summary refs log tree commit diff
path: root/src/test/ui/const-generics
AgeCommit message (Collapse)AuthorLines
2021-09-03Auto merge of #88597 - cjgillot:lower-global, r=petrochenkovbors-6/+6
Move global analyses from lowering to resolution Split off https://github.com/rust-lang/rust/pull/87234 r? `@petrochenkov`
2021-09-02Rollup merge of #88592 - b-naber:region_substs, r=oli-obkMara Bos-0/+26
Fix ICE in const check Fixes https://github.com/rust-lang/rust/issues/88433
2021-09-02add testb-naber-0/+26
2021-09-01Stop sorting bodies by span.Camille GILLOT-6/+6
The definition order is already close to the span order, and only differs in corner cases.
2021-08-30`feature(const_param_types)` -> `feature(adt_const_params)`lcnr-83/+83
2021-08-30allow unordered const/ty params if any cg feature is activelcnr-2/+0
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-2743/+803
2021-08-30remove lazy_normalization_constsEllen-0/+36
2021-08-30rename const_evaluatable_checked to generic_const_exprsEllen-155/+119
:sparkles:
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-1/+0
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-16Use note to point at bound introducing requirementEsteban Küber-100/+140
2021-08-12Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylevGuillaume Gomez-1/+1
Link to edition guide instead of issues for 2021 lints. This changes the 2021 lints to not link to github issues, but to the edition guide instead. Fixes #86996
2021-08-11Modify structured suggestion outputEsteban Küber-101/+80
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-11Rollup merge of #87854 - BoxyUwU:var-None, r=oli-obkYuki Okushi-0/+24
correctly handle enum variants in `opt_const_param_of` Fixes #87542 `opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics. r? `@oli-obk`
2021-08-09Link to edition guide instead of issues for 2021 lints.Mara Bos-1/+1
2021-08-07fmtEllen-1/+1
2021-08-07less opt in const param ofEllen-0/+24
2021-08-06uwuEllen-1/+1
2021-08-06*sprinkles some dust everywhere*Ellen-1/+2
2021-08-06encode `generics_of` of fields and ty paramsEllen-0/+80
2021-08-04dropckEllen-0/+16
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-5/+5
2021-07-30Auto merge of #86754 - estebank:use-multispans-more, r=varkorbors-4/+2
Use `multipart_suggestions` more Built on top of #86532
2021-07-30Use multispan suggestions more oftenEsteban Küber-4/+2
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-30Do not discard `?Sized` type params and suggest their removalEsteban Küber-0/+13
2021-07-27Auto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnrbors-23/+13
Add hir::GenericArg::Infer In order to extend inference to consts, make an Infer type on hir::GenericArg.
2021-07-26Actually infer args in visitorskadmin-1/+2
2021-07-25Auto merge of #83723 - cjgillot:ownernode, r=petrochenkovbors-9/+9
Store all HIR owners in the same container This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem. This should allow for a more compact storage. Based on https://github.com/rust-lang/rust/pull/83114
2021-07-25Bless tests.Camille GILLOT-9/+9
2021-07-25Add generic arg inferkadmin-22/+11
2021-07-24Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakisbors-0/+96
dont provide fwd declared params to cg defaults Fixes #83938 ```rust #![feature(const_evaluatable_checked, const_generics, const_generics_defaults)] #![allow(incomplete_features)] pub struct Bar<const N: usize, const M: usize = { N + 1 }>; pub fn foo<const N1: usize>() -> Bar<N1> { loop {} } fn main() {} ``` This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for `Bar<N1>` we would subst the anon ct: `ConstKind::Unevaluated({N + 1}, substs: [N, M])` with substs of `[N1]`. the anon const has forward declared params supplied though so we end up trying to substitute the provided `M` param which causes the ICE. This PR doesn't handle the predicates of the const so ```rust trait Foo<const N: usize> { const Assoc: usize; } pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>; ``` Resolves to `<() as Foo<N>>::Assoc` which can allow for using fwd declared params indirectly. ```rust trait Foo<const N: usize> {} struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>; ``` This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params PR was briefly discussed [in this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/evil.20preds.20in.20param.20env.20.2386580)
2021-07-24Rollup merge of #87266 - hellow554:issue87076, r=Mark-SimulacrumYuki Okushi-0/+20
Add testcase for 87076 Closes #87076 I also moved the issue tests into the issues subfolder, nothing changed there.
2021-07-20Support HIR wf checking for function signaturesAaron Hill-2/+2
During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-19Auto merge of #87225 - estebank:cleanup, r=oli-obkbors-15/+24
Various diagnostics clean ups/tweaks * Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-15/+24
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19move const-generic issues into seperate directoryMarcel Hellwig-0/+0
2021-07-19add testcase for 87076Marcel Hellwig-0/+20
using https://github.com/rust-lang/rust/issues/87076#issuecomment-878090143 as testcase
2021-07-18Rollup merge of #86843 - FabianWolff:issue-86820, r=lcnrYuki Okushi-0/+40
Check that const parameters of trait methods have compatible types This PR fixes #86820. The problem is that this currently passes the type checker: ```rust trait Tr { fn foo<const N: u8>(self) -> u8; } impl Tr for f32 { fn foo<const N: bool>(self) -> u8 { 42 } } ``` i.e. the type checker fails to check whether const parameters in `impl` methods have the same type as the corresponding declaration in the trait. With my changes, I get, for the above code: ``` error[E0053]: method `foo` has an incompatible const parameter type for trait --> test.rs:6:18 | 6 | fn foo<const N: bool>(self) -> u8 { 42 } | ^ | note: the const parameter `N` has type `bool`, but the declaration in trait `Tr::foo` has type `u8` --> test.rs:2:18 | 2 | fn foo<const N: u8>(self) -> u8; | ^ error: aborting due to previous error ``` This fixes #86820, where an ICE happens later on because the trait method is declared with a const parameter of type `u8`, but the `impl` uses one of type `usize`: > `expected int of size 8, but got size 1`
2021-07-16Check that const parameters of trait methods have compatible typesFabian Wolff-0/+40
2021-07-14OOPSEllen-9/+9
2021-07-14Change type param -> generic paramEllen-0/+37
2021-07-10redo testsEllen-31/+96
2021-07-10Moves changes to explicit_preds_of/inferred_outlives_of/generics_ofEllen-1/+10
2021-07-10Dont provide all parent generics to cgdefaultsEllen-0/+22
2021-07-08only check cg defaults wf once instantiatedlcnr-23/+10
2021-07-03Fix const-generics ICE related to bindingYuki Okushi-0/+142
2021-06-29Bless UI testsFabian Wolff-0/+2
2021-06-25Address PR feedbackRyan Levick-2/+2
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-2/+2
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-2/+2