Skip to content

Commit 443ae83

Browse files
committed
merge lazy_normalization_consts into const_generics
1 parent 479968b commit 443ae83

33 files changed

+70
-198
lines changed

src/librustc_feature/active.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ declare_features! (
559559
/// Allow negative trait implementations.
560560
(active, negative_impls, "1.44.0", Some(68318), None),
561561

562-
/// Lazily evaluate constants. Which allows constants to depend on type parameters.
563-
(active, lazy_normalization_consts, "1.44.0", Some(60471), None),
564-
565562
/// Allows the use of `#[target_feature]` on safe functions.
566563
(active, target_feature_11, "1.45.0", Some(69098), None),
567564

@@ -584,5 +581,4 @@ pub const INCOMPLETE_FEATURES: &[Symbol] = &[
584581
sym::raw_dylib,
585582
sym::const_trait_impl,
586583
sym::const_trait_bound_opt_out,
587-
sym::lazy_normalization_consts,
588584
];

src/librustc_infer/infer/combine.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,11 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
164164
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
165165
return self.unify_const_variable(!a_is_expected, vid, a);
166166
}
167-
(ty::ConstKind::Unevaluated(..), _)
168-
if self.tcx.features().lazy_normalization_consts =>
169-
{
167+
(ty::ConstKind::Unevaluated(..), _) if self.tcx.features().const_generics => {
170168
relation.const_equate_obligation(a, b);
171169
return Ok(b);
172170
}
173-
(_, ty::ConstKind::Unevaluated(..))
174-
if self.tcx.features().lazy_normalization_consts =>
175-
{
171+
(_, ty::ConstKind::Unevaluated(..)) if self.tcx.features().const_generics => {
176172
relation.const_equate_obligation(a, b);
177173
return Ok(a);
178174
}
@@ -662,9 +658,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
662658
}
663659
}
664660
}
665-
ty::ConstKind::Unevaluated(..) if self.tcx().features().lazy_normalization_consts => {
666-
Ok(c)
667-
}
661+
ty::ConstKind::Unevaluated(..) if self.tcx().features().const_generics => Ok(c),
668662
_ => relate::super_relate_consts(self, c, c),
669663
}
670664
}

src/librustc_infer/infer/nll_relate/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,7 @@ where
988988
}
989989
}
990990
}
991-
ty::ConstKind::Unevaluated(..) if self.tcx().features().lazy_normalization_consts => {
992-
Ok(a)
993-
}
991+
ty::ConstKind::Unevaluated(..) if self.tcx().features().const_generics => Ok(a),
994992
_ => relate::super_relate_consts(self, a, a),
995993
}
996994
}

src/librustc_middle/ty/relate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
432432
match relation.relate(&sz_a, &sz_b) {
433433
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
434434
// FIXME(lazy_normalization_consts) Implement improved diagnostics for mismatched array
435-
// length?
436-
Err(err) if relation.tcx().features().lazy_normalization_consts => Err(err),
435+
// length?
436+
Err(err) if relation.tcx().features().const_generics => Err(err),
437437
Err(err) => {
438438
// Check whether the lengths are both concrete/known values,
439439
// but are unequal, for better diagnostics.

src/librustc_span/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ symbols! {
411411
label_break_value,
412412
lang,
413413
lang_items,
414-
lazy_normalization_consts,
415414
let_chains,
416415
lhs,
417416
lib,

src/librustc_trait_selection/traits/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
388388
}
389389

390390
fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
391-
if self.selcx.tcx().features().lazy_normalization_consts {
391+
if self.selcx.tcx().features().const_generics {
392392
constant
393393
} else {
394394
let constant = constant.super_fold_with(self);

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
11731173
// HACK(eddyb) this provides the correct generics when
11741174
// `feature(const_generics)` is enabled, so that const expressions
11751175
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
1176-
if tcx.features().const_generics || tcx.features().lazy_normalization_consts {
1176+
if tcx.features().const_generics {
11771177
Some(parent_def_id.to_def_id())
11781178
} else {
11791179
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
<<<<<<< HEAD
12
//~^ WARN the feature `const_generics` is incomplete
23
#![feature(lazy_normalization_consts)]
34
//~^ WARN the feature `lazy_normalization_consts` is incomplete
5+
=======
6+
#![feature(const_generics)]
7+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
8+
>>>>>>> merge lazy_normalization_consts into const_generics
49

510
#[allow(dead_code)]
611
struct ArithArrayLen<const N: usize>([u32; 0 + N]);

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,21 @@ 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-
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
11-
--> $DIR/array-size-in-generic-struct-param.rs:3:12
12-
|
13-
LL | #![feature(lazy_normalization_consts)]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15-
1610
error: constant expression depends on a generic parameter
17-
--> $DIR/array-size-in-generic-struct-param.rs:7:38
11+
--> $DIR/array-size-in-generic-struct-param.rs:5:38
1812
|
1913
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
2014
| ^^^^^^^^^^^^
2115
|
2216
= note: this may fail depending on what value the parameter takes
2317

2418
error: constant expression depends on a generic parameter
25-
--> $DIR/array-size-in-generic-struct-param.rs:16:5
19+
--> $DIR/array-size-in-generic-struct-param.rs:14:5
2620
|
2721
LL | arr: [u8; CFG.arr_size],
2822
| ^^^^^^^^^^^^^^^^^^^^^^^
2923
|
3024
= note: this may fail depending on what value the parameter takes
3125

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

src/test/ui/const-generics/different_byref.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ error[E0308]: mismatched types
1313
LL | x = Const::<{ [4] }> {};
1414
| ^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `4usize`
1515
|
16-
= note: expected struct `Const<[3usize]>`
17-
found struct `Const<[4usize]>`
16+
= note: expected type `[3usize]`
17+
found type `[4usize]`
1818

1919
error: aborting due to previous error; 1 warning emitted
2020

src/test/ui/const-generics/fn-const-param-infer.stderr

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ error[E0308]: mismatched types
1111
--> $DIR/fn-const-param-infer.rs:16:31
1212
|
1313
LL | let _: Checked<not_one> = Checked::<not_two>;
14-
| ---------------- ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}`
15-
| |
16-
| expected due to this
14+
| ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}`
1715
|
18-
= note: expected struct `Checked<{not_one as fn(usize) -> bool}>`
19-
found struct `Checked<{not_two as fn(usize) -> bool}>`
16+
= note: expected type `{not_one as fn(usize) -> bool}`
17+
found type `{not_two as fn(usize) -> bool}`
2018

2119
error[E0308]: mismatched types
2220
--> $DIR/fn-const-param-infer.rs:20:24
@@ -37,12 +35,10 @@ error[E0308]: mismatched types
3735
--> $DIR/fn-const-param-infer.rs:25:40
3836
|
3937
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
40-
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}`
41-
| |
42-
| expected due to this
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}`
4339
|
44-
= note: expected struct `Checked<{generic::<u32> as fn(usize) -> bool}>`
45-
found struct `Checked<{generic::<u16> as fn(usize) -> bool}>`
40+
= note: expected type `{generic::<u32> as fn(usize) -> bool}`
41+
found type `{generic::<u16> as fn(usize) -> bool}`
4642

4743
error: aborting due to 4 previous errors; 1 warning emitted
4844

src/test/ui/const-generics/issues/issue-61336-1.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//~^ WARN the feature `const_generics` is incomplete
21
#![feature(lazy_normalization_consts)]
32
//~^ WARN the feature `lazy_normalization_consts` is incomplete
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete
45

56
// build-pass
67

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/issue-61336-1.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
9+
warning: 1 warning emitted
10+

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//~^ WARN the feature `const_generics` is incomplete
21
#![feature(lazy_normalization_consts)]
32
//~^ WARN the feature `lazy_normalization_consts` is incomplete
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete
45

56
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
67
[x; { N }]

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ 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-
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
11-
--> $DIR/issue-61336-2.rs:3:12
12-
|
13-
LL | #![feature(lazy_normalization_consts)]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15-
1610
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
17-
--> $DIR/issue-61336-2.rs:11:5
11+
--> $DIR/issue-61336-2.rs:9:5
1812
|
1913
LL | [x; { N }]
2014
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@@ -25,6 +19,6 @@ help: consider restricting type parameter `T`
2519
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
2620
| ^^^^^^^^^^^^^^^^^^^
2721

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

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

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ 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-
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
11-
--> $DIR/issue-61336.rs:3:12
12-
|
13-
LL | #![feature(lazy_normalization_consts)]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15-
1610
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
17-
--> $DIR/issue-61336.rs:11:5
11+
--> $DIR/issue-61336.rs:9:5
1812
|
1913
LL | [x; N]
2014
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@@ -25,6 +19,6 @@ help: consider restricting type parameter `T`
2519
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
2620
| ^^^^^^^^^^^^^^^^^^^
2721

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

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

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,5 @@ 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-
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
11-
--> $DIR/issue-61747.rs:5:12
12-
|
13-
LL | #![feature(lazy_normalization_consts)]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15-
16-
warning: 2 warnings emitted
10+
warning: 1 warning emitted
1711

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#![feature(const_generics)]
44
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5-
#![feature(lazy_normalization_consts)]
6-
//~^ WARN the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
75

86
trait Foo {}
97

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

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

9-
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
10-
--> $DIR/issue-61935.rs:5:12
11-
|
12-
LL | #![feature(lazy_normalization_consts)]
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
14-
15-
warning: 2 warnings emitted
9+
warning: 1 warning emitted
1610

src/test/ui/const-generics/issues/issue-62504.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ struct ArrayHolder<const X: usize>([u32; X]);
1616
impl<const X: usize> ArrayHolder<X> {
1717
pub const fn new() -> Self {
1818
ArrayHolder([0; Self::SIZE])
19-
//~^ ERROR: mismatched types
20-
//~| ERROR constant expression depends on a generic parameter
19+
//~^ ERROR constant expression depends on a generic parameter
2120
}
2221
}
2322

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/issue-62504.rs:18:21
3-
|
4-
LL | ArrayHolder([0; Self::SIZE])
5-
| ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE`
6-
|
7-
= note: expected array `[u32; X]`
8-
found array `[u32; _]`
9-
101
error: constant expression depends on a generic parameter
112
--> $DIR/issue-62504.rs:18:25
123
|
@@ -15,6 +6,5 @@ LL | ArrayHolder([0; Self::SIZE])
156
|
167
= note: this may fail depending on what value the parameter takes
178

18-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1910

20-
For more information about this error, try `rustc --explain E0308`.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#![feature(const_generics)]
44
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5-
#![feature(lazy_normalization_consts)]
6-
//~^ WARN the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
75

86
trait Baz {
97
type Quaks;

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,5 @@ LL | #![feature(const_generics)]
66
|
77
= note: `#[warn(incomplete_features)]` on by default
88

9-
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
10-
--> $DIR/issue-67185-1.rs:5:12
11-
|
12-
LL | #![feature(lazy_normalization_consts)]
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
14-
15-
warning: 2 warnings emitted
9+
warning: 1 warning emitted
1610

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(const_generics)]
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3-
#![feature(lazy_normalization_consts)]
4-
//~^ WARN the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
53

64
trait Baz {
75
type Quaks;

0 commit comments

Comments
 (0)