From 6ece80fcb672ee3053ccf4fafed62e7307b56a66 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 4 Apr 2022 12:16:20 -0700 Subject: [PATCH 1/9] diagnostics: use correct span for const generics Fixes #95616 --- compiler/rustc_ast_lowering/src/lib.rs | 2 +- ...ait-with-supertraits-needing-sized-self.stderr | 2 +- .../ui/async-await/issues/issue-78654.full.stderr | 4 ++-- .../ui/async-await/issues/issue-78654.min.stderr | 4 ++-- .../defaults/default-on-impl.stderr | 4 ++-- .../generic_const_exprs/issue-76595.stderr | 2 +- .../incorrect-number-of-const-args.stderr | 4 ++-- .../const-generics/issues/issue-68366.full.stderr | 8 ++++---- .../const-generics/issues/issue-68366.min.stderr | 8 ++++---- .../ui/const-generics/issues/issue-86820.stderr | 8 ++++---- .../default_function_param.stderr | 4 ++-- .../issue-89013-no-kw.stderr | 2 +- .../parser-error-recovery/issue-89013.stderr | 2 +- ...re-gate-default_type_parameter_fallback.stderr | 4 ++-- .../generic-impl-more-params-with-defaults.stderr | 2 +- .../generic-type-more-params-with-defaults.stderr | 2 +- ...-type-param-can-reference-self-in-trait.stderr | 2 +- src/test/ui/generics/wrong-number-of-args.stderr | 4 ++-- src/test/ui/impl-trait/where-allowed.stderr | 4 ++-- src/test/ui/issues/issue-78957.stderr | 6 +++--- src/test/ui/mir/thir-constparam-temp.stderr | 4 ++-- .../missing-items/missing-type-parameter2.stderr | 4 ++-- .../const_parameters/closures.stderr | 8 ++++---- .../const_parameters/functions.stderr | 2 +- src/test/ui/polymorphization/generators.stderr | 2 +- src/test/ui/save-analysis/issue-89066.stderr | 2 +- ...sing-lifetimes-in-signature-before-const.fixed | 10 ++++++++++ ...missing-lifetimes-in-signature-before-const.rs | 10 ++++++++++ ...ing-lifetimes-in-signature-before-const.stderr | 15 +++++++++++++++ .../generic_duplicate_param_use.stderr | 4 ++-- .../generic_nondefining_use.stderr | 4 ++-- src/test/ui/type/type-check-defaults.stderr | 4 ++-- 32 files changed, 91 insertions(+), 56 deletions(-) create mode 100644 src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed create mode 100644 src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs create mode 100644 src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index e4ed48d4b530d..e7e82e651bb09 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -2068,7 +2068,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::GenericParam { hir_id, name, - span: self.lower_span(param.ident.span), + span: self.lower_span(param.span()), pure_wrt_drop: self.sess.contains_name(¶m.attrs, sym::may_dangle), bounds: self.arena.alloc_from_iter(bounds), kind, diff --git a/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr b/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr index 558b0f5c8a368..0edc9a556b7f6 100644 --- a/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr +++ b/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr @@ -8,7 +8,7 @@ note: required by a bound in `Add` --> $SRC_DIR/core/src/ops/arith.rs:LL:COL | LL | pub trait Add { - | ^^^ required by this bound in `Add` + | ^^^^^^^^^^ required by this bound in `Add` help: consider further restricting `Self` | LL | trait ArithmeticOps: Add + Sub + Mul + Div + Sized {} diff --git a/src/test/ui/async-await/issues/issue-78654.full.stderr b/src/test/ui/async-await/issues/issue-78654.full.stderr index a9208ade74068..0d12a948c68bd 100644 --- a/src/test/ui/async-await/issues/issue-78654.full.stderr +++ b/src/test/ui/async-await/issues/issue-78654.full.stderr @@ -5,10 +5,10 @@ LL | impl Foo { | ^^^^^^^ not a type error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-78654.rs:9:12 + --> $DIR/issue-78654.rs:9:6 | LL | impl Foo { - | ^ unconstrained const parameter + | ^^^^^^^^^^^^^^^^ unconstrained const parameter | = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/src/test/ui/async-await/issues/issue-78654.min.stderr b/src/test/ui/async-await/issues/issue-78654.min.stderr index a9208ade74068..0d12a948c68bd 100644 --- a/src/test/ui/async-await/issues/issue-78654.min.stderr +++ b/src/test/ui/async-await/issues/issue-78654.min.stderr @@ -5,10 +5,10 @@ LL | impl Foo { | ^^^^^^^ not a type error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-78654.rs:9:12 + --> $DIR/issue-78654.rs:9:6 | LL | impl Foo { - | ^ unconstrained const parameter + | ^^^^^^^^^^^^^^^^ unconstrained const parameter | = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/src/test/ui/const-generics/defaults/default-on-impl.stderr b/src/test/ui/const-generics/defaults/default-on-impl.stderr index ddfc0ead8ad8c..4b2b05742538b 100644 --- a/src/test/ui/const-generics/defaults/default-on-impl.stderr +++ b/src/test/ui/const-generics/defaults/default-on-impl.stderr @@ -1,8 +1,8 @@ error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default-on-impl.rs:3:12 + --> $DIR/default-on-impl.rs:3:6 | LL | impl Foo {} - | ^ + | ^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr index 3b69a4066a9ed..c587a7e153fe3 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr @@ -10,7 +10,7 @@ note: function defined here, with 2 generic parameters: `T`, `P` --> $DIR/issue-76595.rs:10:4 | LL | fn test() where Bool<{core::mem::size_of::() > 4}>: True { - | ^^^^ - - + | ^^^^ - -------------- help: add missing generic argument | LL | test::<2, P>(); diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.stderr b/src/test/ui/const-generics/incorrect-number-of-const-args.stderr index bf873dacd98e1..a845454f762cf 100644 --- a/src/test/ui/const-generics/incorrect-number-of-const-args.stderr +++ b/src/test/ui/const-generics/incorrect-number-of-const-args.stderr @@ -10,7 +10,7 @@ note: function defined here, with 2 generic parameters: `X`, `Y` --> $DIR/incorrect-number-of-const-args.rs:1:4 | LL | fn foo() -> usize { - | ^^^ - - + | ^^^ -------------- -------------- help: add missing generic argument | LL | foo::<0, Y>(); @@ -28,7 +28,7 @@ note: function defined here, with 2 generic parameters: `X`, `Y` --> $DIR/incorrect-number-of-const-args.rs:1:4 | LL | fn foo() -> usize { - | ^^^ - - + | ^^^ -------------- -------------- error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-68366.full.stderr b/src/test/ui/const-generics/issues/issue-68366.full.stderr index 4015fb090b934..ca9eb801dfce7 100644 --- a/src/test/ui/const-generics/issues/issue-68366.full.stderr +++ b/src/test/ui/const-generics/issues/issue-68366.full.stderr @@ -1,17 +1,17 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:11:13 + --> $DIR/issue-68366.rs:11:7 | LL | impl Collatz<{Some(N)}> {} - | ^ unconstrained const parameter + | ^^^^^^^^^^^^^^ unconstrained const parameter | = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:17:12 + --> $DIR/issue-68366.rs:17:6 | LL | impl Foo {} - | ^ unconstrained const parameter + | ^^^^^^^^^^^^^^ unconstrained const parameter | = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/src/test/ui/const-generics/issues/issue-68366.min.stderr b/src/test/ui/const-generics/issues/issue-68366.min.stderr index 9f370b0f510f4..3740ced90b1d7 100644 --- a/src/test/ui/const-generics/issues/issue-68366.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68366.min.stderr @@ -8,19 +8,19 @@ LL | impl Collatz<{Some(N)}> {} = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:11:13 + --> $DIR/issue-68366.rs:11:7 | LL | impl Collatz<{Some(N)}> {} - | ^ unconstrained const parameter + | ^^^^^^^^^^^^^^ unconstrained const parameter | = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:17:12 + --> $DIR/issue-68366.rs:17:6 | LL | impl Foo {} - | ^ unconstrained const parameter + | ^^^^^^^^^^^^^^ unconstrained const parameter | = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/src/test/ui/const-generics/issues/issue-86820.stderr b/src/test/ui/const-generics/issues/issue-86820.stderr index f4396f2f2b0a2..f7b8d80eeca7f 100644 --- a/src/test/ui/const-generics/issues/issue-86820.stderr +++ b/src/test/ui/const-generics/issues/issue-86820.stderr @@ -1,14 +1,14 @@ error[E0053]: method `bit` has an incompatible const parameter type for trait - --> $DIR/issue-86820.rs:17:18 + --> $DIR/issue-86820.rs:17:12 | LL | fn bit(self) -> bool { - | ^ + | ^^^^^^^^^^^^^^^ | note: the const parameter `I` has type `usize`, but the declaration in trait `Bits::bit` has type `u8` - --> $DIR/issue-86820.rs:12:18 + --> $DIR/issue-86820.rs:12:12 | LL | fn bit(self) -> bool; - | ^ + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr index 07dcd57dab8cb..dedad2880c9e8 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr @@ -1,8 +1,8 @@ error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default_function_param.rs:3:14 + --> $DIR/default_function_param.rs:3:8 | LL | fn foo() {} - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-kw.stderr b/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-kw.stderr index 59ba054aa1127..acfdde8e1a01f 100644 --- a/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-kw.stderr +++ b/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-kw.stderr @@ -17,7 +17,7 @@ note: trait defined here, with 1 generic parameter: `N` --> $DIR/issue-89013-no-kw.rs:1:7 | LL | trait Foo { - | ^^^ - + | ^^^ -------------- help: add missing generic argument | LL | impl Foo for Bar { diff --git a/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr b/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr index 9d4739926700b..d2d58c496df2c 100644 --- a/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr +++ b/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr @@ -29,7 +29,7 @@ note: trait defined here, with 1 generic parameter: `N` --> $DIR/issue-89013.rs:1:7 | LL | trait Foo { - | ^^^ - + | ^^^ -------------- help: add missing generic argument | LL | impl Foo for Bar { diff --git a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr index 5cd38ebab370e..a7d5c7ac39b09 100644 --- a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr +++ b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr @@ -2,7 +2,7 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` --> $DIR/feature-gate-default_type_parameter_fallback.rs:3:8 | LL | fn avg(_: T) {} - | ^ + | ^^^^^ | = note: `#[deny(invalid_type_param_default)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -12,7 +12,7 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` --> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6 | LL | impl S {} - | ^ + | ^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #36887 diff --git a/src/test/ui/generics/generic-impl-more-params-with-defaults.stderr b/src/test/ui/generics/generic-impl-more-params-with-defaults.stderr index 059289533dadc..fe9b670da799c 100644 --- a/src/test/ui/generics/generic-impl-more-params-with-defaults.stderr +++ b/src/test/ui/generics/generic-impl-more-params-with-defaults.stderr @@ -10,7 +10,7 @@ note: struct defined here, with at most 2 generic parameters: `T`, `A` --> $DIR/generic-impl-more-params-with-defaults.rs:5:8 | LL | struct Vec( - | ^^^ - - + | ^^^ - -------- error: aborting due to previous error diff --git a/src/test/ui/generics/generic-type-more-params-with-defaults.stderr b/src/test/ui/generics/generic-type-more-params-with-defaults.stderr index 500880cfb8678..7f0198f0e8424 100644 --- a/src/test/ui/generics/generic-type-more-params-with-defaults.stderr +++ b/src/test/ui/generics/generic-type-more-params-with-defaults.stderr @@ -10,7 +10,7 @@ note: struct defined here, with at most 2 generic parameters: `T`, `A` --> $DIR/generic-type-more-params-with-defaults.rs:5:8 | LL | struct Vec( - | ^^^ - - + | ^^^ - -------- error: aborting due to previous error diff --git a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr index 2c397d80b013e..6791182238c72 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr +++ b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr @@ -9,7 +9,7 @@ note: required by a bound in `Tsized` --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:14 | LL | trait Tsized {} - | ^ required by this bound in `Tsized` + | ^^^^^^^^^^^^^^^^^ required by this bound in `Tsized` error: aborting due to previous error diff --git a/src/test/ui/generics/wrong-number-of-args.stderr b/src/test/ui/generics/wrong-number-of-args.stderr index 22da0dffbf29e..3b0834a5f51b2 100644 --- a/src/test/ui/generics/wrong-number-of-args.stderr +++ b/src/test/ui/generics/wrong-number-of-args.stderr @@ -287,7 +287,7 @@ note: struct defined here, with at most 3 generic parameters: `A`, `B`, `C` --> $DIR/wrong-number-of-args.rs:78:12 | LL | struct Ty; - | ^^ - - - + | ^^ - - ---------------- error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:96:14 @@ -922,7 +922,7 @@ note: struct defined here, with at most 3 generic parameters: `K`, `V`, `S` --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL | LL | pub struct HashMap { - | ^^^^^^^ - - - + | ^^^^^^^ - - --------------- error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:319:18 diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index eef20c2de94bc..58a2f79efb4c6 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -293,7 +293,7 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` --> $DIR/where-allowed.rs:234:7 | LL | impl T {} - | ^ + | ^^^^^^^^^^^^^^ | = note: `#[deny(invalid_type_param_default)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -303,7 +303,7 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` --> $DIR/where-allowed.rs:241:36 | LL | fn in_method_generic_param_default(_: T) {} - | ^ + | ^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #36887 diff --git a/src/test/ui/issues/issue-78957.stderr b/src/test/ui/issues/issue-78957.stderr index 703d272dc988b..fa2eaab5b417b 100644 --- a/src/test/ui/issues/issue-78957.stderr +++ b/src/test/ui/issues/issue-78957.stderr @@ -2,13 +2,13 @@ error[E0518]: attribute should be applied to function or closure --> $DIR/issue-78957.rs:5:16 | LL | pub struct Foo<#[inline] const N: usize>; - | ^^^^^^^^^ - not a function or closure + | ^^^^^^^^^ -------------- not a function or closure error: attribute should be applied to a function --> $DIR/issue-78957.rs:7:16 | LL | pub struct Bar<#[cold] const N: usize>; - | ^^^^^^^ - not a function + | ^^^^^^^ -------------- not a function | note: the lint level is defined here --> $DIR/issue-78957.rs:1:9 @@ -21,7 +21,7 @@ error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/issue-78957.rs:10:23 | LL | pub struct Baz<#[repr(C)] const N: usize>; - | ^ - not a struct, enum, or union + | ^ -------------- not a struct, enum, or union error[E0518]: attribute should be applied to function or closure --> $DIR/issue-78957.rs:13:17 diff --git a/src/test/ui/mir/thir-constparam-temp.stderr b/src/test/ui/mir/thir-constparam-temp.stderr index 297102e657ef6..ed2766c000ec4 100644 --- a/src/test/ui/mir/thir-constparam-temp.stderr +++ b/src/test/ui/mir/thir-constparam-temp.stderr @@ -13,10 +13,10 @@ note: mutable reference created due to call to this method LL | fn mut_self(&mut self) {} | ^^^^^^^^^^^^^^^^^^^^^^ note: `const` item defined here - --> $DIR/thir-constparam-temp.rs:13:14 + --> $DIR/thir-constparam-temp.rs:13:8 | LL | fn foo() { - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^ warning: 1 warning emitted diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr index 3b930d7e4ec14..cbceec58eb1eb 100644 --- a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr +++ b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr @@ -99,10 +99,10 @@ LL | impl X<{ N }> {} | + + error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/missing-type-parameter2.rs:6:15 + --> $DIR/missing-type-parameter2.rs:6:9 | LL | impl X {} - | ^ + | ^^^^^^^^^^^^^^^ error[E0747]: unresolved item provided when a constant was expected --> $DIR/missing-type-parameter2.rs:6:28 diff --git a/src/test/ui/polymorphization/const_parameters/closures.stderr b/src/test/ui/polymorphization/const_parameters/closures.stderr index d0ee893299652..f174215f257eb 100644 --- a/src/test/ui/polymorphization/const_parameters/closures.stderr +++ b/src/test/ui/polymorphization/const_parameters/closures.stderr @@ -11,7 +11,7 @@ error: item has unused generic parameters --> $DIR/closures.rs:19:19 | LL | pub fn unused() -> usize { - | - generic parameter `T` is unused + | -------------- generic parameter `T` is unused LL | LL | let add_one = |x: usize| x + 1; | ^^^^^^^^^^^^^^^^ @@ -20,13 +20,13 @@ error: item has unused generic parameters --> $DIR/closures.rs:17:8 | LL | pub fn unused() -> usize { - | ^^^^^^ - generic parameter `T` is unused + | ^^^^^^ -------------- generic parameter `T` is unused error: item has unused generic parameters --> $DIR/closures.rs:28:19 | LL | pub fn used_parent() -> usize { - | - generic parameter `T` is unused + | -------------- generic parameter `T` is unused LL | let x: usize = T; LL | let add_one = |x: usize| x + 1; | ^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ error: item has unused generic parameters --> $DIR/closures.rs:48:13 | LL | pub fn unused_upvar() -> usize { - | - generic parameter `T` is unused + | -------------- generic parameter `T` is unused LL | let x: usize = T; LL | let y = || x; | ^^^^ diff --git a/src/test/ui/polymorphization/const_parameters/functions.stderr b/src/test/ui/polymorphization/const_parameters/functions.stderr index 03d0bbb6afe60..f2b5a73073892 100644 --- a/src/test/ui/polymorphization/const_parameters/functions.stderr +++ b/src/test/ui/polymorphization/const_parameters/functions.stderr @@ -11,7 +11,7 @@ error: item has unused generic parameters --> $DIR/functions.rs:15:8 | LL | pub fn unused() { - | ^^^^^^ - generic parameter `T` is unused + | ^^^^^^ -------------- generic parameter `T` is unused error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/polymorphization/generators.stderr b/src/test/ui/polymorphization/generators.stderr index 1152bcb0734a6..9cabb21e784ad 100644 --- a/src/test/ui/polymorphization/generators.stderr +++ b/src/test/ui/polymorphization/generators.stderr @@ -23,7 +23,7 @@ error: item has unused generic parameters --> $DIR/generators.rs:60:5 | LL | pub fn unused_const() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { - | - generic parameter `T` is unused + | ------------ generic parameter `T` is unused LL | / || { LL | | LL | | yield 1; diff --git a/src/test/ui/save-analysis/issue-89066.stderr b/src/test/ui/save-analysis/issue-89066.stderr index a3ff1c02b2a04..5ef04936ea244 100644 --- a/src/test/ui/save-analysis/issue-89066.stderr +++ b/src/test/ui/save-analysis/issue-89066.stderr @@ -31,7 +31,7 @@ note: struct defined here, with 2 generic parameters: `T`, `N` --> $DIR/issue-89066.rs:8:8 | LL | struct All<'a, T, const N: usize> { - | ^^^ - - + | ^^^ - -------------- error: aborting due to 4 previous errors diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed new file mode 100644 index 0000000000000..3c06f4f88c1f9 --- /dev/null +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed @@ -0,0 +1,10 @@ +// run-rustfix +// https://github.com/rust-lang/rust/issues/95616 + +fn buggy_const<'a, const N: usize>(_a: &'a Option<[u8; N]>, _f: &'a str) -> &'a str { //~ERROR [E0106] + return ""; +} + +fn main() { + buggy_const(&Some([69,69,69,69,0]), "test"); +} diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs new file mode 100644 index 0000000000000..110468cbbc52e --- /dev/null +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs @@ -0,0 +1,10 @@ +// run-rustfix +// https://github.com/rust-lang/rust/issues/95616 + +fn buggy_const(_a: &Option<[u8; N]>, _f: &str) -> &str { //~ERROR [E0106] + return ""; +} + +fn main() { + buggy_const(&Some([69,69,69,69,0]), "test"); +} diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr new file mode 100644 index 0000000000000..7b126c90ee797 --- /dev/null +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr @@ -0,0 +1,15 @@ +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetimes-in-signature-before-const.rs:4:67 + | +LL | fn buggy_const(_a: &Option<[u8; N]>, _f: &str) -> &str { + | ---------------- ---- ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `_a` or `_f` +help: consider introducing a named lifetime parameter + | +LL | fn buggy_const<'a, const N: usize>(_a: &'a Option<[u8; N]>, _f: &'a str) -> &'a str { + | +++ ++ ++ ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index 922e41e0f6883..b2edcc5526a4a 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -29,10 +29,10 @@ LL | t | ^ | note: constant used multiple times - --> $DIR/generic_duplicate_param_use.rs:12:22 + --> $DIR/generic_duplicate_param_use.rs:12:16 | LL | type TwoConsts = impl Debug; - | ^ ^ + | ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr index 36694900c17b4..6c82d31e18d8b 100644 --- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr @@ -26,10 +26,10 @@ LL | 7u32 | ^^^^ | note: used non-generic constant `123_usize` for generic parameter - --> $DIR/generic_nondefining_use.rs:11:21 + --> $DIR/generic_nondefining_use.rs:11:15 | LL | type OneConst = impl Debug; - | ^ + | ^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index 2a61547997b63..48a043a683ce8 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -2,7 +2,7 @@ error[E0277]: a value of type `i32` cannot be built from an iterator over elemen --> $DIR/type-check-defaults.rs:6:19 | LL | struct WellFormed>(Z); - | ^ value of type `i32` cannot be built from `std::iter::Iterator` + | ^^^^^^^^^^^^^^^^^ value of type `i32` cannot be built from `std::iter::Iterator` | = help: the trait `FromIterator` is not implemented for `i32` note: required by a bound in `Foo` @@ -15,7 +15,7 @@ error[E0277]: a value of type `i32` cannot be built from an iterator over elemen --> $DIR/type-check-defaults.rs:8:27 | LL | struct WellFormedNoBounds>(Z); - | ^ value of type `i32` cannot be built from `std::iter::Iterator` + | ^^^^^^^^^^^^^^^^^^^^^^^^ value of type `i32` cannot be built from `std::iter::Iterator` | = help: the trait `FromIterator` is not implemented for `i32` note: required by a bound in `Foo` From 92246c099e6e6d4c5e88e2ce14ccce0da42a3b68 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Mon, 4 Apr 2022 23:06:12 +0000 Subject: [PATCH 2/9] Rely on #[link] attribute for unwind on Fuchsia. Closes #95575. --- library/unwind/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/unwind/build.rs b/library/unwind/build.rs index a3f5224151d94..61d3f45ca6523 100644 --- a/library/unwind/build.rs +++ b/library/unwind/build.rs @@ -40,8 +40,6 @@ fn main() { // This is handled in the target spec with late_link_args_[static|dynamic] } else if target.contains("uwp-windows-gnu") { println!("cargo:rustc-link-lib=unwind"); - } else if target.contains("fuchsia") { - println!("cargo:rustc-link-lib=unwind"); } else if target.contains("haiku") { println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("redox") { From ccb704c73d5800048c16a836a906a12d909f962f Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Mon, 4 Apr 2022 16:09:49 -0700 Subject: [PATCH 3/9] Update panic docs to make it clearer when to use panic vs Result --- library/core/src/macros/panic.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/library/core/src/macros/panic.md b/library/core/src/macros/panic.md index 5127a16bbfd86..d8206e7893114 100644 --- a/library/core/src/macros/panic.md +++ b/library/core/src/macros/panic.md @@ -1,8 +1,7 @@ Panics the current thread. This allows a program to terminate immediately and provide feedback -to the caller of the program. `panic!` should be used when a program reaches -an unrecoverable state. +to the caller of the program. This macro is the perfect way to assert conditions in example code and in tests. `panic!` is closely tied with the `unwrap` method of both @@ -21,13 +20,25 @@ Inside the hook a panic can be accessed as a `&dyn Any + Send`, which contains either a `&str` or `String` for regular `panic!()` invocations. To panic with a value of another other type, [`panic_any`] can be used. -[`Result`] enum is often a better solution for recovering from errors than -using the `panic!` macro. This macro should be used to avoid proceeding using -incorrect values, such as from external sources. Detailed information about -error handling is found in the [book]. - See also the macro [`compile_error!`], for raising errors during compilation. +# When to use `panic!` vs `Result` + +The Rust model of error handling groups errors into two major categories: +recoverable and unrecoverable errors. For a recoverable error, such as a file +not found error, it’s reasonable to report the problem to the user and retry +the operation. Unrecoverable errors are always symptoms of bugs, like trying to +access a location beyond the end of an array. + +The Rust language and standard library provides `Result` and `panic!` as parts +of two complementary systems for representing, reporting, propagating, reacting +to, and discarding errors for in these two categories. + +The `panic!` macro is provided to represent unrecoverable errors, whereas the +`Result` enum is provided to represent recoverable errors. For more detailed +information about error handling check out the [book] or the [`std::result`] +module docs. + [ounwrap]: Option::unwrap [runwrap]: Result::unwrap [`std::panic::set_hook()`]: ../std/panic/fn.set_hook.html @@ -36,6 +47,7 @@ See also the macro [`compile_error!`], for raising errors during compilation. [`Any`]: crate::any::Any [`format!`]: ../std/macro.format.html [book]: ../book/ch09-00-error-handling.html +[`std::result`]: ../std/result/index.html # Current implementation From 0d2a00058b4b3d4a04712309cc4cc371a8fb8653 Mon Sep 17 00:00:00 2001 From: ohno418 Date: Thu, 31 Mar 2022 23:58:45 +0900 Subject: [PATCH 4/9] Suggest derivable trait on E0277 --- .../src/traits/error_reporting/mod.rs | 1 + .../src/traits/error_reporting/suggestions.rs | 35 +++++++++++++++++++ .../ui/array-slice-vec/repeat_empty_ok.stderr | 8 +++++ .../defaults-suitability.stderr | 8 +++++ .../ui/consts/const-blocks/trait-error.stderr | 4 +++ ...ives-span-Clone-enum-struct-variant.stderr | 4 +++ .../ui/derives/derives-span-Clone-enum.stderr | 4 +++ .../derives/derives-span-Clone-struct.stderr | 4 +++ .../derives-span-Clone-tuple-struct.stderr | 4 +++ ...ives-span-Debug-enum-struct-variant.stderr | 4 +++ .../ui/derives/derives-span-Debug-enum.stderr | 4 +++ .../derives/derives-span-Debug-struct.stderr | 4 +++ .../derives-span-Debug-tuple-struct.stderr | 4 +++ .../derives-span-Default-struct.stderr | 4 +++ .../derives-span-Default-tuple-struct.stderr | 4 +++ ...derives-span-Eq-enum-struct-variant.stderr | 4 +++ .../ui/derives/derives-span-Eq-enum.stderr | 4 +++ .../ui/derives/derives-span-Eq-struct.stderr | 4 +++ .../derives-span-Eq-tuple-struct.stderr | 4 +++ ...rives-span-Hash-enum-struct-variant.stderr | 4 +++ .../ui/derives/derives-span-Hash-enum.stderr | 4 +++ .../derives/derives-span-Hash-struct.stderr | 4 +++ .../derives-span-Hash-tuple-struct.stderr | 4 +++ ...erives-span-Ord-enum-struct-variant.stderr | 4 +++ .../ui/derives/derives-span-Ord-enum.stderr | 4 +++ .../ui/derives/derives-span-Ord-struct.stderr | 4 +++ .../derives-span-Ord-tuple-struct.stderr | 4 +++ ...span-PartialOrd-enum-struct-variant.stderr | 4 +++ .../derives-span-PartialOrd-enum.stderr | 4 +++ .../derives-span-PartialOrd-struct.stderr | 4 +++ ...erives-span-PartialOrd-tuple-struct.stderr | 4 +++ ...eriving-no-inner-impl-error-message.stderr | 4 +++ src/test/ui/error-codes/E0277-3.rs | 8 +++++ src/test/ui/error-codes/E0277-3.stderr | 22 ++++++++++++ ...issue-87429-associated-type-default.stderr | 4 +++ .../issue-87429-specialization.stderr | 4 +++ src/test/ui/issues/issue-20162.stderr | 4 +++ src/test/ui/issues/issue-21160.stderr | 4 +++ src/test/ui/issues/issue-34229.stderr | 4 +++ src/test/ui/kindck/kindck-copy.stderr | 4 +++ .../ui/kindck/kindck-impl-type-params.stderr | 4 +++ .../malformed/malformed-derive-entry.stderr | 8 +++++ .../method-help-unsatisfied-bound.stderr | 4 +++ src/test/ui/not-clone-closure.stderr | 4 +++ src/test/ui/on-unimplemented/no-debug.stderr | 4 +++ src/test/ui/repeat-to-run-dtor-twice.stderr | 4 +++ .../dbg-macro-requires-debug.stderr | 4 +++ .../call-generic-method-nonconst.stderr | 4 +++ src/test/ui/specialization/issue-59435.stderr | 4 +++ .../structs/struct-path-alias-bounds.stderr | 4 +++ .../derive-macro-missing-bounds.stderr | 4 +++ .../suggestions/issue-84973-blacklist.stderr | 4 +++ .../supertrait-auto-trait.stderr | 4 +++ src/test/ui/traits/issue-71136.stderr | 4 +++ .../union-derive-clone.mirunsafeck.stderr | 4 +++ .../union-derive-clone.thirunsafeck.stderr | 4 +++ .../union/union-derive-eq.mirunsafeck.stderr | 4 +++ .../union/union-derive-eq.thirunsafeck.stderr | 4 +++ src/test/ui/wf/wf-const-type.stderr | 4 +++ src/test/ui/wf/wf-static-type.stderr | 4 +++ .../where-clauses-method-unsatisfied.stderr | 4 +++ .../where-clauses-unsatisfied.stderr | 4 +++ 62 files changed, 310 insertions(+) create mode 100644 src/test/ui/error-codes/E0277-3.rs create mode 100644 src/test/ui/error-codes/E0277-3.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 0a22c02520939..e196362de7afd 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -536,6 +536,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ); self.note_version_mismatch(&mut err, &trait_ref); self.suggest_remove_await(&obligation, &mut err); + self.suggest_derive(&mut err, trait_predicate); if Some(trait_ref.def_id()) == tcx.lang_items().try_trait() { self.suggest_await_before_try( diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 105e338048680..4db6ff0875442 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -189,6 +189,8 @@ pub trait InferCtxtExt<'tcx> { err: &mut Diagnostic, trait_ref: &ty::PolyTraitRef<'tcx>, ); + + fn suggest_derive(&self, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>); } fn predicate_constraint(generics: &hir::Generics<'_>, pred: String) -> (Span, String) { @@ -2589,6 +2591,39 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { _ => {} } } + + fn suggest_derive(&self, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>) { + if let Some(diagnostic_name) = self.tcx.get_diagnostic_name(trait_pred.def_id()) { + let adt = match trait_pred.skip_binder().self_ty().ty_adt_def() { + Some(adt) if adt.did().is_local() => adt, + _ => return, + }; + let can_derive = match diagnostic_name { + sym::Default => !adt.is_enum(), + sym::Eq + | sym::PartialEq + | sym::Ord + | sym::PartialOrd + | sym::Clone + | sym::Copy + | sym::Hash + | sym::Debug => true, + _ => false, + }; + if can_derive { + err.span_suggestion_verbose( + self.tcx.def_span(adt.did()).shrink_to_lo(), + &format!( + "consider annotating `{}` with `#[derive({})]`", + trait_pred.skip_binder().self_ty().to_string(), + diagnostic_name.to_string(), + ), + format!("#[derive({})]\n", diagnostic_name.to_string()), + Applicability::MaybeIncorrect, + ); + } + } + } } /// Collect all the returned expressions within the input expression. diff --git a/src/test/ui/array-slice-vec/repeat_empty_ok.stderr b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr index 85baa1268bf04..eba1a8e2278b7 100644 --- a/src/test/ui/array-slice-vec/repeat_empty_ok.stderr +++ b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr @@ -5,6 +5,10 @@ LL | let headers = [Header{value: &[]}; 128]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>` | = note: the `Copy` trait is required because the repeated element will be copied +help: consider annotating `Header<'_>` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied --> $DIR/repeat_empty_ok.rs:13:19 @@ -13,6 +17,10 @@ LL | let headers = [Header{value: &[0]}; 128]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>` | = note: the `Copy` trait is required because the repeated element will be copied +help: consider annotating `Header<'_>` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr index 6c63c01e2c2f7..43541c5dfbcb5 100644 --- a/src/test/ui/associated-types/defaults-suitability.stderr +++ b/src/test/ui/associated-types/defaults-suitability.stderr @@ -9,6 +9,10 @@ note: required by a bound in `Tr::Ty` | LL | type Ty: Clone = NotClone; | ^^^^^ required by this bound in `Tr::Ty` +help: consider annotating `NotClone` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error[E0277]: the trait bound `NotClone: Clone` is not satisfied --> $DIR/defaults-suitability.rs:22:15 @@ -24,6 +28,10 @@ LL | Self::Ty: Clone, LL | { LL | type Ty = NotClone; | -- required by a bound in this +help: consider annotating `NotClone` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error[E0277]: the trait bound `T: Clone` is not satisfied --> $DIR/defaults-suitability.rs:28:23 diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr index 26e2848e7f7a1..b6afbe1b532fd 100644 --- a/src/test/ui/consts/const-blocks/trait-error.stderr +++ b/src/test/ui/consts/const-blocks/trait-error.stderr @@ -7,6 +7,10 @@ LL | [Foo(String::new()); 4]; = help: the following implementations were found: as Copy> = note: the `Copy` trait is required because the repeated element will be copied +help: consider annotating `Foo` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr index cc874576cb7b9..7326324b03cca 100644 --- a/src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Clone` is not implemented for `Error` | = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Clone-enum.stderr b/src/test/ui/derives/derives-span-Clone-enum.stderr index a4870635de870..229a4f7d9ff94 100644 --- a/src/test/ui/derives/derives-span-Clone-enum.stderr +++ b/src/test/ui/derives/derives-span-Clone-enum.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Clone` is not implemented for `Error` | = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Clone-struct.stderr b/src/test/ui/derives/derives-span-Clone-struct.stderr index 4507eeccc3aee..96bad9edad94c 100644 --- a/src/test/ui/derives/derives-span-Clone-struct.stderr +++ b/src/test/ui/derives/derives-span-Clone-struct.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Clone` is not implemented for `Error` | = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Clone-tuple-struct.stderr b/src/test/ui/derives/derives-span-Clone-tuple-struct.stderr index a79be7f574d6f..b61341e57e671 100644 --- a/src/test/ui/derives/derives-span-Clone-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Clone-tuple-struct.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Clone` is not implemented for `Error` | = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Debug-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Debug-enum-struct-variant.stderr index bdcbbf0c75787..58a64a4f53bfc 100644 --- a/src/test/ui/derives/derives-span-Debug-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Debug-enum-struct-variant.stderr @@ -10,6 +10,10 @@ LL | x: Error = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Debug-enum.stderr b/src/test/ui/derives/derives-span-Debug-enum.stderr index 4ffb75935af9b..e9bb5f960b04a 100644 --- a/src/test/ui/derives/derives-span-Debug-enum.stderr +++ b/src/test/ui/derives/derives-span-Debug-enum.stderr @@ -10,6 +10,10 @@ LL | Error = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Debug-struct.stderr b/src/test/ui/derives/derives-span-Debug-struct.stderr index 74d2460bb6906..0a117c060ff38 100644 --- a/src/test/ui/derives/derives-span-Debug-struct.stderr +++ b/src/test/ui/derives/derives-span-Debug-struct.stderr @@ -10,6 +10,10 @@ LL | x: Error = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Debug-tuple-struct.stderr b/src/test/ui/derives/derives-span-Debug-tuple-struct.stderr index 34ddb4e594377..f2e90a418455f 100644 --- a/src/test/ui/derives/derives-span-Debug-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Debug-tuple-struct.stderr @@ -10,6 +10,10 @@ LL | Error = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Default-struct.stderr b/src/test/ui/derives/derives-span-Default-struct.stderr index dd2cfaf89bb8f..d4affd535eef4 100644 --- a/src/test/ui/derives/derives-span-Default-struct.stderr +++ b/src/test/ui/derives/derives-span-Default-struct.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Default` is not implemented for `Error` | = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Default)]` + | +LL | #[derive(Default)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Default-tuple-struct.stderr b/src/test/ui/derives/derives-span-Default-tuple-struct.stderr index 0674d635d3d0e..129351f599899 100644 --- a/src/test/ui/derives/derives-span-Default-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Default-tuple-struct.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Default` is not implemented for `Error` | = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Default)]` + | +LL | #[derive(Default)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr index 277454a1140e6..e3fb234b96e41 100644 --- a/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr @@ -13,6 +13,10 @@ note: required by a bound in `AssertParamIsEq` LL | pub struct AssertParamIsEq { | ^^ required by this bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-enum.stderr b/src/test/ui/derives/derives-span-Eq-enum.stderr index 6a48ad24561ec..4e10c3f69e735 100644 --- a/src/test/ui/derives/derives-span-Eq-enum.stderr +++ b/src/test/ui/derives/derives-span-Eq-enum.stderr @@ -13,6 +13,10 @@ note: required by a bound in `AssertParamIsEq` LL | pub struct AssertParamIsEq { | ^^ required by this bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-struct.stderr b/src/test/ui/derives/derives-span-Eq-struct.stderr index 7bf83e8eae2d3..bfdab052a2ed4 100644 --- a/src/test/ui/derives/derives-span-Eq-struct.stderr +++ b/src/test/ui/derives/derives-span-Eq-struct.stderr @@ -13,6 +13,10 @@ note: required by a bound in `AssertParamIsEq` LL | pub struct AssertParamIsEq { | ^^ required by this bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr b/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr index 13e2a55319eb5..26b8be343336b 100644 --- a/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr @@ -13,6 +13,10 @@ note: required by a bound in `AssertParamIsEq` LL | pub struct AssertParamIsEq { | ^^ required by this bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr index 7f24be959f019..fe5e0e96ac7af 100644 --- a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Hash` is not implemented for `Error` | = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Hash)]` + | +LL | #[derive(Hash)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-enum.stderr b/src/test/ui/derives/derives-span-Hash-enum.stderr index ae2921a16b315..99785b87ca83e 100644 --- a/src/test/ui/derives/derives-span-Hash-enum.stderr +++ b/src/test/ui/derives/derives-span-Hash-enum.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Hash` is not implemented for `Error` | = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Hash)]` + | +LL | #[derive(Hash)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-struct.stderr b/src/test/ui/derives/derives-span-Hash-struct.stderr index 37b3af702a0c1..4db83dd130010 100644 --- a/src/test/ui/derives/derives-span-Hash-struct.stderr +++ b/src/test/ui/derives/derives-span-Hash-struct.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Hash` is not implemented for `Error` | = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Hash)]` + | +LL | #[derive(Hash)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr b/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr index 18624667d25ee..8660c97e69e1c 100644 --- a/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Hash` is not implemented for `Error` | = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Hash)]` + | +LL | #[derive(Hash)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Ord-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Ord-enum-struct-variant.stderr index b52c5a0d6a504..6e48332c25067 100644 --- a/src/test/ui/derives/derives-span-Ord-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Ord-enum-struct-variant.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Ord` is not implemented for `Error` | = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Ord)]` + | +LL | #[derive(Ord)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Ord-enum.stderr b/src/test/ui/derives/derives-span-Ord-enum.stderr index 2ea0496ea0db7..b05cf0a057b23 100644 --- a/src/test/ui/derives/derives-span-Ord-enum.stderr +++ b/src/test/ui/derives/derives-span-Ord-enum.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Ord` is not implemented for `Error` | = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Ord)]` + | +LL | #[derive(Ord)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Ord-struct.stderr b/src/test/ui/derives/derives-span-Ord-struct.stderr index 52cf0cf8cd75d..c4def34a83dad 100644 --- a/src/test/ui/derives/derives-span-Ord-struct.stderr +++ b/src/test/ui/derives/derives-span-Ord-struct.stderr @@ -8,6 +8,10 @@ LL | x: Error | ^^^^^^^^ the trait `Ord` is not implemented for `Error` | = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Ord)]` + | +LL | #[derive(Ord)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Ord-tuple-struct.stderr b/src/test/ui/derives/derives-span-Ord-tuple-struct.stderr index ecdf8d8cb5931..a3b288d0fb9cc 100644 --- a/src/test/ui/derives/derives-span-Ord-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Ord-tuple-struct.stderr @@ -8,6 +8,10 @@ LL | Error | ^^^^^ the trait `Ord` is not implemented for `Error` | = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(Ord)]` + | +LL | #[derive(Ord)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr index fc8eb1ebfd3e2..2d19aaf68afb1 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr @@ -9,6 +9,10 @@ LL | x: Error | = help: the trait `PartialOrd` is not implemented for `Error` = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(PartialOrd)]` + | +LL | #[derive(PartialOrd)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-PartialOrd-enum.stderr b/src/test/ui/derives/derives-span-PartialOrd-enum.stderr index 38053495a0572..dfbb8060ffa12 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-enum.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-enum.stderr @@ -9,6 +9,10 @@ LL | Error | = help: the trait `PartialOrd` is not implemented for `Error` = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(PartialOrd)]` + | +LL | #[derive(PartialOrd)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-PartialOrd-struct.stderr b/src/test/ui/derives/derives-span-PartialOrd-struct.stderr index 1c07b98f983de..ba63d86e8e46c 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-struct.stderr @@ -9,6 +9,10 @@ LL | x: Error | = help: the trait `PartialOrd` is not implemented for `Error` = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(PartialOrd)]` + | +LL | #[derive(PartialOrd)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr b/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr index bf01252b07b8d..7686ed8064e79 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr @@ -9,6 +9,10 @@ LL | Error | = help: the trait `PartialOrd` is not implemented for `Error` = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Error` with `#[derive(PartialOrd)]` + | +LL | #[derive(PartialOrd)] + | error: aborting due to previous error diff --git a/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr b/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr index d64b4509b260b..451058cd0ee01 100644 --- a/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr +++ b/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr @@ -48,6 +48,10 @@ LL | x: NoCloneOrEq | ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoCloneOrEq` | = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `NoCloneOrEq` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to 3 previous errors diff --git a/src/test/ui/error-codes/E0277-3.rs b/src/test/ui/error-codes/E0277-3.rs new file mode 100644 index 0000000000000..428be79617d7f --- /dev/null +++ b/src/test/ui/error-codes/E0277-3.rs @@ -0,0 +1,8 @@ +fn foo(_: T) {} + +struct S; + +fn main() { + foo(S); + //~^ ERROR can't compare `S` with `S` +} diff --git a/src/test/ui/error-codes/E0277-3.stderr b/src/test/ui/error-codes/E0277-3.stderr new file mode 100644 index 0000000000000..0127e1ccc81ec --- /dev/null +++ b/src/test/ui/error-codes/E0277-3.stderr @@ -0,0 +1,22 @@ +error[E0277]: can't compare `S` with `S` + --> $DIR/E0277-3.rs:6:9 + | +LL | foo(S); + | --- ^ no implementation for `S == S` + | | + | required by a bound introduced by this call + | + = help: the trait `PartialEq` is not implemented for `S` +note: required by a bound in `foo` + --> $DIR/E0277-3.rs:1:11 + | +LL | fn foo(_: T) {} + | ^^^^^^^^^ required by this bound in `foo` +help: consider annotating `S` with `#[derive(PartialEq)]` + | +LL | #[derive(PartialEq)] + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr index e5db2f1b7c35b..c6fa02cb9a6b4 100644 --- a/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr +++ b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr @@ -10,6 +10,10 @@ note: required by a bound in `Family2::Member` | LL | type Member<'a>: for<'b> PartialEq> = Foo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family2::Member` +help: consider annotating `Foo` with `#[derive(PartialEq)]` + | +LL | #[derive(PartialEq)] + | error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-87429-specialization.stderr b/src/test/ui/generic-associated-types/issue-87429-specialization.stderr index ca44ecfdb537d..015e0c7792fec 100644 --- a/src/test/ui/generic-associated-types/issue-87429-specialization.stderr +++ b/src/test/ui/generic-associated-types/issue-87429-specialization.stderr @@ -20,6 +20,10 @@ note: required by a bound in `Family::Member` | LL | type Member<'a>: for<'b> PartialEq>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family::Member` +help: consider annotating `Foo` with `#[derive(PartialEq)]` + | +LL | #[derive(PartialEq)] + | error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/issues/issue-20162.stderr b/src/test/ui/issues/issue-20162.stderr index 6848c3f0d8a54..d70bf6e1d921c 100644 --- a/src/test/ui/issues/issue-20162.stderr +++ b/src/test/ui/issues/issue-20162.stderr @@ -9,6 +9,10 @@ note: required by a bound in `slice::::sort` | LL | T: Ord, | ^^^ required by this bound in `slice::::sort` +help: consider annotating `X` with `#[derive(Ord)]` + | +LL | #[derive(Ord)] + | error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21160.stderr b/src/test/ui/issues/issue-21160.stderr index 300c1272ef6c0..266749376eb05 100644 --- a/src/test/ui/issues/issue-21160.stderr +++ b/src/test/ui/issues/issue-21160.stderr @@ -7,6 +7,10 @@ LL | struct Foo(Bar); | ^^^ the trait `Hash` is not implemented for `Bar` | = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Bar` with `#[derive(Hash)]` + | +LL | #[derive(Hash)] + | error: aborting due to previous error diff --git a/src/test/ui/issues/issue-34229.stderr b/src/test/ui/issues/issue-34229.stderr index 71e02f2fd86cc..69ef876d25502 100644 --- a/src/test/ui/issues/issue-34229.stderr +++ b/src/test/ui/issues/issue-34229.stderr @@ -8,6 +8,10 @@ LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); | = help: the trait `PartialOrd` is not implemented for `Comparable` = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Comparable` with `#[derive(PartialOrd)]` + | +LL | #[derive(PartialEq)] #[derive(PartialOrd)] + | +++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index e147366a22410..f909eb6b14eaf 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -129,6 +129,10 @@ note: required by a bound in `assert_copy` | LL | fn assert_copy() { } | ^^^^ required by this bound in `assert_copy` +help: consider annotating `MyNoncopyStruct` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error[E0277]: the trait bound `Rc: Copy` is not satisfied --> $DIR/kindck-copy.rs:67:19 diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.stderr index 3558f0c9e6294..22e0988ebd408 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.stderr @@ -99,6 +99,10 @@ note: required because of the requirements on the impl of `Gettable` for `S LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` +help: consider annotating `Foo` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to 7 previous errors diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr index 0ddce1be476c3..803883460f08f 100644 --- a/src/test/ui/malformed/malformed-derive-entry.stderr +++ b/src/test/ui/malformed/malformed-derive-entry.stderr @@ -28,6 +28,10 @@ note: required by a bound in `Copy` LL | pub trait Copy: Clone { | ^^^^^ required by this bound in `Copy` = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Test1` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error[E0277]: the trait bound `Test2: Clone` is not satisfied --> $DIR/malformed-derive-entry.rs:6:10 @@ -41,6 +45,10 @@ note: required by a bound in `Copy` LL | pub trait Copy: Clone { | ^^^^^ required by this bound in `Copy` = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Test2` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr index dc73bcd6e4d05..c2515c40b1d77 100644 --- a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr +++ b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr @@ -11,6 +11,10 @@ note: required by a bound in `Result::::unwrap` | LL | E: fmt::Debug, | ^^^^^^^^^^ required by this bound in `Result::::unwrap` +help: consider annotating `Foo` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error: aborting due to previous error diff --git a/src/test/ui/not-clone-closure.stderr b/src/test/ui/not-clone-closure.stderr index a62c21f2ee971..92909797c9679 100644 --- a/src/test/ui/not-clone-closure.stderr +++ b/src/test/ui/not-clone-closure.stderr @@ -11,6 +11,10 @@ LL | let hello = hello.clone(); | ^^^^^ within `[closure@$DIR/not-clone-closure.rs:7:17: 9:6]`, the trait `Clone` is not implemented for `S` | = note: required because it appears within the type `[closure@$DIR/not-clone-closure.rs:7:17: 9:6]` +help: consider annotating `S` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/no-debug.stderr b/src/test/ui/on-unimplemented/no-debug.stderr index b17c1d4c25208..417e01e491b47 100644 --- a/src/test/ui/on-unimplemented/no-debug.stderr +++ b/src/test/ui/on-unimplemented/no-debug.stderr @@ -7,6 +7,10 @@ LL | println!("{:?} {:?}", Foo, Bar); = help: the trait `Debug` is not implemented for `Foo` = note: add `#[derive(Debug)]` to `Foo` or manually `impl Debug for Foo` = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Foo` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error[E0277]: `Bar` doesn't implement `Debug` --> $DIR/no-debug.rs:10:32 diff --git a/src/test/ui/repeat-to-run-dtor-twice.stderr b/src/test/ui/repeat-to-run-dtor-twice.stderr index f07bbe3b9f3f6..904413712cde1 100644 --- a/src/test/ui/repeat-to-run-dtor-twice.stderr +++ b/src/test/ui/repeat-to-run-dtor-twice.stderr @@ -5,6 +5,10 @@ LL | let _ = [ a; 5 ]; | ^^^^^^^^ the trait `Copy` is not implemented for `Foo` | = note: the `Copy` trait is required because the repeated element will be copied +help: consider annotating `Foo` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to previous error diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index 3cdab6541e7d1..ea1f66d78a378 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -7,6 +7,10 @@ LL | let _: NotDebug = dbg!(NotDebug); = help: the trait `Debug` is not implemented for `NotDebug` = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `NotDebug` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr index b0af45acda1ed..0a2a5f0f24578 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr @@ -17,6 +17,10 @@ note: required by a bound in `equals_self` | LL | const fn equals_self(t: &T) -> bool { | ^^^^^^^^^^^^^^^^ required by this bound in `equals_self` +help: consider annotating `S` with `#[derive(PartialEq)]` + | +LL | #[derive(PartialEq)] + | error: aborting due to previous error diff --git a/src/test/ui/specialization/issue-59435.stderr b/src/test/ui/specialization/issue-59435.stderr index bb5d90f001ee7..2114594066861 100644 --- a/src/test/ui/specialization/issue-59435.stderr +++ b/src/test/ui/specialization/issue-59435.stderr @@ -9,6 +9,10 @@ note: required by a bound in `MyTrait::MyType` | LL | type MyType: Default; | ^^^^^^^ required by this bound in `MyTrait::MyType` +help: consider annotating `MyStruct` with `#[derive(Default)]` + | +LL | #[derive(Default)] + | error: aborting due to previous error diff --git a/src/test/ui/structs/struct-path-alias-bounds.stderr b/src/test/ui/structs/struct-path-alias-bounds.stderr index 7a80e7270ba36..266291f62b45d 100644 --- a/src/test/ui/structs/struct-path-alias-bounds.stderr +++ b/src/test/ui/structs/struct-path-alias-bounds.stderr @@ -9,6 +9,10 @@ note: required by a bound in `S` | LL | struct S { a: T } | ^^^^^ required by this bound in `S` +help: consider annotating `NoClone` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/suggestions/derive-macro-missing-bounds.stderr b/src/test/ui/suggestions/derive-macro-missing-bounds.stderr index 7a4f7e209c195..75658f58c8a1b 100644 --- a/src/test/ui/suggestions/derive-macro-missing-bounds.stderr +++ b/src/test/ui/suggestions/derive-macro-missing-bounds.stderr @@ -9,6 +9,10 @@ LL | struct Outer(Inner); = help: the trait `Debug` is not implemented for `a::Inner` = note: add `#[derive(Debug)]` to `a::Inner` or manually `impl Debug for a::Inner` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `a::Inner` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement | LL | struct Outer(Inner) where a::Inner: Debug; diff --git a/src/test/ui/suggestions/issue-84973-blacklist.stderr b/src/test/ui/suggestions/issue-84973-blacklist.stderr index ae55c96702ada..5d8d688a073ca 100644 --- a/src/test/ui/suggestions/issue-84973-blacklist.stderr +++ b/src/test/ui/suggestions/issue-84973-blacklist.stderr @@ -25,6 +25,10 @@ note: required by a bound in `f_clone` | LL | fn f_clone(t: T) {} | ^^^^^ required by this bound in `f_clone` +help: consider annotating `S` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error[E0277]: `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:33]` cannot be unpinned --> $DIR/issue-84973-blacklist.rs:17:5 diff --git a/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr index 9ceeea4872fbb..d7697dcc6405b 100644 --- a/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr +++ b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr @@ -24,6 +24,10 @@ note: required by a bound in `copy` | LL | fn copy(x: T) -> (T, T) { (x, x) } | ^^^^^ required by this bound in `copy` +help: consider annotating `NoClone` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/issue-71136.stderr b/src/test/ui/traits/issue-71136.stderr index 45b1e1095c7d8..62a2a64ed142c 100644 --- a/src/test/ui/traits/issue-71136.stderr +++ b/src/test/ui/traits/issue-71136.stderr @@ -9,6 +9,10 @@ LL | the_foos: Vec, | = note: required because of the requirements on the impl of `Clone` for `Vec` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Foo` with `#[derive(Clone)]` + | +LL | #[derive(Clone)] + | error: aborting due to previous error diff --git a/src/test/ui/union/union-derive-clone.mirunsafeck.stderr b/src/test/ui/union/union-derive-clone.mirunsafeck.stderr index de0bc7830b73a..c242a7de7abfb 100644 --- a/src/test/ui/union/union-derive-clone.mirunsafeck.stderr +++ b/src/test/ui/union/union-derive-clone.mirunsafeck.stderr @@ -38,6 +38,10 @@ note: required by a bound in `AssertParamIsCopy` LL | pub struct AssertParamIsCopy { | ^^^^ required by this bound in `AssertParamIsCopy` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `U1` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to 2 previous errors diff --git a/src/test/ui/union/union-derive-clone.thirunsafeck.stderr b/src/test/ui/union/union-derive-clone.thirunsafeck.stderr index de0bc7830b73a..c242a7de7abfb 100644 --- a/src/test/ui/union/union-derive-clone.thirunsafeck.stderr +++ b/src/test/ui/union/union-derive-clone.thirunsafeck.stderr @@ -38,6 +38,10 @@ note: required by a bound in `AssertParamIsCopy` LL | pub struct AssertParamIsCopy { | ^^^^ required by this bound in `AssertParamIsCopy` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `U1` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to 2 previous errors diff --git a/src/test/ui/union/union-derive-eq.mirunsafeck.stderr b/src/test/ui/union/union-derive-eq.mirunsafeck.stderr index ff4dfcd291760..99505f3163968 100644 --- a/src/test/ui/union/union-derive-eq.mirunsafeck.stderr +++ b/src/test/ui/union/union-derive-eq.mirunsafeck.stderr @@ -13,6 +13,10 @@ note: required by a bound in `AssertParamIsEq` LL | pub struct AssertParamIsEq { | ^^ required by this bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/union/union-derive-eq.thirunsafeck.stderr b/src/test/ui/union/union-derive-eq.thirunsafeck.stderr index ff4dfcd291760..99505f3163968 100644 --- a/src/test/ui/union/union-derive-eq.thirunsafeck.stderr +++ b/src/test/ui/union/union-derive-eq.thirunsafeck.stderr @@ -13,6 +13,10 @@ note: required by a bound in `AssertParamIsEq` LL | pub struct AssertParamIsEq { | ^^ required by this bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/wf/wf-const-type.stderr b/src/test/ui/wf/wf-const-type.stderr index 5a6d66ee7fa7c..e47920d3dfcf8 100644 --- a/src/test/ui/wf/wf-const-type.stderr +++ b/src/test/ui/wf/wf-const-type.stderr @@ -10,6 +10,10 @@ note: required by a bound in `IsCopy` | LL | struct IsCopy { t: T } | ^^^^ required by this bound in `IsCopy` +help: consider annotating `NotCopy` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to previous error diff --git a/src/test/ui/wf/wf-static-type.stderr b/src/test/ui/wf/wf-static-type.stderr index c45bd5777620c..4ae69cf2e1ff8 100644 --- a/src/test/ui/wf/wf-static-type.stderr +++ b/src/test/ui/wf/wf-static-type.stderr @@ -10,6 +10,10 @@ note: required by a bound in `IsCopy` | LL | struct IsCopy { t: T } | ^^^^ required by this bound in `IsCopy` +help: consider annotating `NotCopy` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to previous error diff --git a/src/test/ui/where-clauses/where-clauses-method-unsatisfied.stderr b/src/test/ui/where-clauses/where-clauses-method-unsatisfied.stderr index 3a4cbb62d5597..c13552bc26eee 100644 --- a/src/test/ui/where-clauses/where-clauses-method-unsatisfied.stderr +++ b/src/test/ui/where-clauses/where-clauses-method-unsatisfied.stderr @@ -11,6 +11,10 @@ note: required by a bound in `Foo::::equals` | LL | fn equals(&self, u: &Foo) -> bool where T : Eq { | ^^ required by this bound in `Foo::::equals` +help: consider annotating `Bar` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error diff --git a/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr b/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr index ba18119ff1b4f..b1805a4522f4d 100644 --- a/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr +++ b/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr @@ -9,6 +9,10 @@ note: required by a bound in `equal` | LL | fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } | ^^ required by this bound in `equal` +help: consider annotating `Struct` with `#[derive(Eq)]` + | +LL | #[derive(Eq)] + | error: aborting due to previous error From 0ff2f58330a590fcc967b890731d2ebedf6ecb0c Mon Sep 17 00:00:00 2001 From: ohno418 Date: Fri, 1 Apr 2022 11:28:28 +0900 Subject: [PATCH 5/9] Suggest only when Rhs for PartialEq and PartialOrd is the same type as self --- .../src/traits/error_reporting/suggestions.rs | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 4db6ff0875442..64fb352ac4561 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2593,35 +2593,37 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } fn suggest_derive(&self, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>) { - if let Some(diagnostic_name) = self.tcx.get_diagnostic_name(trait_pred.def_id()) { - let adt = match trait_pred.skip_binder().self_ty().ty_adt_def() { - Some(adt) if adt.did().is_local() => adt, - _ => return, - }; - let can_derive = match diagnostic_name { - sym::Default => !adt.is_enum(), - sym::Eq - | sym::PartialEq - | sym::Ord - | sym::PartialOrd - | sym::Clone - | sym::Copy - | sym::Hash - | sym::Debug => true, - _ => false, - }; - if can_derive { - err.span_suggestion_verbose( - self.tcx.def_span(adt.did()).shrink_to_lo(), - &format!( - "consider annotating `{}` with `#[derive({})]`", - trait_pred.skip_binder().self_ty().to_string(), - diagnostic_name.to_string(), - ), - format!("#[derive({})]\n", diagnostic_name.to_string()), - Applicability::MaybeIncorrect, - ); - } + let Some(diagnostic_name) = self.tcx.get_diagnostic_name(trait_pred.def_id()) else { + return; + }; + let Some(self_ty) = trait_pred.self_ty().no_bound_vars() else { + return; + }; + + let adt = match self_ty.ty_adt_def() { + Some(adt) if adt.did().is_local() => adt, + _ => return, + }; + let can_derive = match diagnostic_name { + sym::Default => !adt.is_enum(), + sym::PartialEq | sym::PartialOrd => { + let rhs_ty = trait_pred.skip_binder().trait_ref.substs.type_at(1); + self_ty == rhs_ty + } + sym::Eq | sym::Ord | sym::Clone | sym::Copy | sym::Hash | sym::Debug => true, + _ => false, + }; + if can_derive { + err.span_suggestion_verbose( + self.tcx.def_span(adt.did()).shrink_to_lo(), + &format!( + "consider annotating `{}` with `#[derive({})]`", + trait_pred.skip_binder().self_ty().to_string(), + diagnostic_name.to_string(), + ), + format!("#[derive({})]\n", diagnostic_name.to_string()), + Applicability::MaybeIncorrect, + ); } } } From de237823e01347a48819d34fe8e0cf130e3e54cb Mon Sep 17 00:00:00 2001 From: ohno418 Date: Mon, 4 Apr 2022 00:08:54 +0900 Subject: [PATCH 6/9] Suggest only when all fields impl the trait --- .../src/traits/error_reporting/mod.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 66 ++++++++++++++----- .../ui/consts/const-blocks/trait-error.stderr | 4 -- src/test/ui/kindck/kindck-copy.stderr | 4 -- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index e196362de7afd..0f5f4f3c60f25 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -536,7 +536,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ); self.note_version_mismatch(&mut err, &trait_ref); self.suggest_remove_await(&obligation, &mut err); - self.suggest_derive(&mut err, trait_predicate); + self.suggest_derive(&obligation, &mut err, trait_predicate); if Some(trait_ref.def_id()) == tcx.lang_items().try_trait() { self.suggest_await_before_try( diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 64fb352ac4561..c2193bbeec49e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -190,7 +190,12 @@ pub trait InferCtxtExt<'tcx> { trait_ref: &ty::PolyTraitRef<'tcx>, ); - fn suggest_derive(&self, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>); + fn suggest_derive( + &self, + obligation: &PredicateObligation<'tcx>, + err: &mut Diagnostic, + trait_pred: ty::PolyTraitPredicate<'tcx>, + ); } fn predicate_constraint(generics: &hir::Generics<'_>, pred: String) -> (Span, String) { @@ -2592,33 +2597,60 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } } - fn suggest_derive(&self, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>) { + fn suggest_derive( + &self, + obligation: &PredicateObligation<'tcx>, + err: &mut Diagnostic, + trait_pred: ty::PolyTraitPredicate<'tcx>, + ) { let Some(diagnostic_name) = self.tcx.get_diagnostic_name(trait_pred.def_id()) else { return; }; - let Some(self_ty) = trait_pred.self_ty().no_bound_vars() else { - return; - }; - - let adt = match self_ty.ty_adt_def() { - Some(adt) if adt.did().is_local() => adt, + let (adt, substs) = match trait_pred.skip_binder().self_ty().kind() { + ty::Adt(adt, substs) if adt.did().is_local() => (adt, substs), _ => return, }; - let can_derive = match diagnostic_name { - sym::Default => !adt.is_enum(), - sym::PartialEq | sym::PartialOrd => { - let rhs_ty = trait_pred.skip_binder().trait_ref.substs.type_at(1); - self_ty == rhs_ty - } - sym::Eq | sym::Ord | sym::Clone | sym::Copy | sym::Hash | sym::Debug => true, - _ => false, + let can_derive = { + let is_derivable_trait = match diagnostic_name { + sym::Default => !adt.is_enum(), + sym::PartialEq | sym::PartialOrd => { + let rhs_ty = trait_pred.skip_binder().trait_ref.substs.type_at(1); + trait_pred.skip_binder().self_ty() == rhs_ty + } + sym::Eq | sym::Ord | sym::Clone | sym::Copy | sym::Hash | sym::Debug => true, + _ => false, + }; + is_derivable_trait && + // Ensure all fields impl the trait. + adt.all_fields().all(|field| { + let field_ty = field.ty(self.tcx, substs); + let trait_substs = match diagnostic_name { + sym::PartialEq | sym::PartialOrd => { + self.tcx.mk_substs_trait(field_ty, &[field_ty.into()]) + } + _ => self.tcx.mk_substs_trait(field_ty, &[]), + }; + let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate { + trait_ref: ty::TraitRef { + substs: trait_substs, + ..trait_pred.skip_binder().trait_ref + }, + ..*tr + }); + let field_obl = Obligation::new( + obligation.cause.clone(), + obligation.param_env, + trait_pred.to_predicate(self.tcx), + ); + self.predicate_must_hold_modulo_regions(&field_obl) + }) }; if can_derive { err.span_suggestion_verbose( self.tcx.def_span(adt.did()).shrink_to_lo(), &format!( "consider annotating `{}` with `#[derive({})]`", - trait_pred.skip_binder().self_ty().to_string(), + trait_pred.skip_binder().self_ty(), diagnostic_name.to_string(), ), format!("#[derive({})]\n", diagnostic_name.to_string()), diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr index b6afbe1b532fd..26e2848e7f7a1 100644 --- a/src/test/ui/consts/const-blocks/trait-error.stderr +++ b/src/test/ui/consts/const-blocks/trait-error.stderr @@ -7,10 +7,6 @@ LL | [Foo(String::new()); 4]; = help: the following implementations were found: as Copy> = note: the `Copy` trait is required because the repeated element will be copied -help: consider annotating `Foo` with `#[derive(Copy)]` - | -LL | #[derive(Copy)] - | error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index f909eb6b14eaf..e147366a22410 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -129,10 +129,6 @@ note: required by a bound in `assert_copy` | LL | fn assert_copy() { } | ^^^^ required by this bound in `assert_copy` -help: consider annotating `MyNoncopyStruct` with `#[derive(Copy)]` - | -LL | #[derive(Copy)] - | error[E0277]: the trait bound `Rc: Copy` is not satisfied --> $DIR/kindck-copy.rs:67:19 From b831b60cefabafa78ea9da173c2ce9c0321a29c7 Mon Sep 17 00:00:00 2001 From: ohno418 Date: Tue, 5 Apr 2022 17:25:38 +0900 Subject: [PATCH 7/9] Fix ui test for nll --- src/test/ui/kindck/kindck-impl-type-params.nll.stderr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index 7129bad8a978a..84e02a24964ef 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -91,6 +91,10 @@ note: required because of the requirements on the impl of `Gettable` for `S LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` +help: consider annotating `Foo` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to 6 previous errors From 975980427bd4b533e4116a8211598fff73780ab0 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:33:22 +0900 Subject: [PATCH 8/9] remove unused function parameters --- .../src/diagnostics/conflict_errors.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 883f711b201a9..7045ef517156b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -772,14 +772,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Some((issued_span, span)), ); - self.suggest_using_local_if_applicable( - &mut err, - location, - (place, span), - gen_borrow_kind, - issued_borrow, - explanation, - ); + self.suggest_using_local_if_applicable(&mut err, location, issued_borrow, explanation); err } @@ -789,8 +782,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &self, err: &mut Diagnostic, location: Location, - (place, span): (Place<'tcx>, Span), - gen_borrow_kind: BorrowKind, issued_borrow: &BorrowData<'tcx>, explanation: BorrowExplanation, ) { @@ -822,7 +813,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { return; }; let inner_param_uses = find_all_local_uses::find(self.body, inner_param.local); - let Some((inner_call_loc,inner_call_term)) = inner_param_uses.into_iter().find_map(|loc| { + let Some((inner_call_loc, inner_call_term)) = inner_param_uses.into_iter().find_map(|loc| { let Either::Right(term) = self.body.stmt_at(loc) else { debug!("{:?} is a statement, so it can't be a call", loc); return None; @@ -833,7 +824,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }; debug!("checking call args for uses of inner_param: {:?}", args); if args.contains(&Operand::Move(inner_param)) { - Some((loc,term)) + Some((loc, term)) } else { None } From 505573e38e4fca72372023c20c1847e01b4bb67e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 5 Apr 2022 14:18:10 +0300 Subject: [PATCH 9/9] :arrow_up: rust-analyzer --- src/tools/rust-analyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index bc08b8eff3f8e..46d7ee68f2628 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit bc08b8eff3f8e4da7c448d7b7f6461938c817a60 +Subproject commit 46d7ee68f26285db26b2640f2c07d6332380c756