-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Iteratively apply suggestions from the compiler #5842
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -927,3 +927,42 @@ issues in preparation for the 2018 edition | |
.with_status(0), | ||
); | ||
} | ||
|
||
#[test] | ||
fn fix_overlapping() { | ||
if !is_nightly() { | ||
return | ||
} | ||
let p = project() | ||
.file( | ||
"src/lib.rs", | ||
r#" | ||
#![feature(rust_2018_preview)] | ||
|
||
pub fn foo<T>() {} | ||
pub struct A; | ||
|
||
pub mod bar { | ||
pub fn baz() { | ||
::foo::<::A>(); | ||
} | ||
} | ||
"# | ||
) | ||
.build(); | ||
|
||
let stderr = "\ | ||
[CHECKING] foo [..] | ||
[FIXING] src[/]lib.rs (2 fixes) | ||
[FINISHED] dev [..] | ||
"; | ||
|
||
assert_that( | ||
p.cargo("fix --allow-no-vcs --prepare-for 2018 --lib"), | ||
execs().with_status(0).with_stderr(stderr), | ||
); | ||
|
||
let contents = p.read_file("src/lib.rs"); | ||
println!("{}", contents); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah this is a "poor man's way" of debugging the test if it fails (as the output is swallowed up if successful). That way it allows looking through just the test output to see why the output didn't exist! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
TIL. Very neat! |
||
assert!(contents.contains("crate::foo::<crate::A>()")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to explicitly call
iter
instead of just&fixes.files
? (same below)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally not a huge fan of
for x in &y
as opposed tofor x in y
orfor x in y.iter()
, the latter one feels more clear to me.