Commit graph

314 commits

Author SHA1 Message Date
bors
3bb5a863c8 Auto merge of #74005 - estebank:type-ascription-redux, r=petrochenkov
Clean up errors in typeck and resolve

* Tweak ordering of suggestions
* Do not suggest similarly named enclosing item
* Point at item definition in foreign crates
* Add missing primary label

CC #34255.
2020-08-10 23:50:39 +00:00
Esteban Küber
089810a1cb Do not suggest similarly named enclosing item 2020-08-10 12:04:10 -07:00
kadmin
64f6437822 Convert Eq impl to check Ord::Equal 2020-08-10 05:54:55 +00:00
kadmin
be0d6f1c06 Change Ord impl for ParamKindOrd
Updated tests and error msgs

Update stderr from test

Update w/ lcnr comments

Change some tests around, and also updated Ord implementation for ParamKindOrd

Update w/ nits from lcnr
2020-08-09 07:41:26 +00:00
kadmin
b8352eb2d1 Test lifetimes after types after consts forbidden
Added more complex test and changed error message
2020-08-09 07:41:24 +00:00
kadmin
f8588284af Added +1 test for only works w/ feat const gen
Added this test to ensure that reordering the parameters only works with the feature const
generics enabled.

Fixed nits

Also added another test to verify that intermixed lifetimes are forbidden
2020-08-09 07:41:22 +00:00
kadmin
18481cbec9 Rm restriction on ord of default types w/ consts 2020-08-08 04:40:07 +00:00
bors
f9c2177ddc Auto merge of #74877 - lcnr:min_const_generics, r=oli-obk
Implement the `min_const_generics` feature gate

Implements both https://github.com/rust-lang/lang-team/issues/37 and https://github.com/rust-lang/compiler-team/issues/332.

Adds the new feature gate `#![feature(min_const_generics)]`.
This feature gate adds the following limitations to using const generics:
- generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`)
- generic parameters must be either integers, `bool` or `char`.

We do allow arbitrary expressions in associated consts though, meaning that the following is allowed,
even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable.
```rust
trait Foo {
    const ASSOC: usize;
}

impl<const N: usize> Foo for [u8; N] {
    const ASSOC: usize = 64 / N;
}
```

r? @varkor cc @eddyb @withoutboats
2020-08-08 01:48:35 +00:00
Bastian Kauschke
644c894912 test min_const_generics using revisions 2020-08-07 07:49:48 +02:00
Bastian Kauschke
37c29adabc allow complex expressions in assoc consts 2020-08-06 22:37:20 +02:00
bors
22ee68dc58 Auto merge of #75166 - JulianKnodt:i64494, r=lcnr
Add regression test for #64494

Add regression test to indicate if this compilation ever succeeds.
Fixes #64494

r? @lcnr
2020-08-05 20:20:56 +00:00
Bastian Kauschke
0d54f571c1 impl review 2020-08-05 18:30:37 +02:00
Bastian Kauschke
188bbf840d forbid complex types for generic parameters 2020-08-05 18:30:37 +02:00
Bastian Kauschke
289e5fca7e forbid generic params in complex consts 2020-08-05 18:30:37 +02:00
kadmin
7dd1b6a22f Add regression test 2020-08-04 23:07:04 +00:00
kadmin
f338054713 Add regression test
As well as matching error outputs
2020-08-04 22:58:44 +00:00
kadmin
011e0ef636 Removed error check in order to prevent ICE 2020-07-31 21:18:39 +00:00
Yuki Okushi
157975c6c4
Rollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis
add const generics array coercion test
2020-07-29 09:24:15 +09:00
Bastian Kauschke
952fd0ce58 update tests 2020-07-27 16:41:27 +02:00
Bastian Kauschke
33a05b40f7 forbid generic params inside of anon consts in ty defaults 2020-07-27 16:33:23 +02:00
Yuki Okushi
832d0a7667
Add test for issue-56445 2020-07-26 18:54:24 +09:00
bors
461707c5a1 Auto merge of #74060 - kpp:remove_length_at_most_32, r=dtolnay
Remove trait LengthAtMost32

This is a continuation of https://github.com/rust-lang/rust/pull/74026 preserving the original burrbull's commit.

I talked to @burrbull, he suggested me to finish his PR.
2020-07-26 05:50:51 +00:00
bors
cfb6114b2a Auto merge of #74676 - lcnr:generics-no-sort, r=varkor
correctly deal with unsorted generic parameters

We now stop sorting generic params and instead correctly handle unsorted params in the rest of the compiler.

We still restrict const params to come after type params though, so this PR does not change anything which
is visible to users.

This might slightly influence perf, so let's prevent any unintentional rollups. @bors rollup=never

r? @varkor
2020-07-24 13:58:36 +00:00
Bastian Kauschke
5f1eea93a9 test usage 2020-07-23 14:30:01 +02:00
Bastian Kauschke
9910f156df add more complex param order test 2020-07-23 13:19:35 +02:00
Bastian Kauschke
49b1971263
add const generics 2020-07-23 10:55:20 +02:00
Bastian Kauschke
2f565967b0 tweak wording
Co-authored-by: varkor <github@varkor.com>
2020-07-23 08:14:39 +02:00
Bastian Kauschke
a95e6bb916 require type defaults to be after const generic parameters
as if this is currently possible. HA!
2020-07-22 22:58:54 +02:00
Gabriel Smith
c60a035658 Add test for an explicit non-'static lifetime in a const argument 2020-07-19 12:53:51 -04:00
Manish Goregaokar
1a54b61e39
Rollup merge of #74445 - lcnr:const-generic-ty-decl, r=Dylan-DPC
add test for #62878

forgot to push this as part of #74159

r? @Dylan-DPC
2020-07-18 16:50:57 -07:00
Bastian Kauschke
0bac36105e add test for #62878 2020-07-17 17:44:11 +02:00
Alex Macleod
f7979d3c93 Add regression test for #69414
Closes #69414 (no longer ICEs after #74159)
2020-07-17 15:45:50 +01:00
Manish Goregaokar
c354524254
Rollup merge of #74392 - lcnr:const-generics-update, r=varkor
const generics triage

I went through all const generics issues and closed all issues which are already fixed.

Some issues already have a regression test but were not closed. Also doing this as part of this PR.

uff r? @eddyb @varkor

closes #61936
closes #62878
closes #63695
closes #67144
closes #68596
closes #69816
closes #70217
closes #70507
closes #70586
closes #71348
closes #71805
closes #73120
closes #73508
closes #73730
closes #74255
2020-07-16 11:19:00 -07:00
Bastian Kauschke
8faeb0e797 add regression test for #74255 2020-07-16 12:46:35 +02:00
Bastian Kauschke
d187e8108b add regression test for #73730 2020-07-16 12:46:35 +02:00
Bastian Kauschke
e23095011f add regression test for #73508 2020-07-16 12:39:02 +02:00
Bastian Kauschke
09ba0bda2c add regression test for #73491 2020-07-16 12:35:53 +02:00
Bastian Kauschke
946cb11a1e add regression test for #73120 2020-07-16 12:32:43 +02:00
Bastian Kauschke
de8d2e897f add regression test for #71805 2020-07-16 12:23:38 +02:00
Bastian Kauschke
a2b18274a8 add regression test for #71348 2020-07-16 12:17:27 +02:00
Bastian Kauschke
f52039d5e8 add regression test for #71169 2020-07-16 12:14:03 +02:00
Bastian Kauschke
eee160cdea add regression test for #70586 2020-07-16 12:10:15 +02:00
Bastian Kauschke
137ca05ccd add regression test for #70217 2020-07-16 12:03:52 +02:00
Bastian Kauschke
333dce960c add regression test for #68596 2020-07-16 12:03:52 +02:00
Bastian Kauschke
e009b53df4 add regression tests for #67144 2020-07-16 11:46:39 +02:00
Bastian Kauschke
01f5dd374c bless ui tests 2020-07-16 11:40:26 +02:00
Bastian Kauschke
0c511ab5c7 update help message 2020-07-16 11:13:05 +02:00
Bastian Kauschke
6f5d8bf5c8 don't supply generics to AnonConsts in param lists 2020-07-16 11:13:05 +02:00
Bastian Kauschke
14a1031ec6 add self dependent const param test 2020-07-16 11:13:05 +02:00
Bastian Kauschke
338a27174a forbid generic params in the type of const params 2020-07-16 11:13:05 +02:00