From 6ece80fcb672ee3053ccf4fafed62e7307b56a66 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 4 Apr 2022 12:16:20 -0700 Subject: [PATCH] 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`