forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#74000 - lcnr:lazy_normalisation_consts, r=v…
…arkor add `lazy_normalization_consts` feature gate In rust-lang#71973 I underestimated the amount of code which is influenced by lazy normalization of consts and decided against having a separate feature flag for this. Looking a bit more into this, the following issues are already working with lazy norm in its current state rust-lang#47814 rust-lang#57739 rust-lang#73980 I therefore think it is worth it to enable lazy norm separately. Note that `#![feature(const_generics)]` still automatically activates this feature, so using `#![feature(const_generics, lazy_normalization_consts)]` is redundant. r? @varkor @nikomatsakis
- Loading branch information
Showing
10 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pub const fn sof<T>() -> usize { | ||
10 | ||
} | ||
|
||
fn test<T>() { | ||
let _: [u8; sof::<T>()]; | ||
//~^ ERROR the size for values of type `T` | ||
} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0277]: the size for values of type `T` cannot be known at compilation time | ||
--> $DIR/feature-gate-lazy_normalization_consts.rs:6:23 | ||
| | ||
LL | pub const fn sof<T>() -> usize { | ||
| - required by this bound in `sof` | ||
... | ||
LL | fn test<T>() { | ||
| - this type parameter needs to be `std::marker::Sized` | ||
LL | let _: [u8; sof::<T>()]; | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `std::marker::Sized` is not implemented for `T` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
help: consider relaxing the implicit `Sized` restriction | ||
| | ||
LL | pub const fn sof<T: ?Sized>() -> usize { | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// check-pass | ||
#![feature(lazy_normalization_consts)] | ||
#![allow(incomplete_features)] | ||
pub struct ArpIPv4<'a> { | ||
_s: &'a u8 | ||
} | ||
|
||
impl<'a> ArpIPv4<'a> { | ||
const LENGTH: usize = 20; | ||
|
||
pub fn to_buffer() -> [u8; Self::LENGTH] { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(lazy_normalization_consts)] | ||
//~^ WARN the feature `lazy_normalization_consts` is incomplete | ||
trait ArraySizeTrait { | ||
const SIZE: usize = 0; | ||
} | ||
|
||
impl<T: ?Sized> ArraySizeTrait for T { | ||
const SIZE: usize = 1; | ||
} | ||
|
||
struct SomeArray<T: ArraySizeTrait> { | ||
array: [u8; T::SIZE], | ||
//~^ ERROR constant expression depends on a generic parameter | ||
phantom: std::marker::PhantomData<T>, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
warning: the feature `lazy_normalization_consts` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-57739.rs:1:12 | ||
| | ||
LL | #![feature(lazy_normalization_consts)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information | ||
|
||
error: constant expression depends on a generic parameter | ||
--> $DIR/issue-57739.rs:12:5 | ||
| | ||
LL | array: [u8; T::SIZE], | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// check-pass | ||
#![feature(lazy_normalization_consts)] | ||
#![allow(incomplete_features)] | ||
|
||
pub struct X<P, Q>(P, Q); | ||
pub struct L<T: ?Sized>(T); | ||
|
||
impl<T: ?Sized> L<T> { | ||
const S: usize = 1; | ||
} | ||
|
||
impl<T> X<T, [u8; L::<T>::S]> {} | ||
|
||
fn main() {} |