summary refs log tree commit diff
path: root/tests/ui/const-generics/generic_const_exprs
AgeCommit message (Collapse)AuthorLines
2024-04-24Fix tests and blessGary Guo-6/+5
2024-04-21add test for ICE caused by using feature(generic_const_exprs) #114463Matthias Krüger-0/+29
Fixes #114463
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 ice: unknown alias DefKind: AnonConst #116710Matthias Krüger-0/+34
Fixes https://github.com/rust-lang/rust/issues/116710
2024-04-04Allow defining opaque types when checking const equality boundsOli Scherer-4/+4
2024-04-04Add regression testOli Scherer-0/+40
2024-03-25Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkovMatthias Krüger-0/+180
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-25Auto merge of #122802 - estebank:unconstrained-generic-const, r=Nadrierilbors-43/+152
Provide structured suggestion for unconstrained generic constant ``` 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-24add test for ICE: no entry found for key for const function in ↵Matthias Krüger-0/+21
generic_const_exprs #113133 Fixes #113133
2024-03-24add test for #114464Matthias Krüger-0/+28
Fixes #114464
2024-03-24add test for https://github.com/rust-lang/rust/issues/119731Matthias Krüger-0/+131
Fixes #119731
2024-03-24add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directiveMatthias Krüger-1/+1
2024-03-24add test for 88421 ICE: could not fully normalize `&<MyType as ↵Matthias Krüger-0/+36
std::ops::Index<MyType>>::Output Fixes #88421
2024-03-23add test for #106423Matthias Krüger-0/+57
Fixes #106423
2024-03-22address review commentsMatthias Krüger-91/+11
2024-03-22add test for ice #119275 "no entry found for key" in predicates_of.rsMatthias Krüger-0/+64
fixes #119275
2024-03-22add test for ice #113017 no entry found for key in generics_of.rsMatthias Krüger-0/+112
Fixes #113017
2024-03-21Provide structured suggestion for unconstrained generic constantEsteban Küber-43/+152
``` 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-20register opaques that reference errorsAli MJ Al-Nasrawy-3/+19
2024-03-19Auto merge of #119212 - w-utter:pretty-print-const-expr, r=compiler-errorsbors-6/+4
Fix representation when printing abstract consts Previously, when printing a const generic expr, it would only display it as `{{const expr}}`. This allows for a more legible representation when printing these out. I also zipped the types with their constants for abstract consts that contain function calls when using type annotations, eg: `foo(S: usize, true: bool) -> usize` insteaad of `foo(S, true): fn(usize, bool) -> usize` for conciseness.
2024-03-18Provide structured suggestion for `#![feature(foo)]`Esteban Küber-4/+16
``` 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-17added pretty_print_const_exprwill-6/+4
2024-03-14Auto merge of #122347 - oli-obk:track_errors13, r=compiler-errorsbors-14/+14
Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" This reverts commit 65cd843ae06ad00123c131a431ed5304e4cd577a, reversing changes made to d255c6a57c393db6221b1ff700daea478436f1cd. reverts https://github.com/rust-lang/rust/pull/122140 It was a large regression in wall time due to trashing CPU caches
2024-03-11Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco"Oli Scherer-14/+14
This reverts commit 65cd843ae06ad00123c131a431ed5304e4cd577a, reversing changes made to d255c6a57c393db6221b1ff700daea478436f1cd.
2024-03-11Remove some unnecessary allow(incomplete_features)Michael Goulet-6/+4
2024-03-11Run a single huge `par_body_owners` instead of many small ones after each other.Oli Scherer-14/+14
This improves parallel rustc parallelism by avoiding the bottleneck after each individual `par_body_owners` (because it needs to wait for queries to finish, so if there is one long running one, a lot of cores will be idle while waiting for the single query).
2024-03-08Replace `TypeWalker` usage with `TypeVisitor`Shoyu Vanilla-1/+10
2024-02-29Make infer higher ranked equate use bidirectional subtyping in invariant contextSantiago Pastorino-1/+17
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-80/+80
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-5/+73
2024-02-03Rollup merge of #120531 - oli-obk:track_errors7, r=estebankMatthias Krüger-4/+29
Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect r? `@nnethercote`
2024-01-31Remove a has_errors check that only hides errors after unrelated items have ↵Oli Scherer-4/+29
errored.
2024-01-30Provide more context on derived obligation error primary labelEsteban Küber-1/+1
Expand the primary span of E0277 when the immediate unmet bound is not what the user wrote: ``` error[E0277]: the trait bound `i32: Bar` is not satisfied --> f100.rs:6:6 | 6 | <i32 as Foo>::foo(); | ^^^ the trait `Bar` is not implemented for `i32`, which is required by `i32: Foo` | help: this trait has no implementations, consider adding one --> f100.rs:2:1 | 2 | trait Bar {} | ^^^^^^^^^ note: required for `i32` to implement `Foo` --> f100.rs:3:14 | 3 | impl<T: Bar> Foo for T {} | --- ^^^ ^ | | | unsatisfied trait bound introduced here ``` Fix #40120.
2024-01-30Rollup merge of #120293 - estebank:issue-102629, r=nnethercoteGuillaume Gomez-10/+10
Deduplicate more sized errors on call exprs Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-26Auto merge of #116167 - RalfJung:structural-eq, r=lcnrbors-2/+2
remove StructuralEq trait The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more. One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust https://github.com/rust-lang/rust/pull/115893 to check for `Eq`, and rule out float matching for good. Fixes https://github.com/rust-lang/rust/issues/115881
2024-01-24remove StructuralEq traitRalf Jung-2/+2
2024-01-24Deduplicate more sized errors on call exprsEsteban Küber-10/+10
Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-22Make generic const type mismatches not hide trait impls from the trait solverOli Scherer-2/+34
2024-01-09Avoid silencing relevant follow-up errorsOli Scherer-4/+97
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-1/+1
2023-12-09report_not_const_evaluatable_error to avoid ICEing on ConstKind::ExprLenko Donchev-0/+89
2023-11-30generic_const_exprs: suggest to add the feature, not use itRalf Jung-11/+11
2023-11-27Auto merge of #117200 - rmehri01:repeated_help, r=WaffleLapkinbors-1/+0
Don't add redundant help for object safety violations Fixes #117186 r? WaffleLapkin
2023-11-26don't add redundant help for object safety violationsRyan Mehri-1/+0
2023-11-24Show number in error message even for one errorNilstrieb-24/+24
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-10-29On object safety error, mention new enum as alternativeEsteban Küber-0/+1
When we encounter a `dyn Trait` that isn't object safe, look for its implementors. If there's one, mention using it directly If there are less than 9, mention the possibility of creating a new enum and using that instead. Account for object unsafe `impl Trait on dyn Trait {}`. Make a distinction between public and sealed traits. Fix #80194.
2023-10-25Rollup merge of #116401 - WaffleLapkin:vtablin''', r=oli-obkMatthias Krüger-2/+5
Return multiple object-safety violation errors and code improvements to the object-safety check See individual commits for more information. Split off of #114260, since it turned out that the main intent of that PR was wrong. r? oli-obk
2023-10-25Return multiple object-safety violation errorsMaybe Waffle-2/+5
2023-10-25Work around the fact that `check_mod_type_wf` may spuriously return ↵Oli Scherer-0/+25
`ErrorGuaranteed`, even if that error is only emitted by `check_modwitem_types`
2023-10-15place evaluation: require the original pointer to be aligned if an access ↵Ralf Jung-2/+3
happens