summary refs log tree commit diff
path: root/tests/ui/const-generics
AgeCommit message (Collapse)AuthorLines
2023-08-11Temporarily switch invalid_reference_casting lint to allow-by-defaultUrgau-11/+2
(cherry picked from commit f25ad54a4d0febbcb2b7e951835228b7b2320b49)
2023-08-11Rename cast_ref_to_mut lint to invalid_reference_castingUrgau-1/+1
(cherry picked from commit 3dbbf23e29516218863bda29d2983bd503e6b7fd)
2023-07-08Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillotMatthias Krüger-15/+15
Don't call `query_normalize` when reporting similar impls Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well. The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions: ``` error[E0277]: the trait bound `[X; 35]: Default` is not satisfied --> /home/gh-compiler-errors/test.rs:4:5 | 4 | <[X; 35] as Default>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: &[T] &mut [T] [T; 32] [T; core::::array::{impl#30}::{constant#0}] [T; core::::array::{impl#31}::{constant#0}] [T; core::::array::{impl#32}::{constant#0}] [T; core::::array::{impl#33}::{constant#0}] [T; core::::array::{impl#34}::{constant#0}] and 27 others ``` So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-07-04implement `ConstEvaluatable` goals in new solverlcnr-1/+13
we don't yet handle `generic_const_exprs`, someone else can do that :3
2023-06-29Fix type privacy lints error messageBryanskiy-4/+4
2023-06-29Rollup merge of #112670 - petrochenkov:typriv, r=eholkMatthias Krüger-1/+1
privacy: Type privacy lints fixes and cleanups See individual commits. Follow up to https://github.com/rust-lang/rust/pull/111801.
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-15/+15
2023-06-25Rollup merge of #112990 - JohnTitor:issue-96699, r=TaKO8KiGuillaume Gomez-0/+87
Add a regression test for #96699 Closes #96699 r? `@BoxyUwU`
2023-06-24Add a regression test for #96699Yuki Okushi-0/+87
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-24Add a regression test for #109141Yuki Okushi-0/+39
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-19Don't ICE on unnormalized struct tail in layout computationMichael Goulet-4/+4
2023-06-15privacy: Feature gate new type privacy lintsVadim Petrochenkov-1/+1
2023-06-15change `std::marker::Sized` to just `Sized`Lukas Markeffsky-2/+2
2023-06-14Rollup merge of #112506 - compiler-errors:const-infer-ice, r=b-naberMatthias Krüger-6/+6
Properly check associated consts for infer placeholders We only reported an error if it was in a "suggestable" position (according to `is_suggestable_infer_ty`) -- this isn't correct for infer tys that can show up in other places in the constant's type, like behind a dyn trait. fixes #112491
2023-06-14Rollup merge of #112520 - chenyukang:yukang-fix-112505, r=fee1-deadMatthias Krüger-0/+19
Fix the overflow issue for transmute_generic_consts Fixes #112505
2023-06-13Auto merge of #112549 - jieyouxu:fix-tests-for-unit-bindings, r=Nilstriebbors-2/+2
Adjust UI tests for `unit_bindings` lint - Explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead. - Use `let () = init;` or `let pat = ();` where appropriate. - Fix disjoint-capture-in-same-closure test which wasn't actually testing a closure: `tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs`. Note that unfortunately there's *a lot* of UI tests, there are a couple of places where I may have left something like `let (): ()` (this is not needed but is left over from an ealier version of the lint) which is bad style. This PR is to help with the `unit_bindings` lint at #112380.
2023-06-12Adjust UI tests for `unit_bindings`许杰友 Jieyou Xu (Joe)-2/+2
- Either explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead. - Fix disjoint-capture-in-same-closure test
2023-06-12Private-in-public lints implementationBryanskiy-2/+26
2023-06-11Fix the overflow issue for transmute_generic_constsyukang-0/+19
2023-06-11properly check associated consts for infer placeholdersMichael Goulet-6/+6
2023-06-08add a test for #105709Takayuki Maeda-0/+9
replace build with check Co-authored-by: Michael Goulet <michael@errs.io> use appropriate test name
2023-06-06remove `has_error_field` helper methodlcnr-25/+4
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