Skip to content

Inline some conversion methods around OsStr - #68102

Merged
bors merged 7 commits into
rust-lang:masterfrom
tesuji:inline
Jan 11, 2020
Merged

Inline some conversion methods around OsStr#68102
bors merged 7 commits into
rust-lang:masterfrom
tesuji:inline

Conversation

@tesuji

@tesujitesuji commented Jan 10, 2020

Copy link
Copy Markdown
Contributor

Diff on the assembly of this snippet before and after this PR: https://www.diffchecker.com/NeGMjaJ2

use std::env;use std::io;use std::path::{Path,PathBuf};pubfncargo_home_with_cwd(cwd:&Path) -> io::Result<PathBuf>{match env::var_os("CARGO_HOME").filter(|h| !h.is_empty()){Some(home) => {let home = PathBuf::from(home);if home.is_absolute(){Ok(home)}else{Ok(cwd.join(&home))}}
_ => env::home_dir().map(|p| p.join(".cargo")).ok_or_else(|| io::Error::new(io::ErrorKind::Other,"could not find cargo home dir")),}}

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @joshtriplett

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2020
@Centril

Copy link
Copy Markdown
Contributor

r? @alexcrichton

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented Jan 10, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 5f3f1a3 has been approved by alexcrichton

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
Inline some conversion methods around OsStr
Diff on the assembly of this snippet before and after this PR: https://www.diffchecker.com/NeGMjaJ2
```rust
use std::env;
use std::io;
use std::path::{Path, PathBuf};
pub fn cargo_home_with_cwd(cwd: &Path) -> io::Result<PathBuf> {
match env::var_os("CARGO_HOME").filter(|h| !h.is_empty()) {
Some(home) => {
let home = PathBuf::from(home);
if home.is_absolute() {
Ok(home)
} else {
Ok(cwd.join(&home))
}
}
_ => env::home_dir()
.map(|p| p.join(".cargo"))
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "could not find cargo home dir")),
}
}
```
@CentrilCentril mentioned this pull request Jan 11, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
Inline some conversion methods around OsStr
Diff on the assembly of this snippet before and after this PR: https://www.diffchecker.com/NeGMjaJ2
```rust
use std::env;
use std::io;
use std::path::{Path, PathBuf};
pub fn cargo_home_with_cwd(cwd: &Path) -> io::Result<PathBuf> {
match env::var_os("CARGO_HOME").filter(|h| !h.is_empty()) {
Some(home) => {
let home = PathBuf::from(home);
if home.is_absolute() {
Ok(home)
} else {
Ok(cwd.join(&home))
}
}
_ => env::home_dir()
.map(|p| p.join(".cargo"))
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "could not find cargo home dir")),
}
}
```
@CentrilCentril mentioned this pull request Jan 11, 2020
bors added a commit that referenced this pull request Jan 11, 2020
Rollup of 8 pull requests
Successful merges:
- #67666 (make use of pointer::is_null)
- #67806 (Extract `rustc_ast_passes`, move gating, & refactor linting)
- #68043 (Add some missing timers)
- #68074 (Add `llvm-skip-rebuild` flag to `x.py`)
- #68079 (Clarify suggestion for E0013)
- #68084 (Do not ICE on unicode next point)
- #68102 (Inline some conversion methods around OsStr)
- #68106 (Fix issue with using `self` module via indirection)
Failed merges:
r? @ghost
@bors
bors merged commit 5f3f1a3 into rust-lang:masterJan 11, 2020
@tesuji
tesuji deleted the inline branch January 11, 2020 07:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@tesuji@rust-highfive@Centril@alexcrichton@bors@joshtriplett