about summary refs log tree commit diff
path: root/tests/ui/const-generics
AgeCommit message (Collapse)AuthorLines
2023-06-02Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errorsbors-83/+227
Rollup of 7 pull requests Successful merges: - #111670 (Require that const param tys implement `ConstParamTy`) - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…) - #112030 (Migrate `item_trait_alias` to Askama) - #112150 (Support 128-bit atomics on all x86_64 Apple targets) - #112174 (Fix broken link) - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.) - #112193 (Check tuple elements are `Sized` in `offset_of`) Failed merges: - #112071 (Group rfcs tests) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-01Implement custom diagnostic for ConstParamTyMichael Goulet-80/+209
2023-06-01Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait tooMichael Goulet-3/+18
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-2/+2
2023-05-31Adjust tests for newly uplifted cast_ref_to_mut lintUrgau-2/+11
2023-05-27Rollup merge of #111991 - BoxyUwU:change_error_term_display, r=compiler-errorsMatthias Krüger-4/+4
Change ty and const error's pretty printing to be in braces `[const error]` and `[type error]` are slightly confusing since they look like either a slice with an error type for the element ty or a slice with a const argument as the type ???. This PR changes them to display as `{const error}` and `{type error}` similar to `{integer}`. This does not update the `Debug` impls for them which is done in #111988. I updated some error logic to avoid printing the substs of trait refs when unable to resolve an assoc item for them, this avoids emitting errors with `{type error}` in them. The substs are not relevant for these errors since we don't take into account the substs when resolving the assoc item. r? ``@compiler-errors``
2023-05-26print const and type errors in braces not square bracketsBoxy-4/+4
2023-05-26Blesses UI tests, add known bug to typeid-equality-by-subtypingonestacked-4/+17
2023-05-17Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwUDylan DPC-2/+82
Add derive for `core::marker::ConstParamTy` This makes it easier to implement it for a type, just like `Copy`. `@BoxyUwU` half asked me to add it
2023-05-16Add derive for `core::marker::ConstParamTy`Nilstrieb-2/+82
This makes it easier to implement it for a type, just like `Copy`.
2023-05-12Note base types of coercionMichael Goulet-2/+2
2023-05-09Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillotMatthias Krüger-382/+431
Various changes to name resolution of anon consts Sorry this PR is kind of all over the place ^^' Fixes #111012 - Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments) - Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy` - Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993 - Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters - Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)` I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands. r? `@cjgillot` cc `@compiler-errors`
2023-05-05improve diagnostics and bless testsBoxy-382/+431
2023-05-05Stabilize const_ptr_readbors-1/+1
2023-05-04Rollup merge of #111100 - BoxyUwU:array_repeat_expr_wf, r=compiler-errorsMatthias Krüger-2/+20
check array type of repeat exprs is wf Fixes #111091 Also makes sure that we actually renumber regions in the length of repeat exprs which we previously weren't doing and would cause ICEs in `adt_const_params` + `generic_const_exprs` from attempting to prove the wf goals when the length was an unevaluated constant with `'erased` in the `ty` field of `Const` The duplicate errors are caused by the fact that `const_arg_to_const`/`array_len_to_const` in `FnCtxt` adds a `WellFormed` goal for the created `Const` which is also checked by the added `WellFormed(array_ty)`. I don't want to change this to just emit a `T: Sized` goal for the element type since that would ignore `ConstArgHasType` wf requirements and generally uncomfortable with the idea of trying to sync up `wf::obligations` for arrays and the code in hir typeck for repeat exprs. r? `@compiler-errors`
2023-05-04check array type of repeat exprs is wfBoxy-2/+20
2023-05-04Rollup merge of #111103 - BoxyUwU:normal_fold_with_gce_norm, r=compiler-errorsMatthias Krüger-11/+13
correctly recurse when expanding anon consts recursing with `super_fold_with` is wrong in case `bac` is itself normalizable, the test that was supposed to test for this being wrong did not actually test for this in reality because of the usage of `{ (N) }` instead of `{{ N }}`. The former resulting in a simple `ConstKind::Param` instead of `ConstKind::Unevaluated`. Tbh generally this test seems very brittle and it will be a lot easier to test once we have normalization of assoc consts since then we can just test that `T::ASSOC` normalizes to some `U::OTHER` which normalizes to some third thing. r? `@compiler-errors`
2023-05-03rustc_middle: Fix `opt_item_ident` for non-local def idsVadim Petrochenkov-0/+6
2023-05-02correctly recurse when expanding anon constsBoxy-11/+13
2023-05-02Rollup merge of #110512 - ↵Dylan DPC-2/+15
compiler-errors:fix-elaboration-with-associated-type-bounds, r=spastorino Fix elaboration with associated type bounds When computing a trait's supertrait predicates, do not add any associated type *trait* bounds to that list of supertrait predicates. This is because supertrait predicates are expected to have the same `Self` type as the trait. For example, given: ```rust trait Foo: Bar<Assoc: Send> ``` Before, we would compute that the supertrait predicates of `T: Foo` are `T: Bar` and `<T as Bar>::Assoc: Send`. However, the last bound is a trait predicate for a totally different type than `T`, and existing code that uses supertrait bounds such as vtable construction, closure fn signature deduction, etc. all rely on the invariant that we have a list of predicates for self type `T`. Fixes #76593 The reason for all the extra diagnostic noise is that we're recomputing predicates with a different filter now. These diagnostics should be deduplicated for any end-user though. --- This does bring up an interesting question -- is the predicate `<T as Bar>::Assoc: Send` an implied bound of `T: Foo`? Because currently the only bounds implied by a (non-alias) trait are its supertraits. I guess I could fix this too, but it would require even more changes, and I'm inclined to punt this question along.
2023-05-02Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwUDylan DPC-1/+285
Add `ConstParamTy` trait This is a bit sketch, but idk. r? `@BoxyUwU` Yet to be done: - [x] ~~Figure out if it's okay to implement `StructuralEq` for primitives / possibly remove their special casing~~ (it should be okay, but maybe not in this PR...) - [ ] Maybe refactor the code a little bit - [x] Use a macro to make impls a bit nicer Future work: - [ ] Actually™ use the trait when checking if a `const` generic type is allowed - [ ] _Really_ refactor the surrounding code - [ ] Refactor `marker.rs` into multiple modules for each "theme" of markers
2023-05-01Don't use implied trait predicates in gather_explicit_predicates_ofMichael Goulet-2/+15
2023-04-28fixup tests wrt new normalizationMaybe Waffle-1/+5
2023-04-27--bless `ConstParamTy` ui testsMaybe Waffle-3/+3
2023-04-27Add `ConstParamTy` testsMaybe Waffle-0/+198
2023-04-27Add a test for `[NotParam; 0]: ConstParamTy` (not holding)Maybe Waffle-0/+28
2023-04-27Add `!StructuralEq` test for `ConstParamTy`Maybe Waffle-0/+29
2023-04-27Rename/move a testMaybe Waffle-1/+1
2023-04-27Remove `feature(const_param_ty_trait)`, use `adt_const_params` insteadMaybe Waffle-2/+3
2023-04-27`derive(Eq)` in a testMaybe Waffle-2/+2
2023-04-27Add a `ConstParamTy` traitMaybe Waffle-0/+24
2023-04-25vars are ?Michael Goulet-8/+8
2023-04-16fix library and rustdoc testsDeadbeef-6/+8
2023-04-12Special-case item attributes in the suggestion outputEsteban Küber-5/+0
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-4/+9
2023-04-08Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naberbors-0/+345
Add ability to transmute (somewhat) with generic consts in arrays Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted. This is done by normalizing the forms of expressions into sorted order of multiplied terms, which is not generic over all expressions, but should handle most cases. This allows for some _basic_ transmutations between types that are equivalent in size without requiring additional stack space at runtime. I only see one other location at which `SizeSkeleton` is being used, and it checks for equality so this shouldn't affect anywhere else that I can tell. See [this Stackoverflow post](https://stackoverflow.com/questions/73085012/transmute-nested-const-generic-array-rust) for what was previously necessary to convert between types. This PR makes converting nested `T -> [T; 1]` transmutes possible, and `[uB*2; N] -> [uB; N * 2]` possible as well. I'm not sure whether this is something that would be wanted, and if it is it definitely should not be insta-stable, so I'd add a feature gate.
2023-04-07Add feature gatekadmin-10/+187
2023-04-07update tests/uiickk-1/+1
2023-04-04Add ability to transmute with generic constskadmin-0/+168
Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted.
2023-03-28Move const trait bounds checks to MIR constckDeadbeef-2/+18
Fixes #109543. When checking paths in HIR typeck, we don't want to check for const predicates since all we want might just be a function pointer. Therefore we move this to MIR constck and check that bounds are met during MIR constck.
2023-03-27Bless tidyMaybe Waffle-1/+1
2023-03-23Note type mismatch on ConstArgHasTypeMichael Goulet-1/+1
2023-03-23Refine error spans for const args in hir typeckMichael Goulet-6/+6
2023-03-23Rollup merge of #109380 - Randl:patch-1, r=oli-obkMatthias Krüger-0/+52
add `known-bug` test for unsoundness issue Test for https://github.com/rust-lang/rust/issues/97156
2023-03-21Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwUMatthias Krüger-0/+22
Constrain const vars to error if const types are mismatched When equating two consts of different types, if either are const variables, constrain them to the correct const error kind. This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection. Fixes #109296 The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message... r? `@BoxyUwU`
2023-03-20Add `known-bug` test for typeid unsoundness issueEvgenii Zheltonozhskii-0/+52
2023-03-19Only expect a GAT const argMichael Goulet-0/+29
2023-03-19Constrain const vars to error if const types are mismatchedMichael Goulet-0/+22
2023-03-18Rollup merge of #107416 - czzrr:issue-80618, r=GuillaumeGomezMatthias Krüger-17/+18
Error code E0794 for late-bound lifetime parameter error. This PR addresses [#80618](https://github.com/rust-lang/rust/issues/80618).
2023-03-09Use param's real type in try_eval_lit_or_paramMichael Goulet-15/+19