diff options
| author | bors <bors@rust-lang.org> | 2022-08-23 15:12:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-23 15:12:09 +0000 |
| commit | a1bea1551b8312b6abfbbf7d49bafac2e6ce8ee4 (patch) | |
| tree | 0ed13d7fbdb1bbecb2499452d47625c915ec93b2 /src | |
| parent | 1cff5642037b83ce1239a624bbe617a9aa0d59b1 (diff) | |
| parent | 28ead17745916a602fed4ed41a104fb7856544f5 (diff) | |
Auto merge of #100920 - Dylan-DPC:rollup-vlcw3sr, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #99249 (Do not re-parse function signatures to suggest generics) - #100309 (Extend comma suggestion to cases where fields arent missing) - #100368 (InferCtxt tainted_by_errors_flag should be Option<ErrorGuaranteed>) - #100768 (Migrate `rustc_plugin_impl` to `SessionDiagnostic`) - #100835 (net listen backlog update, follow-up from #97963.) - #100851 (Fix rustc_parse_format precision & width spans) - #100857 (Refactor query modifier parsing) - #100907 (Fix typo in UnreachableProp) - #100909 (Minor `ast::LitKind` improvements) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/early/const-param-from-outer-fn.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0401.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/generics/issue-98432.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-3214.stderr | 5 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-5997-enum.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-5997-struct.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/nested-ty-params.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/resolve/bad-type-env-capture.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/resolve/issue-3021-c.stderr | 16 | ||||
| -rw-r--r-- | src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/structs/struct-record-suggestion.fixed | 24 | ||||
| -rw-r--r-- | src/test/ui/structs/struct-record-suggestion.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/structs/struct-record-suggestion.stderr | 23 | ||||
| -rw-r--r-- | src/test/ui/type/type-arg-out-of-scope.stderr | 12 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/utils/author.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/consts.rs | 8 |
17 files changed, 116 insertions, 68 deletions
diff --git a/src/test/ui/const-generics/early/const-param-from-outer-fn.stderr b/src/test/ui/const-generics/early/const-param-from-outer-fn.stderr index a9f9787d875..e3bf38b702e 100644 --- a/src/test/ui/const-generics/early/const-param-from-outer-fn.stderr +++ b/src/test/ui/const-generics/early/const-param-from-outer-fn.stderr @@ -4,7 +4,7 @@ error[E0401]: can't use generic parameters from outer function LL | fn foo<const X: u32>() { | - const parameter from outer function LL | fn bar() -> u32 { - | --- try adding a local generic parameter in this method instead + | - help: try using a local generic parameter instead: `<X>` LL | X | ^ use of generic parameter from outer function diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr index 81715621dd9..b0e2ef5b6f7 100644 --- a/src/test/ui/error-codes/E0401.stderr +++ b/src/test/ui/error-codes/E0401.stderr @@ -4,9 +4,9 @@ error[E0401]: can't use generic parameters from outer function LL | fn foo<T>(x: T) { | - type parameter from outer function LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | --------------------------- ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `bfnr<U, V: Baz<U>, W: Fn(), T>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `T,` error[E0401]: can't use generic parameters from outer function --> $DIR/E0401.rs:9:16 @@ -15,7 +15,7 @@ LL | fn foo<T>(x: T) { | - type parameter from outer function ... LL | fn baz<U, - | --- try adding a local generic parameter in this method instead + | - help: try using a local generic parameter instead: `T,` ... LL | (y: T) { | ^ use of generic parameter from outer function diff --git a/src/test/ui/generics/issue-98432.stderr b/src/test/ui/generics/issue-98432.stderr index afa67b63bd9..c7b5c33618d 100644 --- a/src/test/ui/generics/issue-98432.stderr +++ b/src/test/ui/generics/issue-98432.stderr @@ -5,9 +5,9 @@ LL | impl<T> Struct<T> { | - type parameter from outer function LL | const CONST: fn() = || { LL | struct _Obligation where T:; - | ^ use of generic parameter from outer function - | - = help: try using a local generic parameter instead + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<T>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-3214.stderr b/src/test/ui/issues/issue-3214.stderr index 4d8eb6360e6..aa0b5ce64b4 100644 --- a/src/test/ui/issues/issue-3214.stderr +++ b/src/test/ui/issues/issue-3214.stderr @@ -2,10 +2,9 @@ error[E0401]: can't use generic parameters from outer function --> $DIR/issue-3214.rs:3:12 | LL | fn foo<T>() { - | --- - type parameter from outer function - | | - | try adding a local generic parameter in this method instead + | - type parameter from outer function LL | struct Foo { + | - help: try using a local generic parameter instead: `<T>` LL | x: T, | ^ use of generic parameter from outer function diff --git a/src/test/ui/issues/issue-5997-enum.stderr b/src/test/ui/issues/issue-5997-enum.stderr index 1c58b9c3911..3a79215d3ae 100644 --- a/src/test/ui/issues/issue-5997-enum.stderr +++ b/src/test/ui/issues/issue-5997-enum.stderr @@ -2,11 +2,11 @@ error[E0401]: can't use generic parameters from outer function --> $DIR/issue-5997-enum.rs:2:16 | LL | fn f<Z>() -> bool { - | - - type parameter from outer function - | | - | try adding a local generic parameter in this method instead + | - type parameter from outer function LL | enum E { V(Z) } - | ^ use of generic parameter from outer function + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<Z>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5997-struct.stderr b/src/test/ui/issues/issue-5997-struct.stderr index 5b388d16d75..d2e97f76771 100644 --- a/src/test/ui/issues/issue-5997-struct.stderr +++ b/src/test/ui/issues/issue-5997-struct.stderr @@ -2,11 +2,11 @@ error[E0401]: can't use generic parameters from outer function --> $DIR/issue-5997-struct.rs:2:14 | LL | fn f<T>() -> bool { - | - - type parameter from outer function - | | - | try adding a local generic parameter in this method instead + | - type parameter from outer function LL | struct S(T); - | ^ use of generic parameter from outer function + | -^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<T>` error: aborting due to previous error diff --git a/src/test/ui/nested-ty-params.stderr b/src/test/ui/nested-ty-params.stderr index f6741b5e5e8..8f4746f5ec3 100644 --- a/src/test/ui/nested-ty-params.stderr +++ b/src/test/ui/nested-ty-params.stderr @@ -4,9 +4,9 @@ error[E0401]: can't use generic parameters from outer function LL | fn hd<U>(v: Vec<U> ) -> U { | - type parameter from outer function LL | fn hd1(w: [U]) -> U { return w[0]; } - | --- ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `hd1<U>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<U>` error[E0401]: can't use generic parameters from outer function --> $DIR/nested-ty-params.rs:3:23 @@ -14,9 +14,9 @@ error[E0401]: can't use generic parameters from outer function LL | fn hd<U>(v: Vec<U> ) -> U { | - type parameter from outer function LL | fn hd1(w: [U]) -> U { return w[0]; } - | --- ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `hd1<U>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<U>` error: aborting due to 2 previous errors diff --git a/src/test/ui/resolve/bad-type-env-capture.stderr b/src/test/ui/resolve/bad-type-env-capture.stderr index 6f24c0d8699..b6282c2d070 100644 --- a/src/test/ui/resolve/bad-type-env-capture.stderr +++ b/src/test/ui/resolve/bad-type-env-capture.stderr @@ -4,9 +4,9 @@ error[E0401]: can't use generic parameters from outer function LL | fn foo<T>() { | - type parameter from outer function LL | fn bar(b: T) { } - | --- ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `bar<T>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<T>` error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-3021-c.stderr b/src/test/ui/resolve/issue-3021-c.stderr index 8764ac8a856..5176efc3a6b 100644 --- a/src/test/ui/resolve/issue-3021-c.stderr +++ b/src/test/ui/resolve/issue-3021-c.stderr @@ -3,22 +3,22 @@ error[E0401]: can't use generic parameters from outer function | LL | fn siphash<T>() { | - type parameter from outer function -... +LL | +LL | trait U { + | - help: try using a local generic parameter instead: `<T>` LL | fn g(&self, x: T) -> T; - | - ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `g<T>` + | ^ use of generic parameter from outer function error[E0401]: can't use generic parameters from outer function --> $DIR/issue-3021-c.rs:4:30 | LL | fn siphash<T>() { | - type parameter from outer function -... +LL | +LL | trait U { + | - help: try using a local generic parameter instead: `<T>` LL | fn g(&self, x: T) -> T; - | - ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `g<T>` + | ^ use of generic parameter from outer function error: aborting due to 2 previous errors diff --git a/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr b/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr index 10a703ee093..0a6d1cc3bcd 100644 --- a/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr +++ b/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr @@ -4,8 +4,8 @@ error[E0401]: can't use generic parameters from outer function LL | trait TraitA<A> { | - type parameter from outer function LL | fn outer(&self) { - | ----- try adding a local generic parameter in this method instead LL | enum Foo<B> { + | - help: try using a local generic parameter instead: `A,` LL | Variance(A) | ^ use of generic parameter from outer function @@ -15,9 +15,10 @@ error[E0401]: can't use generic parameters from outer function LL | trait TraitB<A> { | - type parameter from outer function LL | fn outer(&self) { - | ----- try adding a local generic parameter in this method instead LL | struct Foo<B>(A); - | ^ use of generic parameter from outer function + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `A,` error[E0401]: can't use generic parameters from outer function --> $DIR/resolve-type-param-in-item-in-trait.rs:23:28 @@ -25,9 +26,10 @@ error[E0401]: can't use generic parameters from outer function LL | trait TraitC<A> { | - type parameter from outer function LL | fn outer(&self) { - | ----- try adding a local generic parameter in this method instead LL | struct Foo<B> { a: A } - | ^ use of generic parameter from outer function + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `A,` error[E0401]: can't use generic parameters from outer function --> $DIR/resolve-type-param-in-item-in-trait.rs:30:22 @@ -36,9 +38,9 @@ LL | trait TraitD<A> { | - type parameter from outer function LL | fn outer(&self) { LL | fn foo<B>(a: A) { } - | ------ ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `foo<B, A>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `A,` error: aborting due to 4 previous errors diff --git a/src/test/ui/structs/struct-record-suggestion.fixed b/src/test/ui/structs/struct-record-suggestion.fixed index 48144cd1ce2..49e38b196de 100644 --- a/src/test/ui/structs/struct-record-suggestion.fixed +++ b/src/test/ui/structs/struct-record-suggestion.fixed @@ -6,11 +6,29 @@ struct A { d: usize, } -fn main() { - let q = A { c: 5, .. Default::default() }; +fn a() { + let q = A { c: 5,..Default::default() }; //~^ ERROR mismatched types //~| ERROR missing fields //~| HELP separate the last named field with a comma - let r = A { c: 5, .. Default::default() }; + let r = A { c: 5, ..Default::default() }; assert_eq!(q, r); } + +#[derive(Debug, Default, Eq, PartialEq)] +struct B { + b: u32, +} + +fn b() { + let q = B { b: 1,..Default::default() }; + //~^ ERROR mismatched types + //~| HELP separate the last named field with a comma + let r = B { b: 1 }; + assert_eq!(q, r); +} + +fn main() { + a(); + b(); +} diff --git a/src/test/ui/structs/struct-record-suggestion.rs b/src/test/ui/structs/struct-record-suggestion.rs index 6d169d5c6db..901f310c8bd 100644 --- a/src/test/ui/structs/struct-record-suggestion.rs +++ b/src/test/ui/structs/struct-record-suggestion.rs @@ -6,11 +6,29 @@ struct A { d: usize, } -fn main() { - let q = A { c: 5 .. Default::default() }; +fn a() { + let q = A { c: 5..Default::default() }; //~^ ERROR mismatched types //~| ERROR missing fields //~| HELP separate the last named field with a comma - let r = A { c: 5, .. Default::default() }; + let r = A { c: 5, ..Default::default() }; assert_eq!(q, r); } + +#[derive(Debug, Default, Eq, PartialEq)] +struct B { + b: u32, +} + +fn b() { + let q = B { b: 1..Default::default() }; + //~^ ERROR mismatched types + //~| HELP separate the last named field with a comma + let r = B { b: 1 }; + assert_eq!(q, r); +} + +fn main() { + a(); + b(); +} diff --git a/src/test/ui/structs/struct-record-suggestion.stderr b/src/test/ui/structs/struct-record-suggestion.stderr index e5bd03117b9..66e9f021ed6 100644 --- a/src/test/ui/structs/struct-record-suggestion.stderr +++ b/src/test/ui/structs/struct-record-suggestion.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/struct-record-suggestion.rs:10:20 | -LL | let q = A { c: 5 .. Default::default() }; - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `std::ops::Range` +LL | let q = A { c: 5..Default::default() }; + | ^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `std::ops::Range` | = note: expected type `u64` found struct `std::ops::Range<{integer}>` @@ -10,15 +10,28 @@ LL | let q = A { c: 5 .. Default::default() }; error[E0063]: missing fields `b` and `d` in initializer of `A` --> $DIR/struct-record-suggestion.rs:10:13 | -LL | let q = A { c: 5 .. Default::default() }; +LL | let q = A { c: 5..Default::default() }; | ^ missing `b` and `d` | help: to set the remaining fields from `Default::default()`, separate the last named field with a comma | -LL | let q = A { c: 5, .. Default::default() }; +LL | let q = A { c: 5,..Default::default() }; | + -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/struct-record-suggestion.rs:24:20 + | +LL | let q = B { b: 1..Default::default() }; + | ^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found struct `std::ops::Range` + | + = note: expected type `u32` + found struct `std::ops::Range<{integer}>` +help: to set the remaining fields from `Default::default()`, separate the last named field with a comma + | +LL | let q = B { b: 1,..Default::default() }; + | + + +error: aborting due to 3 previous errors Some errors have detailed explanations: E0063, E0308. For more information about an error, try `rustc --explain E0063`. diff --git a/src/test/ui/type/type-arg-out-of-scope.stderr b/src/test/ui/type/type-arg-out-of-scope.stderr index 0b6283fbc51..7f18b4510f4 100644 --- a/src/test/ui/type/type-arg-out-of-scope.stderr +++ b/src/test/ui/type/type-arg-out-of-scope.stderr @@ -4,9 +4,9 @@ error[E0401]: can't use generic parameters from outer function LL | fn foo<T>(x: T) { | - type parameter from outer function LL | fn bar(f: Box<dyn FnMut(T) -> T>) { } - | --- ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `bar<T>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<T>` error[E0401]: can't use generic parameters from outer function --> $DIR/type-arg-out-of-scope.rs:3:35 @@ -14,9 +14,9 @@ error[E0401]: can't use generic parameters from outer function LL | fn foo<T>(x: T) { | - type parameter from outer function LL | fn bar(f: Box<dyn FnMut(T) -> T>) { } - | --- ^ use of generic parameter from outer function - | | - | help: try using a local generic parameter instead: `bar<T>` + | - ^ use of generic parameter from outer function + | | + | help: try using a local generic parameter instead: `<T>` error: aborting due to 2 previous errors diff --git a/src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs b/src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs index 582782f245f..e32ef9933af 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs @@ -290,7 +290,7 @@ impl<'a> NormalizedPat<'a> { LitKind::Char(val) => Self::LitInt(val.into()), LitKind::Int(val, _) => Self::LitInt(val), LitKind::Bool(val) => Self::LitBool(val), - LitKind::Float(..) | LitKind::Err(_) => Self::Wild, + LitKind::Float(..) | LitKind::Err => Self::Wild, }, _ => Self::Wild, }, diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index c0726868f77..429c64ac156 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -276,7 +276,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { match lit.value.node { LitKind::Bool(val) => kind!("Bool({val:?})"), LitKind::Char(c) => kind!("Char({c:?})"), - LitKind::Err(val) => kind!("Err({val})"), + LitKind::Err => kind!("Err"), LitKind::Byte(b) => kind!("Byte({b})"), LitKind::Int(i, suffix) => { let int_ty = match suffix { diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index 351a3f4aec8..e053708edd5 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -45,7 +45,7 @@ pub enum Constant { /// A reference Ref(Box<Constant>), /// A literal with syntax error. - Err(Symbol), + Err, } impl PartialEq for Constant { @@ -118,9 +118,7 @@ impl Hash for Constant { Self::Ref(ref r) => { r.hash(state); }, - Self::Err(ref s) => { - s.hash(state); - }, + Self::Err => {}, } } } @@ -194,7 +192,7 @@ pub fn lit_to_mir_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant { _ => bug!(), }, LitKind::Bool(b) => Constant::Bool(b), - LitKind::Err(s) => Constant::Err(s), + LitKind::Err => Constant::Err, } } |
