Skip to content

Commit afd7ea8

Browse files
committed
update tests and add relevant feature gate test
1 parent e1a8d32 commit afd7ea8

12 files changed

+124
-33
lines changed

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
11641164
let parent_id = tcx.hir().get_parent_item(hir_id);
11651165
Some(tcx.hir().local_def_id(parent_id).to_def_id())
11661166
}
1167-
// FIXME(#43408) always enable this once we use `lazy_normalization` is
1167+
// FIXME(#43408) always enable this once `lazy_normalization` is
11681168
// stable enough and does not need a feature gate anymore.
11691169
Node::AnonConst(_) => {
11701170
let parent_id = tcx.hir().get_parent_item(hir_id);
@@ -1193,7 +1193,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
11931193
}
11941194
}
11951195
}
1196-
11971196
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => {
11981197
Some(tcx.closure_base_def_id(def_id))
11991198
}

src/test/ui/const-generics/array-size-in-generic-struct-param.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ LL | arr: [u8; CFG.arr_size],
2929
|
3030
= note: this may fail depending on what value the parameter takes
3131

32-
error: aborting due to 2 previous errors; 1 warning emitted
32+
error: aborting due to 2 previous errors; 2 warnings emitted
3333

src/test/ui/const-generics/issues/issue-61336-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | #![feature(lazy_normalization_consts)]
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1515

1616
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
17-
--> $DIR/issue-61336-2.rs:9:5
17+
--> $DIR/issue-61336-2.rs:11:5
1818
|
1919
LL | [x; { N }]
2020
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@@ -25,6 +25,6 @@ help: consider restricting type parameter `T`
2525
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
2626
| ^^^^^^^^^^^^^^^^^^^
2727

28-
error: aborting due to previous error; 1 warning emitted
28+
error: aborting due to previous error; 2 warnings emitted
2929

3030
For more information about this error, try `rustc --explain E0277`.

src/test/ui/const-generics/issues/issue-61336.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | #![feature(lazy_normalization_consts)]
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1515

1616
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
17-
--> $DIR/issue-61336.rs:9:5
17+
--> $DIR/issue-61336.rs:11:5
1818
|
1919
LL | [x; N]
2020
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@@ -25,6 +25,6 @@ help: consider restricting type parameter `T`
2525
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
2626
| ^^^^^^^^^^^^^^^^^^^
2727

28-
error: aborting due to previous error; 1 warning emitted
28+
error: aborting due to previous error; 2 warnings emitted
2929

3030
For more information about this error, try `rustc --explain E0277`.

src/test/ui/const-generics/issues/issue-61747.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ LL | #![feature(const_generics)]
77
= note: `#[warn(incomplete_features)]` on by default
88
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
99

10-
<<<<<<< HEAD
11-
warning: 1 warning emitted
12-
=======
1310
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
1411
--> $DIR/issue-61747.rs:5:12
1512
|
1613
LL | #![feature(lazy_normalization_consts)]
1714
| ^^^^^^^^^^^^^^^^^^^^^^^^^
18-
>>>>>>> Added `lazy_normalization_consts` feature, and removed the -Z flag.
15+
16+
warning: 2 warnings emitted
1917

src/test/ui/const-generics/issues/issue-61935.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ warning: the feature `lazy_normalization_consts` is incomplete and may cause the
1212
LL | #![feature(lazy_normalization_consts)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1414

15+
warning: 2 warnings emitted
16+

src/test/ui/const-generics/issues/issue-66205.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: constant expression depends on a generic parameter
2-
--> $DIR/issue-66205.rs:5:12
2+
--> $DIR/issue-66205.rs:6:12
33
|
44
LL | fact::<{ N - 1 }>();
55
| ^^^^^^^^^

src/test/ui/const-generics/issues/issue-67185-1.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ warning: the feature `lazy_normalization_consts` is incomplete and may cause the
1212
LL | #![feature(lazy_normalization_consts)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1414

15+
warning: 2 warnings emitted
16+

src/test/ui/const-generics/issues/issue-67185-2.stderr

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ LL | | }
5151
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
5252
--> $DIR/issue-67185-2.rs:27:6
5353
|
54+
LL | trait Foo
55+
| --- required by a bound in this
56+
...
57+
LL | <u8 as Baz>::Quaks: Bar,
58+
| --- required by this bound in `Foo`
59+
...
5460
LL | impl Foo for FooImpl {}
5561
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
5662
|
@@ -61,6 +67,12 @@ LL | impl Foo for FooImpl {}
6167
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
6268
--> $DIR/issue-67185-2.rs:27:6
6369
|
70+
LL | trait Foo
71+
| --- required by a bound in this
72+
...
73+
LL | [<u8 as Baz>::Quaks; 2]: Bar,
74+
| --- required by this bound in `Foo`
75+
...
6476
LL | impl Foo for FooImpl {}
6577
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
6678
|
@@ -71,17 +83,14 @@ LL | impl Foo for FooImpl {}
7183
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
7284
--> $DIR/issue-67185-2.rs:31:14
7385
|
74-
LL | / trait Foo
75-
LL | |
76-
LL | | where
77-
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
78-
LL | | <u8 as Baz>::Quaks: Bar,
79-
LL | | {
80-
LL | | }
81-
| |_- required by `Foo`
86+
LL | trait Foo
87+
| --- required by a bound in this
88+
...
89+
LL | [<u8 as Baz>::Quaks; 2]: Bar,
90+
| --- required by this bound in `Foo`
8291
...
83-
LL | fn f(_: impl Foo) {}
84-
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
92+
LL | fn f(_: impl Foo) {}
93+
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
8594
|
8695
= help: the following implementations were found:
8796
<[[u16; 3]; 3] as Bar>
@@ -90,22 +99,19 @@ LL | fn f(_: impl Foo) {}
9099
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
91100
--> $DIR/issue-67185-2.rs:31:14
92101
|
93-
LL | / trait Foo
94-
LL | |
95-
LL | | where
96-
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
97-
LL | | <u8 as Baz>::Quaks: Bar,
98-
LL | | {
99-
LL | | }
100-
| |_- required by `Foo`
102+
LL | trait Foo
103+
| --- required by a bound in this
104+
...
105+
LL | <u8 as Baz>::Quaks: Bar,
106+
| --- required by this bound in `Foo`
101107
...
102-
LL | fn f(_: impl Foo) {}
103-
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
108+
LL | fn f(_: impl Foo) {}
109+
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
104110
|
105111
= help: the following implementations were found:
106112
<[[u16; 3]; 3] as Bar>
107113
<[u16; 4] as Bar>
108114

109-
error: aborting due to 6 previous errors
115+
error: aborting due to 6 previous errors; 2 warnings emitted
110116

111117
For more information about this error, try `rustc --explain E0277`.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// run-pass
2+
#![feature(const_generics)]
3+
#![feature(lazy_normalization_consts)]
4+
#![allow(incomplete_features)]
5+
trait Foo {}
6+
7+
impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
8+
9+
trait FooImpl<const IS_ZERO: bool> {}
10+
11+
impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {}
12+
13+
impl<const N: usize> FooImpl<{ 0u8 != 0u8 }> for [(); N] {}
14+
15+
fn foo<T: Foo>(_: T) {}
16+
17+
fn main() {
18+
foo([]);
19+
foo([()]);
20+
}

0 commit comments

Comments
 (0)