-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
lazy_normalization_consts
feature gate
- 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() {} |