about summary refs log tree commit diff
path: root/tests/ui/const-generics
AgeCommit message (Collapse)AuthorLines
2024-06-04Rollup merge of #125608 - oli-obk:subsequent_lifetime_errors, r=BoxyUwU许杰友 Jieyou Xu (Joe)-18/+2
Avoid follow-up errors if the number of generic parameters already doesn't match fixes #125604 best reviewed commit-by-commit
2024-06-03Make WHERE_CLAUSES_OBJECT_SAFETY a regular object safety violationMichael Goulet-15/+25
2024-06-03Mark all missing generic args as errorsOli Scherer-18/+2
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-6/+6
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-6/+6
2024-05-29Partially implement `ConstArgHasType`Boxy-183/+109
2024-05-28Allow type_of to return partially non-error types if the type was already ↵Oli Scherer-4/+31
tainted
2024-05-27remove fixed crashes, add fixed crashes to tests, add new cashed found in ↵Matthias Krüger-1/+153
the meantime
2024-05-25Rollup merge of #125451 - oli-obk:const_type_mismatch, r=compiler-errorsMatthias Krüger-23/+26
Fail relating constants of different types fixes #121585 fixes #121858 fixes #124151 I gave this several attempts before, but we lost too many important diagnostics until I managed to make compilation never bail out early. We have reached this point, so now we can finally fix all those ICEs by bubbling up an error instead of continueing when we encounter a bug.
2024-05-24Actually just remove the special case altogetherMichael Goulet-0/+24
2024-05-24Use regular type equating instead of a custom queryOli Scherer-1/+15
2024-05-24Fail relating constants of different typesOli Scherer-22/+11
2024-05-14only find segs chain for missing methods when no available candidatesbohan-0/+34
2024-04-28add test for ice ↵Matthias Krüger-0/+91
expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr Fixes https://github.com/rust-lang/rust/issues/113776
2024-04-28add test for const generic ty's with lifetimes cause opaque types to ICEMatthias Krüger-0/+29
Fixes https://github.com/rust-lang/rust/issues/111911
2024-04-28add test for ICE failed to resolve instance for <[f32; 2] as CrossProductMatthias Krüger-0/+18
Fixes https://github.com/rust-lang/rust/issues/111667
2024-04-28add test for Inconsistent rustc_transmute::is_transmutable(...) result, got YesMatthias Krüger-0/+71
Fixes https://github.com/rust-lang/rust/issues/110969
2024-04-24Fix tests and blessGary Guo-6/+5
2024-04-23Rollup merge of #122591 - gurry:122162-impl-type-binding-suggestion, r=fmeaseLeón Orell Valerian Liehr-0/+10
Suggest using type args directly instead of equality constraint When type arguments are written erroneously using an equality constraint we suggest specifying them directly without the equality constraint. Fixes #122162 Changes the diagnostic in the issue from: ```rust error[E0229]: associated type bindings are not allowed here 9 | impl std::cmp::PartialEq<Rhs = T> for S { | ^^^^^^^ associated type not allowed here | ``` to ```rust error[E0229]: associated type bindings are not allowed here 9 | impl std::cmp::PartialEq<Rhs = T> for S { | ^^^^^^^ associated type not allowed here | help: to use `T` as a generic argument specify it directly | | impl std::cmp::PartialEq<T> for S { | ~ ```
2024-04-21add test for ICE caused by using feature(generic_const_exprs) #114463Matthias Krüger-0/+29
Fixes #114463
2024-04-19add test for #83993Matthias Krüger-0/+47
Fixes #83993
2024-04-16Don't ICE for kind mismatches during error renderingOli Scherer-0/+63
2024-04-16Emit suggestions when equality constraints are wrongly usedGurinder Singh-0/+10
2024-04-11Rollup merge of #123704 - estebank:diag-changes, r=compiler-errorsMatthias Krüger-4/+11
Tweak value suggestions in `borrowck` and `hir_analysis` Unify the output of `suggest_assign_value` and `ty_kind_suggestion`. Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-11Rollup merge of #123703 - estebank:diag-changes-2, r=NadrierilLeón Orell Valerian Liehr-5/+5
Use `fn` ptr signature instead of `{closure@..}` in infer error 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! { | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Address #123630 (test missing).
2024-04-10Handle more cases of value suggestionsEsteban Küber-4/+11
2024-04-10Use `fn` ptr signature instead of `{closure@..}` in infer errorEsteban Küber-5/+5
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-09Tweak value suggestions in `borrowck` and `hir_analysis`Esteban Küber-2/+2
Unify the output of `suggest_assign_value` and `ty_kind_suggestion`. Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-09Further cleanup cfgs in the UI test suiteUrgau-2/+2
This commit does three things: 1. replaces (the last remaining) never true cfgs by the FALSE cfg 2. fix derive-helper-configured.rs (typo in directive) 3. and comment some current unused #[cfg_attr] (missing revisions)
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-04-04Add some regression tests for opaque types and const genericsOli Scherer-0/+170
2024-03-27Use `TraitRef::to_string` sorting in favor of `TraitRef::ord`, as the latter ↵Oli Scherer-15/+15
compares `DefId`s which we need to avoid
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-91/+258
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-22add test for #97725Matthias Krüger-1/+6
Fixes #97725
2024-03-22Rollup merge of #122863 - matthiaskrgr:teest, r=lcnrMatthias Krüger-0/+96
add more ice tests fixes #119275 fixes #113017 fixes #112824 fixes #112823 fixes #121472 fixes #110696
2024-03-22Rollup merge of #122820 - oli-obk:no_ord_def_id, r=estebankMatthias Krüger-74/+161
Stop using `<DefId as Ord>` in various diagnostic situations work towards https://github.com/rust-lang/rust/issues/90317 Reverts part of https://github.com/rust-lang/rust/pull/106281, as it sorts constants and that's problematic since it can contain `ParamConst`, which contains `DefId`s
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-21add test for #122549Matthias Krüger-0/+96
Fixes #122549
2024-03-21Sorting arbitrary constants should not be done, as it relies on `DefId` ↵Oli Scherer-74/+161
ordering, which breaks incremental compilation.