mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Auto merge of #14765 - weihanglo:rustfix, r=epage
test(rustfix): switch to a simpler case for dedup-suggestions
This commit is contained in:
commit
40d6078baf
@ -1,17 +1,11 @@
|
|||||||
// This fixes rust-lang/rust#123304.
|
// See <https://github.com/rust-lang/cargo/issues/13027>
|
||||||
// If that lint stops emitting duplicate suggestions,
|
|
||||||
// we might need to find a substitution.
|
|
||||||
#![warn(unsafe_op_in_unsafe_fn)]
|
|
||||||
|
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($x:ident) => {
|
() => {
|
||||||
pub unsafe fn $x() { unsafe {
|
let _ = &1;
|
||||||
let _ = String::new().as_mut_vec();
|
|
||||||
}}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo!(a);
|
foo!();
|
||||||
foo!(b);
|
foo!();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,17 +1,11 @@
|
|||||||
// This fixes rust-lang/rust#123304.
|
// See <https://github.com/rust-lang/cargo/issues/13027>
|
||||||
// If that lint stops emitting duplicate suggestions,
|
|
||||||
// we might need to find a substitution.
|
|
||||||
#![warn(unsafe_op_in_unsafe_fn)]
|
|
||||||
|
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($x:ident) => {
|
() => {
|
||||||
pub unsafe fn $x() {
|
&1;
|
||||||
let _ = String::new().as_mut_vec();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo!(a);
|
foo!();
|
||||||
foo!(b);
|
foo!();
|
||||||
}
|
}
|
||||||
|
@ -2308,47 +2308,53 @@ error[E0308]: mismatched types
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This fixes rust-lang/rust#123304.
|
// See <https://github.com/rust-lang/cargo/issues/13027>
|
||||||
// If that lint stops emitting duplicate suggestions,
|
|
||||||
// we might need to find a substitution.
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn fix_only_once_for_duplicates() {
|
fn fix_only_once_for_duplicates() {
|
||||||
let p = project()
|
let p = project()
|
||||||
.file(
|
.file(
|
||||||
"src/lib.rs",
|
"src/main.rs",
|
||||||
r#"
|
r#"
|
||||||
#![warn(unsafe_op_in_unsafe_fn)]
|
macro_rules! foo {
|
||||||
|
() => {
|
||||||
|
&1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! foo {
|
fn main() {
|
||||||
($x:ident) => {
|
foo!();
|
||||||
pub unsafe fn $x() {
|
foo!();
|
||||||
let _ = String::new().as_mut_vec();
|
}
|
||||||
}
|
"#,
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
foo!(a);
|
|
||||||
foo!(b);
|
|
||||||
"#,
|
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("fix --allow-no-vcs")
|
p.cargo("fix --allow-no-vcs")
|
||||||
|
.env("__CARGO_FIX_YOLO", "1")
|
||||||
.with_stderr_data(str![[r#"
|
.with_stderr_data(str![[r#"
|
||||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||||
[FIXED] src/lib.rs (1 fix)
|
[FIXED] src/main.rs (1 fix)
|
||||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
|
|
||||||
"#]])
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
assert_eq!(
|
assert_e2e().eq(
|
||||||
p.read_file("src/lib.rs").matches("unsafe").count(),
|
p.read_file("src/main.rs"),
|
||||||
4,
|
str![[r#"
|
||||||
"unsafe keyword in src/lib.rs:\n\
|
|
||||||
2 in lint name;\n\
|
macro_rules! foo {
|
||||||
1 from original unsafe fn;\n\
|
() => {
|
||||||
1 from newly-applied unsafe blocks"
|
let _ = &1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo!();
|
||||||
|
foo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user