about summary refs log tree commit diff
path: root/src/test/ui/const-generics
AgeCommit message (Collapse)AuthorLines
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
2021-06-12Auto merge of #86130 - BoxyUwU:abstract_const_as_cast, r=oli-obkbors-0/+279
const_eval_checked: Support as casts in abstract consts
2021-06-12Rollup merge of #86205 - JohnTitor:full-test-for-72293, r=oli-obkYuki Okushi-11/+17
Run full const-generics test for issue-72293 Closes #72293 r? ```@oli-obk```
2021-06-12Rollup merge of #85800 - BoxyUwU:const-param-default-diagnostics, r=oli-obkYuki Okushi-12/+40
Fix some diagnostic issues with const_generics_defaults feature gate This PR makes a few changes: - print out const param defaults in "lifetime ordering" errors rather than discarding them - update `is_simple_text` to account for const params when checking if a type has no generics, this was causing a note to be failed to add to an error message - fixes some diagnostic wording that incorrectly said there was ordering restrictions between type/const params despite the `const_generics_defaults` feature gate is active
2021-06-11Run full const-generics test for issue-72293Yuki Okushi-11/+17
2021-06-10support `as _` and add testsEllen-2/+217
2021-06-09Add more tests + visit_ty in some placesEllen-5/+37
2021-06-08Support as casts in abstract constsEllen-0/+32
2021-06-07note :sparkles: uwuuuEllen-8/+13
2021-06-06Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-seYuki Okushi-14/+14
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue #84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? ```@m-ou-se```
2021-06-02Replace IntoIter::new with IntoIterator::into_iter in stdMuhammad Mominul Huque-14/+14
2021-06-01Add test for forward declared const param defaultsEllen-0/+42
2021-05-29Fix missing note on type mismatch error diagnosticsEllen-4/+14
2021-05-29Make lifetime ordering error pretty print const param defaultsEllen-2/+15
2021-05-28const eval errors: display the current item instance if there are generics ↵Rémy Rakic-8/+9
involved
2021-05-25Auto merge of #85481 - lcnr:const-equate, r=matthewjasperbors-3/+46
deal with `const_evaluatable_checked` in `ConstEquate` Failing to evaluate two constants which do not contain inference variables should not result in ambiguity.
2021-05-19deal with `const_evaluatable_checked` in `ConstEquate`lcnr-3/+46
2021-05-18Rollup merge of #85251 - BoxyUwU:constparamdefaultsany%, r=lcnrRalf Jung-9/+2
Make `const_generics_defaults` not an incomplete feature r? `@lcnr`
2021-05-13wowEllen-2/+2
2021-05-13completion uwuEllen-7/+0