about summary refs log tree commit diff
path: root/tests/ui/generic-const-items
AgeCommit message (Collapse)AuthorLines
2025-08-06Fortify generic param default checksLeón Orell Valerian Liehr-11/+36
2025-06-30Avoid looking at HIR for trait and impl itemsOli Scherer-1/+1
2025-06-26Move an ACE test out of the GCI directoryLeón Orell Valerian Liehr-35/+0
2025-06-07const-eval error: always say in which item the error occurredRalf Jung-3/+3
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-02Clarify why we are talking about a failed const eval at a random placeOli Scherer-4/+4
2025-06-02Use the informative error as the main const eval error messageOli Scherer-12/+12
2025-05-28GCI: Check where-clauses for well-formedness at the def siteLeón Orell Valerian Liehr-0/+22
2025-05-27Always evaluate free lifetime-generic constantsLeón Orell Valerian Liehr-6/+5
Co-authored-by: Michael Goulet <michael@errs.io>
2025-05-01User type annotations for free consts in pattern positionBoxy-0/+25
2025-04-11Improve `AssocItem::descr`.Nicholas Nethercote-12/+12
The commit adds "associated" to the description of associated types and associated consts, to match the description of associated functions. This increases error message precision and consistency with `AssocKind::fmt`. The commit also notes an imperfection in `AssocKind::fmt`; fixing this imperfection is possible but beyond the scope of this PR.
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-2/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-01Rollup merge of #137617 - BoxyUwU:generic_const_parameter_types, r=lcnrMatthias Krüger-2/+0
Introduce `feature(generic_const_parameter_types)` Allows to define const generic parameters whose type depends on other generic parameters, e.g. `Foo<const N: usize, const ARR: [u8; N]>;` Wasn't going to implement for this for a while until we could implement it with `bad_inference.rs` resolved but apparently the project simd folks would like to be able to use this for some intrinsics and the inference issue isn't really a huge problem there aiui. (cc ``@workingjubilee`` )
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-2/+0
2025-02-28Shorten span of panic failures in const contextEsteban Küber-1/+1
Previously, we included a redundant prefix on the panic message and a postfix of the location of the panic. The prefix didn't carry any additional information beyond "something failed", and the location of the panic is redundant with the diagnostic's span, which gets printed out even if its code is not shown. ``` error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:11:9 | LL | MaybeUninit::<!>::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` ``` ``` error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ``` error[E0080]: evaluation of constant value failed --> $DIR/uninhabited.rs:41:9 | LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- When the primary span for a const error is the same as the first frame in the const error report, skip it. ``` error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` instead of ``` error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ explicit panic | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ note: inside `_CONST` --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- Revert order of constant evaluation errors Point at the code the user wrote first and std functions last. ``` error[E0080]: evaluation of constant value failed --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | LL | impl ConstGenericTrait<{my_fn(1)}> for () {} | ^^^^^^^^ evaluation panicked: Some error occurred | note: called from `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 | LL | panic!("Some error occurred"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` instead of ``` error[E0080]: evaluation of constant value failed --> $DIR/const-errs-dont-conflict-103369.rs:10:5 | LL | panic!("Some error occurred"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Some error occurred | note: called from `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}` --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | LL | impl ConstGenericTrait<{my_fn(1)}> for () {} | ^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ```
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-2/+4
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-01-29Rollup merge of #136168 - fmease:gci-fix-mono, r=compiler-errorsLeón Orell Valerian Liehr-0/+40
GCI: Don't try to eval / collect mono items inside overly generic free const items Fixes #136156. Thanks for the pointers, errs! There's one (preexisting) thing of note (maybe?). There's a difference between `const _: () = panic!();` and `const _<'a>: () = panic!();`: The former is a pre-mono error, the latter is a post-mono error. For comparison, both `fn _f() { const { panic!() } }` and `fn _f<'a: 'a>() { const { panic!() } }` are post-mono errors. cc `@oli-obk` r? compiler-errors or reassign
2025-01-28GCI: Don't try to collect mono items inside overly generic free const itemsLeón Orell Valerian Liehr-0/+40
2025-01-27Remove all dead files inside tests/ui/León Orell Valerian Liehr-13/+0
2025-01-06improve diagnostics for const eval query overflowMartin Zacho-4/+14
2025-01-02Remove diagnostic_only_typeck and fix placeholder suggestion for const/staticMichael Goulet-16/+3
2024-11-03Yeet effects featureMichael Goulet-1/+1
2024-11-02Add trait diff highlighting logic and use it in E0277Esteban Küber-2/+4
When a trait is not implemented for a type, but there *is* an `impl` for another type or different trait params, we format the output to use highlighting in the same way that E0308 does for types. The logic accounts for 3 cases: - When both the type and trait in the expected predicate and the candidate are different - When only the types are different - When only the trait generic params are different For each case, we use slightly different formatting and wording.
2024-09-29fix(hir_analysis/wfcheck): don't leak {type error}Barrett Ray-19/+20
avoid `{type error}` being leaked in user-facing messages, particularly when using the `adt_const_params` feature
2024-07-17Split part of `adt_const_params` into `unsized_const_params`Boxy-0/+4
2024-06-30Migrate tests to use `-Znext-solver`Deadbeef-1/+1
2024-05-24Handle trait/impl GAC mismatches when inferring missing/placeholder typesLeón Orell Valerian Liehr-5/+25
2024-05-24Properly deal with missing/placeholder types inside GACsLeón Orell Valerian Liehr-0/+49
2024-04-13Check regions earlier when comparing impl with trait item defLeón Orell Valerian Liehr-17/+29
2024-04-10Use `fn` ptr signature instead of `{closure@..}` in infer errorEsteban Küber-2/+2
When suggesting a type on inference error, do not use `{closure@..}`. Instead, replace with an appropriate `fn` ptr. On the error message, use `short_ty_string` and write long types to disk. ``` error[E0284]: type annotations needed for `Select<{closure@lib.rs:2782:13}, _, Expression<'_>, _>` --> crates/lang/src/parser.rs:41:13 | 41 | let lit = select! { | ^^^ 42 | Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()), | ---- type must be known at this point | = note: the full type name has been written to '/home/gh-estebank/iowo/target/debug/deps/lang-e2d6e25819442273.long-type-4587393693885174369.txt' = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan` help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 41 | let lit: Select<for<'a, 'b> fn(tokens::Token<'_>, &'a mut MapExtra<'_, 'b, _, _>) -> Option<Expression<'_>>, _, Expression<'_>, _> = select! { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` instead of ``` error[E0284]: type annotations needed for `Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _>` --> crates/lang/src/parser.rs:41:13 | 41 | let lit = select! { | ^^^ 42 | Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()), | ---- type must be known at this point | = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan` help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 41 | let lit: Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _> = select! { | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Fix #123630.
2024-04-07add test for assertion failed: !value.has_infer() #115806Matthias Krüger-0/+33
Fixes https://github.com/rust-lang/rust/issues/115806
2024-03-26Auto merge of #121387 - oli-obk:eager_const_failures_regression, r=lcnrbors-0/+14
Avoid some unnecessary query invocations. Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything. should fix the perf regression from https://github.com/rust-lang/rust/pull/121087
2024-03-25Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkovMatthias Krüger-0/+35
add even more tests! Fixes https://github.com/rust-lang/rust/issues/109869 Fixes https://github.com/rust-lang/rust/issues/110453 Fixes https://github.com/rust-lang/rust/issues/109020 Fixes https://github.com/rust-lang/rust/issues/108580 Fixes https://github.com/rust-lang/rust/issues/108220 Fixes https://github.com/rust-lang/rust/issues/113045 Fixes https://github.com/rust-lang/rust/issues/113133 Fixes https://github.com/rust-lang/rust/issues/114464 Fixes https://github.com/rust-lang/rust/issues/116599 Fixes https://github.com/rust-lang/rust/issues/119731
2024-03-24add test for ICE with associated_const_equality #108220Matthias Krüger-0/+35
Fixes #108220
2024-03-21Provide structured suggestion for unconstrained generic constantEsteban Küber-10/+45
``` error: unconstrained generic constant --> $DIR/const-argument-if-length.rs:18:10 | LL | pad: [u8; is_zst::<T>()], | ^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: { | ++++++++++++++++++++++++++ ``` Detect when the constant expression isn't `usize` and suggest casting: ``` error: unconstrained generic constant --> f300.rs:6:10 | 6 | bb::<{!N}>(); | ^^^^ -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36 | help: try adding a `where` bound | 5 | fn b<const N: bool>() where [(); {!N} as usize]: { | ++++++++++++++++++++++++++ ``` Fix #122395.
2024-03-19Avoid computing generic params or a param env for free const itemsOli Scherer-0/+14
2024-03-18Provide structured suggestion for `#![feature(foo)]`Esteban Küber-1/+4
``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-11Rollup merge of #119385 - fmease:assoc-const-eq-fixes-2, r=oli-obk,cjgillotJubilee-1/+10
Fix type resolution of associated const equality bounds (take 2) Instead of trying to re-resolve the type of assoc const bindings inside the `type_of` query impl in an incomplete manner, transfer the already (correctly) resolved type from `add_predicates_for_ast_type_binding` to `type_of`/`anon_type_of` through query feeding. --- Together with #118668 (merged) and #121258, this supersedes #118360. Fixes #118040. r? ``@ghost``
2024-02-19Always evaluate free constants and statics, even if previous errors occurredOli Scherer-3/+12
2024-02-18Propagate the resolved type of assoc const bindings via query feedingLeón Orell Valerian Liehr-1/+10
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-9/+9
2024-01-31Remove a has_errors check that does not prevent follow up error noiseOli Scherer-1/+1
2024-01-13Bless testsGeorge-lewis-0/+8
Update tests
2024-01-09Avoid silencing relevant follow-up errorsOli Scherer-1/+14
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-17/+13
2023-12-19bless ui testsDeadbeef-0/+1
2023-11-24Show number in error message even for one errorNilstrieb-7/+7
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-12Deny more `~const` trait boundsLeón Orell Valerian Liehr-5/+5
2023-10-04Reorder fullfillment errors to keep more interesting ones firstEsteban Küber-1/+1
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed` and coercion errors to the end of the list. The pre-existing deduplication logic eliminates redundant errors better that way, keeping the resulting output with fewer errors than before, while also having more detail.
2023-10-02Point out the actual mismatch errorMichael Goulet-0/+2
2023-09-28make adt_const_params feature suggestion more consistent with others and ↵asquared31415-1/+1
only suggest it when the type can probably work