summary refs log tree commit diff
path: root/src/test/ui/const-generics
AgeCommit message (Collapse)AuthorLines
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-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
2021-05-13Auto merge of #85041 - mibac138:suggest-generics, r=estebankbors-2/+20
Suggest adding a type parameter for impls Add a new suggestion upon encountering an unknown type in a `impl` that suggests adding a new type parameter. This diagnostic suggests to add a new type parameter even though it may be a const parameter, however after adding the parameter and running rustc again a follow up error steers the user to change the type parameter to a const parameter. ```rust struct X<const C: ()>(); impl X<C> {} ``` suggests ``` error[E0412]: cannot find type `C` in this scope --> bar.rs:2:8 | 1 | struct X<const C: ()>(); | ------------------------ similarly named struct `X` defined here 2 | impl X<C> {} | ^ | help: a struct with a similar name exists | 2 | impl X<X> {} | ^ help: you might be missing a type parameter | 2 | impl<C> X<C> {} | ^^^ ``` After adding a type parameter the code now becomes ```rust struct X<const C: ()>(); impl<C> X<C> {} ``` and the error now fully steers the user towards the correct code ``` error[E0747]: type provided when a constant was expected --> bar.rs:2:11 | 2 | impl<C> X<C> {} | ^ | help: consider changing this type parameter to be a `const` generic | 2 | impl<const C: ()> X<C> {} | ^^^^^^^^^^^ ``` r? `@estebank` Somewhat related #84946
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-7/+7
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-11improve diagnosts for GATsb-naber-31/+31
2021-05-07Fix impl type parameter suggestion involving constsmibac138-2/+2
2021-05-05Suggest adding a type parameter for implsmibac138-2/+20
2021-05-04Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakisbors-10/+13
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021 This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition. r? `@estebank`
2021-05-03Rollup merge of #84784 - JulianKnodt:suggest_const, r=lcnrDylan DPC-0/+24
Add help message to suggest const for unused type param r? `@lcnr`
2021-05-01Add help message for unused type paramkadmin-0/+24
2021-05-01Auto merge of #84410 - BoxyUwU:blue, r=varkorbors-0/+39
Fix generic arg mismatch errors being ignored with explicit late bound lifetimes Fixes #83466 r? `@varkor`
2021-05-01test: *sneezes*Ellen-0/+39
2021-04-27Rename a test for consistencyYuki Okushi-0/+0
2021-04-27Add a regression test for issue-84408Yuki Okushi-0/+38
2021-04-21supply substs to anon consts in defaultslcnr-49/+37
2021-04-21improve wf check for const param defaultslcnr-5/+54
2021-04-21loosen ordering restricts for `const_generics_defaults`lcnr-76/+132