Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit b5e14a3

Browse files
committed
Merge pull request #112 from matthiaskrgr/fix_RUSTFLAGS_prepare_for
cli: fix injection of --prepare-for flags
2 parents ab63ed8 + 88527e6 commit b5e14a3

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

cargo-fix/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub fn run() -> Result<(), Error> {
104104
if let Some("2018") = matches.value_of("edition") {
105105
info!("edition upgrade!");
106106
let mut rustc_flags = env::var_os("RUSTFLAGS").unwrap_or_else(|| "".into());
107-
rustc_flags.push("-W rust-2018-compatibility");
107+
rustc_flags.push(" -W rust-2018-compatibility");
108108
cmd.env("RUSTFLAGS", &rustc_flags);
109109
}
110110

cargo-fix/tests/all/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ mod broken_build;
356356
mod broken_lints;
357357
mod dependencies;
358358
mod edition_upgrade;
359+
mod rust_flags;
359360
mod smoke;
360361
mod subtargets;
361362
mod vcs;

cargo-fix/tests/all/rust_flags.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use super::project;
2+
3+
#[test]
4+
fn specify_rustflags() {
5+
let p = project()
6+
.file(
7+
"src/lib.rs",
8+
r#"
9+
#![allow(unused)]
10+
#![feature(rust_2018_preview)]
11+
12+
mod foo {
13+
pub const FOO: &str = "fooo";
14+
}
15+
16+
fn main() {
17+
let x = ::foo::FOO;
18+
}
19+
"#,
20+
)
21+
.build();
22+
23+
let stderr = "\
24+
[CHECKING] foo v0.1.0 (CWD)
25+
[FIXING] src/lib.rs (1 fix)
26+
[FINISHED] dev [unoptimized + debuginfo]
27+
";
28+
29+
p.expect_cmd("cargo-fix fix --prepare-for 2018")
30+
.env("RUSTFLAGS", "-C target-cpu=native")
31+
.stdout("")
32+
.stderr(stderr)
33+
.run();
34+
}

cargo-fix/tests/all/smoke.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ fn preserve_line_endings() {
105105
)
106106
.build();
107107

108-
p.expect_cmd("cargo-fix fix")
109-
.fix_everything()
110-
.run();
108+
p.expect_cmd("cargo-fix fix").fix_everything().run();
111109
assert!(p.read("src/lib.rs").contains("\r\n"));
112110
}
113111

@@ -123,9 +121,7 @@ fn fix_deny_warnings() {
123121
)
124122
.build();
125123

126-
p.expect_cmd("cargo-fix fix")
127-
.fix_everything()
128-
.run();
124+
p.expect_cmd("cargo-fix fix").fix_everything().run();
129125
}
130126

131127
#[test]
@@ -146,9 +142,7 @@ fn fix_deny_warnings_but_not_others() {
146142
)
147143
.build();
148144

149-
p.expect_cmd("cargo-fix fix")
150-
.fix_everything()
151-
.run();
145+
p.expect_cmd("cargo-fix fix").fix_everything().run();
152146
assert!(!p.read("src/lib.rs").contains("let mut x = 3;"));
153147
assert!(p.read("src/lib.rs").contains("fn bar() {}"));
154148
}

src/replace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum State {
1414

1515
impl State {
1616
fn is_inserted(&self) -> bool {
17-
if let &State::Inserted(..) = self {
17+
if let State::Inserted(..) = *self {
1818
true
1919
} else {
2020
false
@@ -26,7 +26,7 @@ impl State {
2626
struct Span {
2727
/// Start of this span in parent data
2828
start: usize,
29-
/// up to end inculding
29+
/// up to end including
3030
end: usize,
3131
data: State,
3232
}

0 commit comments

Comments
 (0)