diff --git a/.github/ISSUE_TEMPLATE/tracking_issue.md b/.github/ISSUE_TEMPLATE/tracking_issue.md index aedc15a54c274..6def803b269e9 100644 --- a/.github/ISSUE_TEMPLATE/tracking_issue.md +++ b/.github/ISSUE_TEMPLATE/tracking_issue.md @@ -50,7 +50,7 @@ for larger features an implementation could be broken up into multiple PRs. [stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr [doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs [nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/main/nightly-style-procedure.md -[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide +[Style Guide]: https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide ### Unresolved Questions const-super-trait.rs:3:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 6 previous errors diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr index 821ab6fa57cd0..d0e7edf42cdd5 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr @@ -38,7 +38,19 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> const-super-trait.rs:3:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 4 previous errors diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr index b39be78e4384c..e8b5c09699202 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr @@ -56,6 +56,14 @@ error[E0015]: cannot call non-const method `::a` in constant functions 10 | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> const-super-trait.rs:3:1 + | + 3 | trait Foo { + | ^^^^^^^^^ this trait is not const + 4 | fn a(&self); + | ------------ this method is not const + = help: const traits are not yet supported on stable Rust = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 6 previous errors diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr index 30ee5cf6f4b0c..263532f3a9400 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr @@ -46,6 +46,14 @@ error[E0015]: cannot call non-const method `::a` in constant functions 10 | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> const-super-trait.rs:3:1 + | + 3 | trait Foo { + | ^^^^^^^^^ this trait is not const + 4 | fn a(&self); + | ------------ this method is not const + = help: const traits are not yet supported on stable Rust = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 5 previous errors diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr index eac4fe841bffd..d7a901ba20ee5 100644 --- a/tests/ui/asm/non-const.stderr +++ b/tests/ui/asm/non-const.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `non_const_fn` in constants LL | global_asm!("/* {} */", const non_const_fn(0)); | ^^^^^^^^^^^^^^^ | +note: function `non_const_fn` is not const + --> $DIR/non-const.rs:8:1 + | +LL | fn non_const_fn(x: i32) -> i32 { x } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index 8ec9a10f09f4d..29a7363705cd7 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -4,6 +4,8 @@ error[E0015]: cannot call non-const function `format` in statics LL | static settings_dir: String = format!(""); | ^^^^^^^^^^^ | +note: function `format` is not const + --> $SRC_DIR/alloc/src/fmt.rs:LL:COL = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/const-generics/early/const-param-from-outer-fn.stderr b/tests/ui/const-generics/early/const-param-from-outer-fn.stderr index faba4ce10a1b4..3c25dff41aa22 100644 --- a/tests/ui/const-generics/early/const-param-from-outer-fn.stderr +++ b/tests/ui/const-generics/early/const-param-from-outer-fn.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo() { | - const parameter from outer item LL | fn bar() -> u32 { - | - help: try introducing a local generic parameter here: `` + | --- generic parameter used in this inner function LL | X | ^ use of generic parameter from outer item + | +help: try introducing a local generic parameter here + | +LL | fn bar() -> u32 { + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-call.stderr b/tests/ui/consts/const-call.stderr index b9dcf5addb519..cc80f73d0bb61 100644 --- a/tests/ui/consts/const-call.stderr +++ b/tests/ui/consts/const-call.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `f` in constants LL | let _ = [0; f(2)]; | ^^^^ | +note: function `f` is not const + --> $DIR/const-call.rs:1:1 + | +LL | fn f(x: usize) -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index bd50ac0bf4116..ea191eb5c0989 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -21,6 +21,8 @@ error[E0015]: cannot call non-const function `_print` in constant functions LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | +note: function `_print` is not const + --> $SRC_DIR/std/src/io/stdio.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr index 1fa881cf42b6a..ac0d344d8f480 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `regular_in_block` in constant func LL | regular_in_block(); | ^^^^^^^^^^^^^^^^^^ | +note: function `regular_in_block` is not const + --> $DIR/const-extern-fn-call-extern-fn.rs:2:5 + | +LL | fn regular_in_block(); + | ^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const function `regular` in constant functions @@ -12,6 +17,11 @@ error[E0015]: cannot call non-const function `regular` in constant functions LL | regular(); | ^^^^^^^^^ | +note: function `regular` is not const + --> $DIR/const-extern-fn-call-extern-fn.rs:12:1 + | +LL | extern "C" fn regular() {} + | ^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-fn-not-safe-for-const.stderr b/tests/ui/consts/const-fn-not-safe-for-const.stderr index e8f0566e73dd8..8fd27df5367e0 100644 --- a/tests/ui/consts/const-fn-not-safe-for-const.stderr +++ b/tests/ui/consts/const-fn-not-safe-for-const.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `random` in constant functions LL | random() | ^^^^^^^^ | +note: function `random` is not const + --> $DIR/const-fn-not-safe-for-const.rs:5:1 + | +LL | fn random() -> u32 { + | ^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr index 62a1677c0d930..b991b6af08cc1 100644 --- a/tests/ui/consts/const_cmp_type_id.stderr +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -3,6 +3,9 @@ error[E0277]: the trait bound `TypeId: const PartialOrd` is not satisfied | LL | let _a = TypeId::of::() < TypeId::of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: trait `PartialOrd` is implemented but not `const` + --> $SRC_DIR/core/src/any.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/control-flow/issue-46843.stderr b/tests/ui/consts/control-flow/issue-46843.stderr index 42eb035647c0e..46b2a6bf1fd36 100644 --- a/tests/ui/consts/control-flow/issue-46843.stderr +++ b/tests/ui/consts/control-flow/issue-46843.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `non_const` in constants LL | pub const Q: i32 = match non_const() { | ^^^^^^^^^^^ | +note: function `non_const` is not const + --> $DIR/issue-46843.rs:6:1 + | +LL | fn non_const() -> Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-16538.stderr b/tests/ui/consts/issue-16538.stderr index 8bd11541a7dff..fd97b4360a468 100644 --- a/tests/ui/consts/issue-16538.stderr +++ b/tests/ui/consts/issue-16538.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `Y::foo` in statics LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | +note: function `foo` is not const + --> $DIR/issue-16538.rs:6:5 + | +LL | pub fn foo(value: *const X) -> *const X { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/consts/issue-32829-2.stderr b/tests/ui/consts/issue-32829-2.stderr index eedd9d34e550e..b201454866ed5 100644 --- a/tests/ui/consts/issue-32829-2.stderr +++ b/tests/ui/consts/issue-32829-2.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `invalid` in constants LL | invalid(); | ^^^^^^^^^ | +note: function `invalid` is not const + --> $DIR/issue-32829-2.rs:68:1 + | +LL | fn invalid() {} + | ^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const function `invalid` in statics @@ -12,6 +17,11 @@ error[E0015]: cannot call non-const function `invalid` in statics LL | invalid(); | ^^^^^^^^^ | +note: function `invalid` is not const + --> $DIR/issue-32829-2.rs:68:1 + | +LL | fn invalid() {} + | ^^^^^^^^^^^^ = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` @@ -21,6 +31,11 @@ error[E0015]: cannot call non-const function `invalid` in statics LL | invalid(); | ^^^^^^^^^ | +note: function `invalid` is not const + --> $DIR/issue-32829-2.rs:68:1 + | +LL | fn invalid() {} + | ^^^^^^^^^^^^ = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/consts/issue-43105.stderr b/tests/ui/consts/issue-43105.stderr index c030c0f5fcdec..7ec0a2b73afc5 100644 --- a/tests/ui/consts/issue-43105.stderr +++ b/tests/ui/consts/issue-43105.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `xyz` in constants LL | const NUM: u8 = xyz(); | ^^^^^ | +note: function `xyz` is not const + --> $DIR/issue-43105.rs:1:1 + | +LL | fn xyz() -> u8 { 42 } + | ^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/mir_check_nonconst.stderr b/tests/ui/consts/mir_check_nonconst.stderr index e930fa2103d5d..bb0940ee789b9 100644 --- a/tests/ui/consts/mir_check_nonconst.stderr +++ b/tests/ui/consts/mir_check_nonconst.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `bar` in statics LL | static foo: Foo = bar(); | ^^^^^ | +note: function `bar` is not const + --> $DIR/mir_check_nonconst.rs:4:1 + | +LL | fn bar() -> Foo { + | ^^^^^^^^^^^^^^^ = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index f5556bf9f4514..edd1a584eab26 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -4,7 +4,7 @@ error[E0401]: can't use generic parameters from outer item LL | fn bar(_: T) { | - type parameter from outer item LL | reuse Trait::static_method { - | - help: try introducing a local generic parameter here: `T,` + | ------------- generic parameter used in this inner delegated function LL | LL | let _ = T::Default(); | ^^^^^^^^^^ use of generic parameter from outer item diff --git a/tests/ui/error-codes/E0015.stderr b/tests/ui/error-codes/E0015.stderr index 0c983d2843492..bc457aefaecb0 100644 --- a/tests/ui/error-codes/E0015.stderr +++ b/tests/ui/error-codes/E0015.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `create_some` in constants LL | const FOO: Option = create_some(); | ^^^^^^^^^^^^^ | +note: function `create_some` is not const + --> $DIR/E0015.rs:1:1 + | +LL | fn create_some() -> Option { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0401.stderr b/tests/ui/error-codes/E0401.stderr index 5d6878620c89a..8daaf09df1592 100644 --- a/tests/ui/error-codes/E0401.stderr +++ b/tests/ui/error-codes/E0401.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo(x: T) { | - type parameter from outer item LL | fn bfnr, W: Fn()>(y: T) { - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `T,` + | ---- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn bfnr, W: Fn()>(y: T) { + | ++ error[E0401]: can't use generic parameters from outer item --> $DIR/E0401.rs:9:16 @@ -15,10 +20,15 @@ LL | fn foo(x: T) { | - type parameter from outer item ... LL | fn baz $DIR/E0401.rs:22:25 @@ -27,10 +37,11 @@ LL | impl Iterator for A { | ---- `Self` type implicitly declared here, by this `impl` ... LL | fn helper(sel: &Self) -> u8 { - | ^^^^ - | | - | use of `Self` from outer item - | refer to the type directly here instead + | ------ ^^^^ + | | | + | | use of `Self` from outer item + | | refer to the type directly here instead + | `Self` used in this inner function error: aborting due to 3 previous errors diff --git a/tests/ui/explicit-tail-calls/become-cast-return.rs b/tests/ui/explicit-tail-calls/become-cast-return.rs new file mode 100644 index 0000000000000..d4cdcbf3a0112 --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-cast-return.rs @@ -0,0 +1,22 @@ +//@ run-pass +//@ ignore-backends: gcc +//@ ignore-wasm 'tail-call' feature not enabled in target wasm32-wasip1 +//@ ignore-cross-compile +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +#[inline(never)] +fn leaf(_: &Box) -> [u8; 1] { + [1] +} + +#[inline(never)] +fn dispatch(param: &Box) -> [u8; 1] { + become leaf(param) +} + +fn main() { + let data = Box::new(0); + let out = dispatch(&data); + assert_eq!(out, [1]); +} diff --git a/tests/ui/explicit-tail-calls/become-indirect-return.rs b/tests/ui/explicit-tail-calls/become-indirect-return.rs new file mode 100644 index 0000000000000..b1e552bca0293 --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-indirect-return.rs @@ -0,0 +1,22 @@ +//@ run-pass +//@ ignore-backends: gcc +//@ ignore-wasm 'tail-call' feature not enabled in target wasm32-wasip1 +//@ ignore-cross-compile +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +#[inline(never)] +fn op_dummy(_param: &Box) -> [u8; 24] { + [1; 24] +} + +#[inline(never)] +fn dispatch(param: &Box) -> [u8; 24] { + become op_dummy(param) +} + +fn main() { + let param = Box::new(0); + let result = dispatch(¶m); + assert_eq!(result, [1; 24]); +} diff --git a/tests/ui/explicit-tail-calls/constck.stderr b/tests/ui/explicit-tail-calls/constck.stderr index c223d273b383f..2fc2fb7f9338b 100644 --- a/tests/ui/explicit-tail-calls/constck.stderr +++ b/tests/ui/explicit-tail-calls/constck.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `not_const` in constant functions LL | become not_const(); | ^^^^^^^^^^^ | +note: function `not_const` is not const + --> $DIR/constck.rs:18:1 + | +LL | fn not_const() {} + | ^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const function `not_const` in constant functions @@ -12,6 +17,11 @@ error[E0015]: cannot call non-const function `not_const` in constant functions LL | become yes_const(not_const()); | ^^^^^^^^^^^ | +note: function `not_const` is not const + --> $DIR/constck.rs:18:1 + | +LL | fn not_const() {} + | ^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors diff --git a/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr index aea0f049b07d3..fb2d2f247b65b 100644 --- a/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr +++ b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn f() -> bool { | - type parameter from outer item LL | enum E { V(Z) } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | - ^ use of generic parameter from outer item + | | + | generic parameter used in this inner enum + | +help: try introducing a local generic parameter here + | +LL | enum E { V(Z) } + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/generics/generic-params-nested-fn-scope-error.stderr b/tests/ui/generics/generic-params-nested-fn-scope-error.stderr index 7fd1069c651fa..f809740ed381f 100644 --- a/tests/ui/generics/generic-params-nested-fn-scope-error.stderr +++ b/tests/ui/generics/generic-params-nested-fn-scope-error.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo(v: Vec) -> U { | - type parameter from outer item LL | fn bar(w: [U]) -> U { - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn bar(w: [U]) -> U { + | +++ error[E0401]: can't use generic parameters from outer item --> $DIR/generic-params-nested-fn-scope-error.rs:5:23 @@ -14,9 +19,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo(v: Vec) -> U { | - type parameter from outer item LL | fn bar(w: [U]) -> U { - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn bar(w: [U]) -> U { + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/generics/issue-98432.stderr b/tests/ui/generics/issue-98432.stderr index 2b09d43960f62..a1efee78cb7df 100644 --- a/tests/ui/generics/issue-98432.stderr +++ b/tests/ui/generics/issue-98432.stderr @@ -5,9 +5,14 @@ LL | impl Struct { | - type parameter from outer item LL | const CONST: fn() = || { LL | struct _Obligation where T:; - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | ----------- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner struct + | +help: try introducing a local generic parameter here + | +LL | struct _Obligation where T:; + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/generics/missing-param-but-has-colon-144215.rs b/tests/ui/generics/missing-param-but-has-colon-144215.rs new file mode 100644 index 0000000000000..31a9dd49e5c65 --- /dev/null +++ b/tests/ui/generics/missing-param-but-has-colon-144215.rs @@ -0,0 +1,9 @@ +//! Regression test for + +#[rustfmt::skip] +struct S(&'static T); +//~^ ERROR the parameter type `T` may not live long enough +//~| HELP consider adding an explicit lifetime bound +//~| SUGGESTION 'static + +fn main() {} diff --git a/tests/ui/generics/missing-param-but-has-colon-144215.stderr b/tests/ui/generics/missing-param-but-has-colon-144215.stderr new file mode 100644 index 0000000000000..bf6cee035e2e6 --- /dev/null +++ b/tests/ui/generics/missing-param-but-has-colon-144215.stderr @@ -0,0 +1,17 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/missing-param-but-has-colon-144215.rs:4:14 + | +LL | struct S(&'static T); + | ^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the reference type `&'static T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound + | +LL | struct S(&'static T); + | +++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr b/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr index 11a8c01e49094..63de7099797ca 100644 --- a/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr +++ b/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr @@ -3,7 +3,9 @@ error[E0401]: can't reference `Self` constructor from outer item | LL | impl A { | ------------ the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference -... +LL | fn d() { +LL | fn d() { + | - `Self` used in this inner item LL | Self(1) | ^^^^ help: replace `Self` with the actual type: `A` diff --git a/tests/ui/resolve/bad-type-env-capture.stderr b/tests/ui/resolve/bad-type-env-capture.stderr index 3f9bc9149c24a..c565997ca2a26 100644 --- a/tests/ui/resolve/bad-type-env-capture.stderr +++ b/tests/ui/resolve/bad-type-env-capture.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo() { | - type parameter from outer item LL | fn bar(b: T) { } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn bar(b: T) { } + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr index fbb9ede8aa175..bc67e9dce4e3b 100644 --- a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr +++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr @@ -4,7 +4,9 @@ error[E0401]: can't use generic parameters from outer item LL | fn outer() { // outer function | - type parameter from outer item LL | const K: u32 = T::C; - | ^^^^ use of generic parameter from outer item + | - ^^^^ use of generic parameter from outer item + | | + | generic parameter used in this inner constant item | = note: a `const` is a separate item from the item that contains it @@ -15,7 +17,9 @@ LL | impl Tr for T { // outer impl block | - type parameter from outer item LL | const C: u32 = { LL | const I: u32 = T::C; - | ^^^^ use of generic parameter from outer item + | - ^^^^ use of generic parameter from outer item + | | + | generic parameter used in this inner constant item | = note: a `const` is a separate item from the item that contains it @@ -25,7 +29,9 @@ error[E0401]: can't use generic parameters from outer item LL | struct S(U32<{ // outer struct | - type parameter from outer item LL | const _: u32 = T::C; - | ^^^^ use of generic parameter from outer item + | - ^^^^ use of generic parameter from outer item + | | + | generic parameter used in this inner constant item | = note: a `const` is a separate item from the item that contains it diff --git a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr index 60aa94038c3ad..3959d117c7c9a 100644 --- a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr +++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr @@ -4,11 +4,15 @@ error[E0401]: can't use generic parameters from outer item LL | fn outer() { // outer function | - type parameter from outer item LL | const K: u32 = T::C; - | - ^^^^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | - ^^^^ use of generic parameter from outer item + | | + | generic parameter used in this inner constant item | = note: a `const` is a separate item from the item that contains it +help: try introducing a local generic parameter here + | +LL | const K: u32 = T::C; + | +++ error[E0401]: can't use generic parameters from outer item --> $DIR/generic-params-from-outer-item-in-const-item.rs:19:24 @@ -17,11 +21,15 @@ LL | impl Tr for T { // outer impl block | - type parameter from outer item LL | const C: u32 = { LL | const I: u32 = T::C; - | - ^^^^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | - ^^^^ use of generic parameter from outer item + | | + | generic parameter used in this inner constant item | = note: a `const` is a separate item from the item that contains it +help: try introducing a local generic parameter here + | +LL | const I: u32 = T::C; + | +++ error[E0401]: can't use generic parameters from outer item --> $DIR/generic-params-from-outer-item-in-const-item.rs:27:20 @@ -29,11 +37,15 @@ error[E0401]: can't use generic parameters from outer item LL | struct S(U32<{ // outer struct | - type parameter from outer item LL | const _: u32 = T::C; - | - ^^^^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | - ^^^^ use of generic parameter from outer item + | | + | generic parameter used in this inner constant item | = note: a `const` is a separate item from the item that contains it +help: try introducing a local generic parameter here + | +LL | const _: u32 = T::C; + | +++ error: aborting due to 3 previous errors diff --git a/tests/ui/resolve/issue-12796.stderr b/tests/ui/resolve/issue-12796.stderr index 2305971303a71..b5828c6f5fc86 100644 --- a/tests/ui/resolve/issue-12796.stderr +++ b/tests/ui/resolve/issue-12796.stderr @@ -2,10 +2,11 @@ error[E0401]: can't use `Self` from outer item --> $DIR/issue-12796.rs:3:22 | LL | fn inner(_: &Self) { - | ^^^^ - | | - | use of `Self` from outer item - | can't use `Self` here + | ----- ^^^^ + | | | + | | use of `Self` from outer item + | | can't use `Self` here + | `Self` used in this inner function error: aborting due to 1 previous error diff --git a/tests/ui/resolve/issue-3021-c.stderr b/tests/ui/resolve/issue-3021-c.stderr index 537bbaf7b6a56..8c554fd1b97dc 100644 --- a/tests/ui/resolve/issue-3021-c.stderr +++ b/tests/ui/resolve/issue-3021-c.stderr @@ -5,9 +5,14 @@ LL | fn siphash() { | - type parameter from outer item LL | LL | trait U { - | - help: try introducing a local generic parameter here: `` + | - generic parameter used in this inner trait LL | fn g(&self, x: T) -> T; | ^ use of generic parameter from outer item + | +help: try introducing a local generic parameter here + | +LL | trait U { + | +++ error[E0401]: can't use generic parameters from outer item --> $DIR/issue-3021-c.rs:4:30 @@ -16,9 +21,14 @@ LL | fn siphash() { | - type parameter from outer item LL | LL | trait U { - | - help: try introducing a local generic parameter here: `` + | - generic parameter used in this inner trait LL | fn g(&self, x: T) -> T; | ^ use of generic parameter from outer item + | +help: try introducing a local generic parameter here + | +LL | trait U { + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/issue-3214.stderr b/tests/ui/resolve/issue-3214.stderr index 1c64fdc1711fd..ab12676bdd805 100644 --- a/tests/ui/resolve/issue-3214.stderr +++ b/tests/ui/resolve/issue-3214.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo() { | - type parameter from outer item LL | struct Foo { - | - help: try introducing a local generic parameter here: `` + | --- generic parameter used in this inner struct LL | x: T, | ^ use of generic parameter from outer item + | +help: try introducing a local generic parameter here + | +LL | struct Foo { + | +++ error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied --> $DIR/issue-3214.rs:6:22 diff --git a/tests/ui/resolve/issue-39559-2.stderr b/tests/ui/resolve/issue-39559-2.stderr index f6e6917d01e6d..4bfa1d1b1322f 100644 --- a/tests/ui/resolve/issue-39559-2.stderr +++ b/tests/ui/resolve/issue-39559-2.stderr @@ -4,7 +4,20 @@ error[E0015]: cannot call non-const associated function `::dim` in LL | let array: [usize; Dim3::dim()] | ^^^^^^^^^^^ | +note: associated function `dim` is not const because trait `Dim` is not const + --> $DIR/issue-39559-2.rs:1:1 + | +LL | trait Dim { + | ^^^^^^^^^ this trait is not const +LL | fn dim() -> usize; + | ------------------ this associated function is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` = note: calls in constants are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Dim` const + | +LL + #[const_trait] +LL | trait Dim { + | error[E0015]: cannot call non-const associated function `::dim` in constants --> $DIR/issue-39559-2.rs:16:15 @@ -12,7 +25,20 @@ error[E0015]: cannot call non-const associated function `::dim` in LL | = [0; Dim3::dim()]; | ^^^^^^^^^^^ | +note: associated function `dim` is not const because trait `Dim` is not const + --> $DIR/issue-39559-2.rs:1:1 + | +LL | trait Dim { + | ^^^^^^^^^ this trait is not const +LL | fn dim() -> usize; + | ------------------ this associated function is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` = note: calls in constants are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Dim` const + | +LL + #[const_trait] +LL | trait Dim { + | error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr b/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr index ca32147d19765..2d21ed0155a70 100644 --- a/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr +++ b/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr @@ -1,11 +1,14 @@ error[E0401]: can't use generic parameters from outer item --> $DIR/issue-65025-extern-static-parent-generics.rs:3:28 | -LL | unsafe fn foo() { - | - type parameter from outer item -LL | extern "C" { -LL | static baz: *const A; - | ^ use of generic parameter from outer item +LL | unsafe fn foo() { + | - type parameter from outer item +LL | / extern "C" { +LL | | static baz: *const A; + | | ^ use of generic parameter from outer item +LL | | +LL | | } + | |_____- generic parameter used in this inner extern block | = note: a `static` is a separate item from the item that contains it diff --git a/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr b/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr index 98ffb4567f164..b22bfb719bd50 100644 --- a/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr +++ b/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr @@ -1,11 +1,14 @@ error[E0401]: can't use generic parameters from outer item --> $DIR/issue-65035-static-with-parent-generics.rs:3:26 | -LL | fn f() { - | - type parameter from outer item -LL | extern "C" { -LL | static a: *const T; - | ^ use of generic parameter from outer item +LL | fn f() { + | - type parameter from outer item +LL | / extern "C" { +LL | | static a: *const T; + | | ^ use of generic parameter from outer item +LL | | +LL | | } + | |_____- generic parameter used in this inner extern block | = note: a `static` is a separate item from the item that contains it @@ -15,18 +18,23 @@ error[E0401]: can't use generic parameters from outer item LL | fn g() { | - type parameter from outer item LL | static a: *const T = Default::default(); - | ^ use of generic parameter from outer item + | - ^ use of generic parameter from outer item + | | + | generic parameter used in this inner static item | = note: a `static` is a separate item from the item that contains it error[E0401]: can't use generic parameters from outer item --> $DIR/issue-65035-static-with-parent-generics.rs:15:24 | -LL | fn h() { - | - const parameter from outer item -LL | extern "C" { -LL | static a: [u8; N]; - | ^ use of generic parameter from outer item +LL | fn h() { + | - const parameter from outer item +LL | / extern "C" { +LL | | static a: [u8; N]; + | | ^ use of generic parameter from outer item +LL | | +LL | | } + | |_____- generic parameter used in this inner extern block | = note: a `static` is a separate item from the item that contains it @@ -36,7 +44,9 @@ error[E0401]: can't use generic parameters from outer item LL | fn i() { | - const parameter from outer item LL | static a: [u8; N] = [0; N]; - | ^ use of generic parameter from outer item + | - ^ use of generic parameter from outer item + | | + | generic parameter used in this inner static item | = note: a `static` is a separate item from the item that contains it @@ -46,7 +56,9 @@ error[E0401]: can't use generic parameters from outer item LL | fn i() { | - const parameter from outer item LL | static a: [u8; N] = [0; N]; - | ^ use of generic parameter from outer item + | - ^ use of generic parameter from outer item + | | + | generic parameter used in this inner static item | = note: a `static` is a separate item from the item that contains it diff --git a/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr b/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr index 1ab56fdc50441..00aa645688e7f 100644 --- a/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr +++ b/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr @@ -5,9 +5,14 @@ LL | trait TraitA { | - type parameter from outer item LL | fn outer(&self) { LL | enum Foo { - | - help: try introducing a local generic parameter here: `A,` + | --- generic parameter used in this inner enum LL | Variance(A) | ^ use of generic parameter from outer item + | +help: try introducing a local generic parameter here + | +LL | enum Foo { + | ++ error[E0401]: can't use generic parameters from outer item --> $DIR/resolve-type-param-in-item-in-trait.rs:16:23 @@ -16,9 +21,14 @@ LL | trait TraitB { | - type parameter from outer item LL | fn outer(&self) { LL | struct Foo(A); - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `A,` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner struct + | +help: try introducing a local generic parameter here + | +LL | struct Foo(A); + | ++ error[E0401]: can't use generic parameters from outer item --> $DIR/resolve-type-param-in-item-in-trait.rs:23:28 @@ -27,9 +37,14 @@ LL | trait TraitC { | - type parameter from outer item LL | fn outer(&self) { LL | struct Foo { a: A } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `A,` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner struct + | +help: try introducing a local generic parameter here + | +LL | struct Foo { a: A } + | ++ error[E0401]: can't use generic parameters from outer item --> $DIR/resolve-type-param-in-item-in-trait.rs:30:22 @@ -38,9 +53,14 @@ LL | trait TraitD { | - type parameter from outer item LL | fn outer(&self) { LL | fn foo(a: A) { } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `A,` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn foo(a: A) { } + | ++ error: aborting due to 4 previous errors diff --git a/tests/ui/resolve/use-self-in-inner-fn.rs b/tests/ui/resolve/use-self-in-inner-fn.rs index 62f9dc5664ffe..ed64ee885271c 100644 --- a/tests/ui/resolve/use-self-in-inner-fn.rs +++ b/tests/ui/resolve/use-self-in-inner-fn.rs @@ -6,6 +6,7 @@ impl A { fn peach(this: &Self) { //~^ ERROR can't use `Self` from outer item //~| NOTE use of `Self` from outer item + //~| NOTE `Self` used in this inner function //~| NOTE refer to the type directly here instead } } diff --git a/tests/ui/resolve/use-self-in-inner-fn.stderr b/tests/ui/resolve/use-self-in-inner-fn.stderr index 9c388df8bc20c..645875f6e726d 100644 --- a/tests/ui/resolve/use-self-in-inner-fn.stderr +++ b/tests/ui/resolve/use-self-in-inner-fn.stderr @@ -5,10 +5,11 @@ LL | impl A { | ---- `Self` type implicitly declared here, by this `impl` ... LL | fn peach(this: &Self) { - | ^^^^ - | | - | use of `Self` from outer item - | refer to the type directly here instead + | ----- ^^^^ + | | | + | | use of `Self` from outer item + | | refer to the type directly here instead + | `Self` used in this inner function error: aborting due to 1 previous error diff --git a/tests/ui/self/self-ctor-nongeneric.stderr b/tests/ui/self/self-ctor-nongeneric.stderr index b53ecbe55b594..c3ae7df2ad25e 100644 --- a/tests/ui/self/self-ctor-nongeneric.stderr +++ b/tests/ui/self/self-ctor-nongeneric.stderr @@ -5,7 +5,9 @@ LL | impl S0 { | ------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference LL | fn foo() { LL | const C: S0 = Self(0); - | ^^^^ help: replace `Self` with the actual type: `S0` + | - ^^^^ help: replace `Self` with the actual type: `S0` + | | + | `Self` used in this inner item | = 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 #124186 @@ -17,6 +19,8 @@ warning: can't reference `Self` constructor from outer item LL | impl S0 { | ------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference ... +LL | fn bar() -> S0 { + | --- `Self` used in this inner item LL | Self(0) | ^^^^ help: replace `Self` with the actual type: `S0` | diff --git a/tests/ui/self/self-ctor.stderr b/tests/ui/self/self-ctor.stderr index 0cb22baaa1a05..b8dfd324c3f36 100644 --- a/tests/ui/self/self-ctor.stderr +++ b/tests/ui/self/self-ctor.stderr @@ -5,7 +5,9 @@ LL | impl S0 { | ------------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference LL | fn foo() { LL | const C: S0 = Self(0); - | ^^^^ help: replace `Self` with the actual type: `S0` + | - ^^^^ help: replace `Self` with the actual type: `S0` + | | + | `Self` used in this inner item error[E0401]: can't reference `Self` constructor from outer item --> $DIR/self-ctor.rs:8:13 @@ -13,6 +15,8 @@ error[E0401]: can't reference `Self` constructor from outer item LL | impl S0 { | ------------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference ... +LL | fn bar() -> S0 { + | --- `Self` used in this inner item LL | Self(0) | ^^^^ help: replace `Self` with the actual type: `S0` diff --git a/tests/ui/static/static-vec-repeat-not-constant.stderr b/tests/ui/static/static-vec-repeat-not-constant.stderr index e6ff199ae0198..fa4033f6a4076 100644 --- a/tests/ui/static/static-vec-repeat-not-constant.stderr +++ b/tests/ui/static/static-vec-repeat-not-constant.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `foo` in statics LL | static a: [isize; 2] = [foo(); 2]; | ^^^^^ | +note: function `foo` is not const + --> $DIR/static-vec-repeat-not-constant.rs:1:1 + | +LL | fn foo() -> isize { 23 } + | ^^^^^^^^^^^^^^^^^ = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index eb2d37d297e9f..c54f4830533ae 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -35,6 +35,13 @@ error[E0015]: cannot call non-const method `::to_string` in sta LL | field2: SafeEnum::Variant4("str".to_string()), | ^^^^^^^^^^^ | +note: method `to_string` is not const because trait `ToString` is not const + --> $SRC_DIR/alloc/src/string.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/alloc/src/string.rs:LL:COL + | + = note: this method is not const = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/statics/static-generic-param-soundness.stderr b/tests/ui/statics/static-generic-param-soundness.stderr index 47554c7fcb0f0..72f65e2bac7cb 100644 --- a/tests/ui/statics/static-generic-param-soundness.stderr +++ b/tests/ui/statics/static-generic-param-soundness.stderr @@ -4,7 +4,9 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo() { | - type parameter from outer item LL | static a: Bar = Bar::What; - | ^ use of generic parameter from outer item + | - ^ use of generic parameter from outer item + | | + | generic parameter used in this inner static item | = note: a `static` is a separate item from the item that contains it diff --git a/tests/ui/traits/const-traits/assoc-type.current.stderr b/tests/ui/traits/const-traits/assoc-type.current.stderr index 1e58efeedeea1..7fe086550f1c2 100644 --- a/tests/ui/traits/const-traits/assoc-type.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type.current.stderr @@ -9,6 +9,10 @@ note: required by a bound in `Foo::Bar` | LL | type Bar: [const] Add; | ^^^^^^^^^^^ required by this bound in `Foo::Bar` +help: make the `impl` of trait `Add` `const` + | +LL | impl const Add for NonConstAdd { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/assoc-type.next.stderr b/tests/ui/traits/const-traits/assoc-type.next.stderr index 1e58efeedeea1..7fe086550f1c2 100644 --- a/tests/ui/traits/const-traits/assoc-type.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type.next.stderr @@ -9,6 +9,10 @@ note: required by a bound in `Foo::Bar` | LL | type Bar: [const] Add; | ^^^^^^^^^^^ required by this bound in `Foo::Bar` +help: make the `impl` of trait `Add` `const` + | +LL | impl const Add for NonConstAdd { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call-const-closure.stderr b/tests/ui/traits/const-traits/call-const-closure.stderr index 4bb8b2e9777e6..9de22759c2003 100644 --- a/tests/ui/traits/const-traits/call-const-closure.stderr +++ b/tests/ui/traits/const-traits/call-const-closure.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `(): [const] Bar` is not satisfied | LL | (const || ().foo())(); | ^^^ + | +help: make the `impl` of trait `Bar` `const` + | +LL | impl const Bar for () { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr index 4aaf53344c90a..c6f93629379ac 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `u32: [const] Plus` is not satisfied | LL | a.plus(b) | ^ + | +help: make the `impl` of trait `Plus` `const` + | +LL | impl const Plus for u32 { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call-generic-method-fail.stderr b/tests/ui/traits/const-traits/call-generic-method-fail.stderr index a2fba141f7b89..6e75730b9b513 100644 --- a/tests/ui/traits/const-traits/call-generic-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-fail.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `T: [const] PartialEq` is not satisfied | LL | *t == *t | ^^^^^^^^ + | +note: trait `PartialEq` is implemented but not `const` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +note: trait `PartialEq` is implemented but not `const` + --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr index 9c1e0fee9e711..b2ec41182a83b 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr @@ -11,6 +11,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: make the `impl` of trait `Foo` `const` + | +LL | impl const Foo for S { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr index 599a5503b0f33..1a7ec35f3ddba 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr @@ -4,6 +4,11 @@ error[E0015]: cannot call non-const function `non_const` in constant functions LL | fn foo() { non_const() } | ^^^^^^^^^^^ | +note: function `non_const` is not const + --> $DIR/const-check-fns-in-const-impl.rs:11:1 + | +LL | fn non_const() {} + | ^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr index fddd8d10bccc4..faacc86512441 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `(): const Tr` is not satisfied | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: make the `impl` of trait `Tr` `const` + | +LL | impl const Tr for () { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.stderr b/tests/ui/traits/const-traits/const-default-method-bodies.stderr index 03ca6f1d51155..22b6a9b5613a8 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.stderr +++ b/tests/ui/traits/const-traits/const-default-method-bodies.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `NonConstImpl: [const] ConstDefaultFn` is not sati | LL | NonConstImpl.a(); | ^ + | +help: make the `impl` of trait `ConstDefaultFn` `const` + | +LL | impl const ConstDefaultFn for NonConstImpl { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr index c2309ea6e122e..48c8852a7b8d4 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr @@ -16,6 +16,10 @@ note: required by a bound in `check` | LL | const fn check(_: T) {} | ^^^^^^^^^^^^^^^^ required by this bound in `check` +help: make the `impl` of trait `A` `const` + | +LL | impl const A for NonTrivialDrop {} + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr index c2309ea6e122e..48c8852a7b8d4 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr @@ -16,6 +16,10 @@ note: required by a bound in `check` | LL | const fn check(_: T) {} | ^^^^^^^^^^^^^^^^ required by this bound in `check` +help: make the `impl` of trait `A` `const` + | +LL | impl const A for NonTrivialDrop {} + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-opaque.no.stderr b/tests/ui/traits/const-traits/const-opaque.no.stderr index acf19ba96ab39..591b81f976745 100644 --- a/tests/ui/traits/const-traits/const-opaque.no.stderr +++ b/tests/ui/traits/const-traits/const-opaque.no.stderr @@ -11,12 +11,21 @@ note: required by a bound in `bar` | LL | const fn bar(t: T) -> impl [const] Foo { | ^^^^^^^^^^^ required by this bound in `bar` +help: make the `impl` of trait `Foo` `const` + | +LL | impl const Foo for () { + | +++++ error[E0277]: the trait bound `(): const Foo` is not satisfied --> $DIR/const-opaque.rs:33:12 | LL | opaque.method(); | ^^^^^^ + | +help: make the `impl` of trait `Foo` `const` + | +LL | impl const Foo for () { + | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr index 1da519151182a..fe45ff188efb4 100644 --- a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr +++ b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr @@ -3,6 +3,12 @@ error[E0277]: the trait bound `cross_crate::NonConst: [const] cross_crate::MyTra | LL | NonConst.func(); | ^^^^ + | +note: trait `MyTrait` is implemented but not `const` + --> $DIR/auxiliary/cross-crate.rs:12:1 + | +LL | impl MyTrait for NonConst { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr index 2e236cecfb475..3ce646ec5027f 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr @@ -9,6 +9,10 @@ note: required by a bound in `foo` | LL | const fn foo() where T: [const] Tr {} | ^^^^^^^^^^ required by this bound in `foo` +help: make the `impl` of trait `Tr` `const` + | +LL | impl const Tr for () {} + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr index 2dc2d48461749..f473a687efcb0 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `(): [const] Tr` is not satisfied | LL | ().a() | ^ + | +help: make the `impl` of trait `Tr` `const` + | +LL | impl const Tr for () {} + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr index ad0829ff05fb0..ca73ae845550d 100644 --- a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr +++ b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr @@ -13,7 +13,19 @@ error[E0015]: cannot call non-const method `<() as Trait>::foo` in constant func LL | ().foo(); | ^^^^^ | +note: method `foo` is not const because trait `Trait` is not const + --> $DIR/inline-incorrect-early-bound-in-ctfe.rs:13:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ this trait is not const +LL | fn foo(self); + | ------------- this method is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Trait` const + | +LL + #[const_trait] +LL | trait Trait { + | error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/issue-79450.stderr b/tests/ui/traits/const-traits/issue-79450.stderr index 5bdebbbfb032b..d8a9e18980687 100644 --- a/tests/ui/traits/const-traits/issue-79450.stderr +++ b/tests/ui/traits/const-traits/issue-79450.stderr @@ -4,6 +4,8 @@ error[E0015]: cannot call non-const function `_print` in constant functions LL | println!("lul"); | ^^^^^^^^^^^^^^^ | +note: function `_print` is not const + --> $SRC_DIR/std/src/io/stdio.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/traits/const-traits/issue-88155.stderr b/tests/ui/traits/const-traits/issue-88155.stderr index 96a3c4187f5c2..4a912cc8274a7 100644 --- a/tests/ui/traits/const-traits/issue-88155.stderr +++ b/tests/ui/traits/const-traits/issue-88155.stderr @@ -4,7 +4,19 @@ error[E0015]: cannot call non-const associated function `::assoc` in con LL | T::assoc() | ^^^^^^^^^^ | +note: associated function `assoc` is not const because trait `A` is not const + --> $DIR/issue-88155.rs:3:1 + | +LL | pub trait A { + | ^^^^^^^^^^^ this trait is not const +LL | fn assoc() -> bool; + | ------------------- this associated function is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `A` const + | +LL + #[const_trait] +LL | pub trait A { + | error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr index 8e5894a32966f..3c150c77a6916 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr @@ -9,6 +9,10 @@ note: required by a bound in `Foo::Assoc` | LL | type Assoc: [const] Bar | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` +help: make the `impl` of trait `Bar` `const` + | +LL | impl const Bar for N where T: Bar {} + | +++++ error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/item-bound-entailment-fails.rs:24:21 diff --git a/tests/ui/traits/const-traits/minicore-deref-fail.stderr b/tests/ui/traits/const-traits/minicore-deref-fail.stderr index 4329b235756be..e6c087cb9d822 100644 --- a/tests/ui/traits/const-traits/minicore-deref-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-deref-fail.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `Ty: [const] minicore::Deref` is not satisfied | LL | *Ty; | ^^^ + | +help: make the `impl` of trait `Deref` `const` + | +LL | impl const Deref for Ty { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.stderr b/tests/ui/traits/const-traits/minicore-fn-fail.stderr index c02a067774b56..eb840d421f488 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-fn-fail.stderr @@ -11,6 +11,10 @@ note: required by a bound in `call_indirect` | LL | const fn call_indirect(t: &T) { t() } | ^^^^^^^^^^^^ required by this bound in `call_indirect` +help: make the `impl` of trait `Foo` `const` + | +LL | impl const Foo for () {} + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/no-explicit-const-params.stderr b/tests/ui/traits/const-traits/no-explicit-const-params.stderr index 6955e9ab2985d..47fa65b2479be 100644 --- a/tests/ui/traits/const-traits/no-explicit-const-params.stderr +++ b/tests/ui/traits/const-traits/no-explicit-const-params.stderr @@ -59,6 +59,11 @@ error[E0277]: the trait bound `(): const Bar` is not satisfied | LL | <() as Bar>::bar(); | ^^ + | +help: make the `impl` of trait `Bar` `const` + | +LL | impl const Bar for () { + | +++++ error: aborting due to 5 previous errors diff --git a/tests/ui/traits/const-traits/specializing-constness-2.stderr b/tests/ui/traits/const-traits/specializing-constness-2.stderr index 850e6939daebc..2a34cd1c4f82d 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.stderr +++ b/tests/ui/traits/const-traits/specializing-constness-2.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `T: [const] A` is not satisfied | LL | ::a(); | ^ + | +help: make the `impl` of trait `A` `const` + | +LL | impl const A for T { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr index 0ecbad64bc853..c9dc239bef334 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr @@ -51,7 +51,19 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/super-traits-fail-2.rs:6:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 5 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr index 0e5b697d1ddef..bfbf6980ab833 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr @@ -63,7 +63,19 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/super-traits-fail-2.rs:6:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr index a0ae60526ef3f..ea487cbd563f2 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -94,7 +94,20 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/super-traits-fail-3.rs:17:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 9 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr index a0ae60526ef3f..ea487cbd563f2 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -94,7 +94,20 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/super-traits-fail-3.rs:17:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 9 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index c8ec77c2f0930..5951caebe7335 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -74,7 +74,19 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/super-traits-fail-3.rs:17:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 7 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr index a820239cde012..563495204ad7b 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -63,7 +63,19 @@ error[E0015]: cannot call non-const method `::a` in constant functions LL | x.a(); | ^^^ | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/super-traits-fail-3.rs:17:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL + #[const_trait] +LL | trait Foo { + | error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail.stderr b/tests/ui/traits/const-traits/super-traits-fail.stderr index e19aa30cf95c3..3010a5df0c31f 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail.stderr @@ -3,6 +3,11 @@ error[E0277]: the trait bound `S: [const] Foo` is not satisfied | LL | impl const Bar for S {} | ^ + | +help: make the `impl` of trait `Foo` `const` + | +LL | impl const Foo for S { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr b/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr index ad33a70ed3bb6..2e75003c49b8a 100644 --- a/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr +++ b/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr @@ -24,6 +24,9 @@ error[E0401]: can't reference `Self` constructor from outer item LL | impl<'a, T> Foo<'a> for Repeated { | ----------------------------------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference ... +LL | fn inner(value: Option<()>) -> Repeated { + | ----- `Self` used in this inner item +LL | match value { LL | _ => Self(unimplemented!()), | ^^^^ help: replace `Self` with the actual type: `Repeated` diff --git a/tests/ui/type/type-arg-out-of-scope.stderr b/tests/ui/type/type-arg-out-of-scope.stderr index fcaaca1770f67..3d8850ebccea5 100644 --- a/tests/ui/type/type-arg-out-of-scope.stderr +++ b/tests/ui/type/type-arg-out-of-scope.stderr @@ -4,9 +4,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo(x: T) { | - type parameter from outer item LL | fn bar(f: Box T>) { } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn bar(f: Box T>) { } + | +++ error[E0401]: can't use generic parameters from outer item --> $DIR/type-arg-out-of-scope.rs:2:35 @@ -14,9 +19,14 @@ error[E0401]: can't use generic parameters from outer item LL | fn foo(x: T) { | - type parameter from outer item LL | fn bar(f: Box T>) { } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` + | --- ^ use of generic parameter from outer item + | | + | generic parameter used in this inner function + | +help: try introducing a local generic parameter here + | +LL | fn bar(f: Box T>) { } + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 240dc1ae8ab9e..0b70ac97fd435 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -671,6 +671,11 @@ error[E0015]: cannot call non-const function `map::` in constants LL | const _: Option<_> = map(value); | ^^^^^^^^^^ | +note: function `map` is not const + --> $DIR/typeck_type_placeholder_item.rs:222:1 + | +LL | fn map(_: fn() -> Option<&'static T>) -> Option { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}>` in constants @@ -679,6 +684,13 @@ error[E0015]: cannot call non-const method ` as Iterator>:: LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^ | +note: method `filter` is not const because trait `Iterator` is not const + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this method is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::` in constants @@ -687,6 +699,13 @@ error[E0015]: cannot call non-const method `, {closu LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^ | +note: method `map` is not const because trait `Iterator` is not const + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this method is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 83 previous errors