Auto merge of #77557 - Dylan-DPC:rollup-aib9ptp, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #75853 (Use more intra-doc-links in `core::fmt`) - #75928 (Remove trait_selection error message in specific case) - #76329 (Add check for doc alias attribute at crate level) - #77219 (core::global_allocator docs link to std::alloc::GlobalAlloc) - #77395 (BTreeMap: admit the existence of leaf edges in comments) - #77407 (Improve build-manifest to work with the improved promote-release) - #77426 (Include scope id in SocketAddrV6::Display) - #77439 (Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`) - #77471 (BTreeMap: refactoring around edges, missed spots) - #77512 (Allow `Abort` terminators in all const-contexts) - #77514 (Replace some once(x).chain(once(y)) with [x, y] IntoIter) Failed merges: r? `@ghost`
This commit is contained in:
commit
efbaa41306
116 changed files with 1643 additions and 659 deletions
6
src/test/rustdoc-ui/doc-alias-crate-level.rs
Normal file
6
src/test/rustdoc-ui/doc-alias-crate-level.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#![feature(doc_alias)]
|
||||
|
||||
#![doc(alias = "crate-level-not-working")] //~ ERROR
|
||||
|
||||
#[doc(alias = "shouldn't work!")] //~ ERROR
|
||||
pub fn foo() {}
|
||||
14
src/test/rustdoc-ui/doc-alias-crate-level.stderr
Normal file
14
src/test/rustdoc-ui/doc-alias-crate-level.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
||||
--> $DIR/doc-alias-crate-level.rs:5:7
|
||||
|
|
||||
LL | #[doc(alias = "shouldn't work!")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute
|
||||
--> $DIR/doc-alias-crate-level.rs:3:8
|
||||
|
|
||||
LL | #![doc(alias = "crate-level-not-working")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
||||
|
|
||||
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||
|
|
@ -6,7 +6,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
|||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
||||
|
|
||||
LL | arr: [u8; CFG.arr_size],
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#[allow(dead_code)]
|
||||
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct Config {
|
||||
|
|
@ -19,7 +19,7 @@ struct B<const CFG: Config> {
|
|||
//[min]~^ ERROR `Config` is forbidden
|
||||
arr: [u8; CFG.arr_size],
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||
}
|
||||
|
||||
const C: Config = Config { arr_size: 5 };
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/const-argument-if-length.rs:8:28
|
||||
|
|
||||
LL | pub const fn is_zst<T: ?Sized>() -> usize {
|
||||
| - this type parameter needs to be `Sized`
|
||||
LL | if std::mem::size_of::<T>() == 0 {
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||
|
|
||||
LL | pub const fn size_of<T>() -> usize {
|
||||
| - required by this bound in `std::mem::size_of`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-argument-if-length.rs:19:15
|
||||
|
|
||||
LL | pad: [u8; is_zst::<T>()],
|
||||
| ^^^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/const-argument-if-length.rs:17:12
|
||||
|
|
||||
LL | pub struct AtLeastByte<T: ?Sized> {
|
||||
| - this type parameter needs to be `Sized`
|
||||
LL | value: T,
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
= note: only the last field of a struct may have a dynamically sized type
|
||||
= help: change the field's type to have a statically known size
|
||||
help: borrowed types always have a statically known size
|
||||
|
|
||||
LL | value: &T,
|
||||
| ^
|
||||
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
||||
|
|
||||
LL | value: Box<T>,
|
||||
| ^^^^ ^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0080, E0277.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/const-argument-if-length.rs:19:24
|
||||
|
|
||||
LL | pad: [u8; is_zst::<T>()],
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/const-argument-if-length.rs:17:12
|
||||
|
|
||||
LL | pub struct AtLeastByte<T: ?Sized> {
|
||||
| - this type parameter needs to be `Sized`
|
||||
LL | value: T,
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
= note: only the last field of a struct may have a dynamically sized type
|
||||
= help: change the field's type to have a statically known size
|
||||
help: borrowed types always have a statically known size
|
||||
|
|
||||
LL | value: &T,
|
||||
| ^
|
||||
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
||||
|
|
||||
LL | value: Box<T>,
|
||||
| ^^^^ ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
24
src/test/ui/const-generics/const-argument-if-length.rs
Normal file
24
src/test/ui/const-generics/const-argument-if-length.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
pub const fn is_zst<T: ?Sized>() -> usize {
|
||||
if std::mem::size_of::<T>() == 0 {
|
||||
//[full]~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AtLeastByte<T: ?Sized> {
|
||||
value: T,
|
||||
//~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||
pad: [u8; is_zst::<T>()],
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^ ERROR evaluation of constant value failed
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:33
|
||||
|
|
||||
LL | type Arr<const N: usize> = [u8; N - 1];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
type Arr<const N: usize> = [u8; N - 1];
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
|
||||
//[full]~^ ERROR constant expression depends
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/simple.rs:8:53
|
||||
|
|
||||
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||
|
|
@ -6,7 +6,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
|||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/simple.rs:8:35
|
||||
|
|
||||
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/simple_fail.rs:7:33
|
||||
|
|
||||
LL | type Arr<const N: usize> = [u8; N - 1];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
type Arr<const N: usize> = [u8; N - 1]; //[full]~ ERROR evaluation of constant
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
fn test<const N: usize>() -> Arr<N> where Arr<N>: Sized {
|
||||
todo!()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/generic-function-call-in-array-length.rs:9:29
|
||||
|
|
||||
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/generic-function-call-in-array-length.rs:9:39
|
||||
|
|
||||
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
||||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/generic-function-call-in-array-length.rs:12:13
|
||||
|
|
||||
LL | [0; foo(N)]
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
||||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
const fn foo(n: usize) -> usize { n * 2 }
|
||||
|
||||
fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^ ERROR constant expression depends on a generic parameter
|
||||
[0; foo(N)]
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/generic-sum-in-array-length.rs:7:45
|
||||
|
|
||||
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/generic-sum-in-array-length.rs:7:53
|
||||
|
|
||||
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `A`
|
||||
|
|
||||
= help: it is currently only allowed to use either `A` or `{ A }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/generic-sum-in-array-length.rs:7:57
|
||||
|
|
||||
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `B`
|
||||
|
|
||||
= help: it is currently only allowed to use either `B` or `{ B }` as generic constants
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
12
src/test/ui/const-generics/generic-sum-in-array-length.rs
Normal file
12
src/test/ui/const-generics/generic-sum-in-array-length.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^^ ERROR constant expression depends on a generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||
--> $DIR/impl-trait-with-const-arguments.rs:24:20
|
||||
|
|
||||
LL | assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||
| ^^^^^^ explicit generic argument not allowed
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||
--> $DIR/impl-trait-with-const-arguments.rs:24:20
|
||||
|
|
||||
LL | assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||
| ^^^^^^ explicit generic argument not allowed
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait Usizer {
|
||||
fn m(self) -> usize;
|
||||
}
|
||||
|
||||
fn f<const N: usize>(u: impl Usizer) -> usize {
|
||||
N + u.m()
|
||||
}
|
||||
|
||||
struct Usizable;
|
||||
|
||||
impl Usizer for Usizable {
|
||||
fn m(self) -> usize {
|
||||
16
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||
//~^ ERROR cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:8
|
||||
|
|
||||
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
|
||||
|
|
||||
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error: `&'static str` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
|
||||
|
|
||||
LL | trait Trait<const S: &'static str> {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(const_type_name)]
|
||||
|
||||
trait Trait<const S: &'static str> {}
|
||||
//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
|
||||
|
||||
struct Bug<T>
|
||||
where
|
||||
T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^ ERROR constant expression depends on a generic parameter
|
||||
{
|
||||
t: T
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-61522-array-len-succ.rs:7:45
|
||||
|
|
||||
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
||||
|
|
@ -6,7 +6,7 @@ LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
|||
|
|
||||
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-61522-array-len-succ.rs:12:30
|
||||
|
|
||||
LL | fn inner(&self) -> &[u8; COUNT + 1] {
|
||||
|
|
|
|||
21
src/test/ui/const-generics/issue-67375.full.stderr
Normal file
21
src/test/ui/const-generics/issue-67375.full.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/issue-67375.rs:9:12
|
||||
|
|
||||
LL | inner: [(); { [|_: &T| {}; 0].len() }],
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(const_evaluatable_unchecked)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
|
||||
|
||||
error[E0392]: parameter `T` is never used
|
||||
--> $DIR/issue-67375.rs:7:12
|
||||
|
|
||||
LL | struct Bug<T> {
|
||||
| ^ unused parameter
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0392`.
|
||||
19
src/test/ui/const-generics/issue-67375.min.stderr
Normal file
19
src/test/ui/const-generics/issue-67375.min.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-67375.rs:9:25
|
||||
|
|
||||
LL | inner: [(); { [|_: &T| {}; 0].len() }],
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error[E0392]: parameter `T` is never used
|
||||
--> $DIR/issue-67375.rs:7:12
|
||||
|
|
||||
LL | struct Bug<T> {
|
||||
| ^ unused parameter
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0392`.
|
||||
15
src/test/ui/const-generics/issue-67375.rs
Normal file
15
src/test/ui/const-generics/issue-67375.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Bug<T> {
|
||||
//~^ ERROR parameter `T` is never used
|
||||
inner: [(); { [|_: &T| {}; 0].len() }],
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^ WARN cannot use constants which depend on generic parameters in types
|
||||
//[full]~^^^ WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
26
src/test/ui/const-generics/issue-67945-1.full.stderr
Normal file
26
src/test/ui/const-generics/issue-67945-1.full.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-67945-1.rs:14:20
|
||||
|
|
||||
LL | struct Bug<S> {
|
||||
| - this type parameter
|
||||
...
|
||||
LL | let x: S = MaybeUninit::uninit();
|
||||
| - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type parameter `S`
|
||||
found union `MaybeUninit<_>`
|
||||
|
||||
error[E0392]: parameter `S` is never used
|
||||
--> $DIR/issue-67945-1.rs:11:12
|
||||
|
|
||||
LL | struct Bug<S> {
|
||||
| ^ unused parameter
|
||||
|
|
||||
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0392.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
27
src/test/ui/const-generics/issue-67945-1.min.stderr
Normal file
27
src/test/ui/const-generics/issue-67945-1.min.stderr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-67945-1.rs:14:16
|
||||
|
|
||||
LL | let x: S = MaybeUninit::uninit();
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-67945-1.rs:17:45
|
||||
|
|
||||
LL | let b = &*(&x as *const _ as *const S);
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error[E0392]: parameter `S` is never used
|
||||
--> $DIR/issue-67945-1.rs:11:12
|
||||
|
|
||||
LL | struct Bug<S> {
|
||||
| ^ unused parameter
|
||||
|
|
||||
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0392`.
|
||||
23
src/test/ui/const-generics/issue-67945-1.rs
Normal file
23
src/test/ui/const-generics/issue-67945-1.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use std::mem::{self, MaybeUninit};
|
||||
|
||||
struct Bug<S> {
|
||||
//~^ ERROR parameter `S` is never used
|
||||
A: [(); {
|
||||
let x: S = MaybeUninit::uninit();
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^ ERROR mismatched types
|
||||
let b = &*(&x as *const _ as *const S);
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
0
|
||||
}],
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
26
src/test/ui/const-generics/issue-67945-2.full.stderr
Normal file
26
src/test/ui/const-generics/issue-67945-2.full.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-67945-2.rs:12:20
|
||||
|
|
||||
LL | struct Bug<S> {
|
||||
| - this type parameter
|
||||
...
|
||||
LL | let x: S = MaybeUninit::uninit();
|
||||
| - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type parameter `S`
|
||||
found union `MaybeUninit<_>`
|
||||
|
||||
error[E0392]: parameter `S` is never used
|
||||
--> $DIR/issue-67945-2.rs:9:12
|
||||
|
|
||||
LL | struct Bug<S> {
|
||||
| ^ unused parameter
|
||||
|
|
||||
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0392.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
27
src/test/ui/const-generics/issue-67945-2.min.stderr
Normal file
27
src/test/ui/const-generics/issue-67945-2.min.stderr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-67945-2.rs:12:16
|
||||
|
|
||||
LL | let x: S = MaybeUninit::uninit();
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-67945-2.rs:15:45
|
||||
|
|
||||
LL | let b = &*(&x as *const _ as *const S);
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error[E0392]: parameter `S` is never used
|
||||
--> $DIR/issue-67945-2.rs:9:12
|
||||
|
|
||||
LL | struct Bug<S> {
|
||||
| ^ unused parameter
|
||||
|
|
||||
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0392`.
|
||||
21
src/test/ui/const-generics/issue-67945-2.rs
Normal file
21
src/test/ui/const-generics/issue-67945-2.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
struct Bug<S> {
|
||||
//~^ ERROR parameter `S` is never used
|
||||
A: [(); {
|
||||
let x: S = MaybeUninit::uninit();
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[full]~^^ ERROR mismatched types
|
||||
let b = &*(&x as *const _ as *const S);
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
0
|
||||
}],
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
16
src/test/ui/const-generics/issue-67945-3.full.stderr
Normal file
16
src/test/ui/const-generics/issue-67945-3.full.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-67945-3.rs:8:8
|
||||
|
|
||||
LL | A: [(); {
|
||||
| ________^
|
||||
LL | |
|
||||
LL | | let x: Option<Box<Self>> = None;
|
||||
LL | |
|
||||
LL | | 0
|
||||
LL | | }],
|
||||
| |______^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
8
src/test/ui/const-generics/issue-67945-3.min.stderr
Normal file
8
src/test/ui/const-generics/issue-67945-3.min.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: generic `Self` types are currently not permitted in anonymous constants
|
||||
--> $DIR/issue-67945-3.rs:10:27
|
||||
|
|
||||
LL | let x: Option<Box<Self>> = None;
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
17
src/test/ui/const-generics/issue-67945-3.rs
Normal file
17
src/test/ui/const-generics/issue-67945-3.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Bug<S: ?Sized> {
|
||||
A: [(); {
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
let x: Option<Box<Self>> = None;
|
||||
//[min]~^ ERROR generic `Self` types are currently not permitted in anonymous constants
|
||||
0
|
||||
}],
|
||||
B: S
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-61747.rs:8:30
|
||||
|
|
||||
LL | fn successor() -> Const<{C + 1}> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-61935.rs:10:23
|
||||
|
|
||||
LL | Self:FooImpl<{N==0}>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl<const N: usize> Foo for [(); N]
|
|||
where
|
||||
Self:FooImpl<{N==0}>
|
||||
//[full]~^ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
{}
|
||||
|
||||
trait FooImpl<const IS_ZERO: bool>{}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-62220.rs:8:59
|
||||
|
|
||||
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
pub struct Vector<T, const N: usize>([T; N]);
|
||||
|
||||
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
impl<T, const N: usize> Vector<T, { N }> {
|
||||
/// Drop the last component and return the vector with one fewer dimension.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-62456.rs:7:20
|
||||
|
|
||||
LL | let _ = [0u64; N + 1];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
fn foo<const N: usize>() {
|
||||
let _ = [0u64; N + 1];
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-64494.rs:16:38
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||
|
|
@ -6,7 +6,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
|||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-64494.rs:19:38
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ impl True for Is<{true}> {}
|
|||
|
||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[min]~| ERROR conflicting implementations of trait `MyTrait`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-66205.rs:8:14
|
||||
|
|
||||
LL | fact::<{ N - 1 }>();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
fn fact<const N: usize>() {
|
||||
fact::<{ N - 1 }>();
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-67739.rs:12:30
|
||||
|
|
||||
LL | [0u8; mem::size_of::<Self::Associated>()];
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub trait Trait {
|
|||
fn associated_size(&self) -> usize {
|
||||
[0u8; mem::size_of::<Self::Associated>()];
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-68366.rs:12:37
|
||||
|
|
||||
LL | impl <const N: usize> Collatz<{Some(N)}> {}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct Collatz<const N: Option<usize>>;
|
|||
|
||||
impl <const N: usize> Collatz<{Some(N)}> {}
|
||||
//~^ ERROR the const parameter
|
||||
//[min]~^^ generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
struct Foo;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-68977.rs:29:17
|
||||
|
|
||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||
|
|
@ -6,7 +6,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
|||
|
|
||||
= help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-68977.rs:29:28
|
||||
|
|
||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ fxp_storage_impls! {
|
|||
|
||||
type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
|
||||
PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~| ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-72787.rs:11:17
|
||||
|
|
||||
LL | Condition<{ LHS <= RHS }>: True
|
||||
|
|
@ -6,7 +6,7 @@ LL | Condition<{ LHS <= RHS }>: True
|
|||
|
|
||||
= help: it is currently only allowed to use either `LHS` or `{ LHS }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-72787.rs:11:24
|
||||
|
|
||||
LL | Condition<{ LHS <= RHS }>: True
|
||||
|
|
@ -14,7 +14,7 @@ LL | Condition<{ LHS <= RHS }>: True
|
|||
|
|
||||
= help: it is currently only allowed to use either `RHS` or `{ RHS }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-72787.rs:26:25
|
||||
|
|
||||
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||
|
|
@ -22,7 +22,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
|||
|
|
||||
= help: it is currently only allowed to use either `I` or `{ I }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-72787.rs:26:36
|
||||
|
|
||||
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ pub trait True {}
|
|||
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
|
||||
Condition<{ LHS <= RHS }>: True
|
||||
//[full]~^ Error constant expression depends on a generic parameter
|
||||
//[min]~^^ Error generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~| Error generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ Error generic parameters must not be used inside of non-trivial constant values
|
||||
//[min]~| Error generic parameters must not be used inside of non-trivial constant values
|
||||
{
|
||||
}
|
||||
impl True for Condition<true> {}
|
||||
|
|
@ -28,8 +28,8 @@ where
|
|||
//[full]~| constant expression depends on a generic parameter
|
||||
//[full]~| constant expression depends on a generic parameter
|
||||
//[full]~| constant expression depends on a generic parameter
|
||||
//[min]~^^^^^ Error generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~| Error generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^^^^ Error generic parameters must not be used inside of non-trivial constant values
|
||||
//[min]~| Error generic parameters must not be used inside of non-trivial constant values
|
||||
// Condition<{ 8 - I <= 8 - J }>: True,
|
||||
{
|
||||
fn print() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-72819-generic-in-const-eval.rs:9:17
|
||||
|
|
||||
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
struct Arr<const N: usize>
|
||||
where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-76701-ty-param-in-const.rs:6:46
|
||||
|
|
||||
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||
|
|
@ -6,7 +6,7 @@ LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
|||
|
|
||||
= note: type parameters are currently not permitted in anonymous constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/issue-76701-ty-param-in-const.rs:12:42
|
||||
|
|
||||
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn const_param<const N: usize>() -> [u8; N + 1] {
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@ fn ok<const M: usize>() -> [u8; M] {
|
|||
}
|
||||
|
||||
struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
struct Break1<const N: usize>([u8; { { N } }]);
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
|
||||
fn break2<const N: usize>() {
|
||||
let _: [u8; N + 1];
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
}
|
||||
|
||||
fn break3<const N: usize>() {
|
||||
let _ = [0; N + 1];
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||
}
|
||||
|
||||
trait Foo {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/complex-expression.rs:9:38
|
||||
|
|
||||
LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||
|
|
@ -6,7 +6,7 @@ LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
|||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/complex-expression.rs:12:40
|
||||
|
|
||||
LL | struct Break1<const N: usize>([u8; { { N } }]);
|
||||
|
|
@ -14,7 +14,7 @@ LL | struct Break1<const N: usize>([u8; { { N } }]);
|
|||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/complex-expression.rs:16:17
|
||||
|
|
||||
LL | let _: [u8; N + 1];
|
||||
|
|
@ -22,7 +22,7 @@ LL | let _: [u8; N + 1];
|
|||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/complex-expression.rs:21:17
|
||||
|
|
||||
LL | let _ = [0; N + 1];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/self-ty-in-const-1.rs:4:41
|
||||
|
|
||||
LL | fn t1() -> [u8; std::mem::size_of::<Self>()];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
#![feature(min_const_generics)]
|
||||
|
||||
fn a<const X: &'static [u32]>() {}
|
||||
//~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {
|
||||
a::<{&[]}>();
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error: `&'static [u32]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/static-reference-array-const-param.rs:3:15
|
||||
|
|
||||
LL | fn a<const X: &'static [u32]>() {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#![feature(min_const_generics)]
|
||||
|
||||
struct Const<const P: &'static ()>;
|
||||
//~^ ERROR `&'static ()` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {
|
||||
const A: &'static () = unsafe {
|
||||
std::mem::transmute(10 as *const ())
|
||||
};
|
||||
|
||||
let _ = Const::<{A}>;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error: `&'static ()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/transmute-const-param-static-reference.rs:3:23
|
||||
|
|
||||
LL | struct Const<const P: &'static ()>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ LL | struct Bar<T = [u8; N], const N: usize>(T);
|
|||
|
|
||||
= note: using type defaults and const parameters in the same parameter list is currently not permitted
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44
|
||||
|
|
||||
LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
|
||||
//[full]~^ ERROR constant values inside of type parameter defaults
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||
|
||||
// FIXME(const_generics:defaults): We still don't know how to we deal with type defaults.
|
||||
struct Bar<T = [u8; N], const N: usize>(T);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/wf-misc.rs:9:17
|
||||
|
|
||||
LL | let _: [u8; N + 1];
|
||||
|
|
@ -6,7 +6,7 @@ LL | let _: [u8; N + 1];
|
|||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
error: generic parameters must not be used inside of non-trivial constant values
|
||||
--> $DIR/wf-misc.rs:17:21
|
||||
|
|
||||
LL | let _: Const::<{N + 1}>;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
pub fn arr_len<const N: usize>() {
|
||||
let _: [u8; N + 1];
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||
}
|
||||
|
||||
struct Const<const N: usize>;
|
||||
|
|
@ -16,7 +16,7 @@ struct Const<const N: usize>;
|
|||
pub fn func_call<const N: usize>() {
|
||||
let _: Const::<{N + 1}>;
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
13
src/test/ui/consts/const-eval/unwind-abort.rs
Normal file
13
src/test/ui/consts/const-eval/unwind-abort.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#![feature(unwind_attributes, const_panic)]
|
||||
|
||||
#[unwind(aborts)]
|
||||
const fn foo() {
|
||||
panic!() //~ evaluation of constant value failed
|
||||
}
|
||||
|
||||
const _: () = foo(); //~ any use of this value will cause an error
|
||||
// Ensure that the CTFE engine handles calls to `#[unwind(aborts)]` gracefully
|
||||
|
||||
fn main() {
|
||||
let _ = foo();
|
||||
}
|
||||
21
src/test/ui/consts/const-eval/unwind-abort.stderr
Normal file
21
src/test/ui/consts/const-eval/unwind-abort.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/unwind-abort.rs:5:5
|
||||
|
|
||||
LL | panic!()
|
||||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/unwind-abort.rs:8:15
|
||||
|
|
||||
LL | const _: () = foo();
|
||||
| --------------^^^^^-
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
17
src/test/ui/consts/unwind-abort.rs
Normal file
17
src/test/ui/consts/unwind-abort.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(unwind_attributes, const_panic)]
|
||||
|
||||
// `#[unwind(aborts)]` is okay for a `const fn`. We don't unwind in const-eval anyways.
|
||||
#[unwind(aborts)]
|
||||
const fn foo() {
|
||||
panic!()
|
||||
}
|
||||
|
||||
const fn bar() {
|
||||
foo();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
bar();
|
||||
}
|
||||
7
src/test/ui/doc-alias-crate-level.rs
Normal file
7
src/test/ui/doc-alias-crate-level.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// compile-flags: -Zdeduplicate-diagnostics=no
|
||||
|
||||
#![feature(doc_alias)]
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#![doc(alias = "shouldn't work!")] //~ ERROR
|
||||
8
src/test/ui/doc-alias-crate-level.stderr
Normal file
8
src/test/ui/doc-alias-crate-level.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
||||
--> $DIR/doc-alias-crate-level.rs:7:8
|
||||
|
|
||||
LL | #![doc(alias = "shouldn't work!")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
//~ NOTE: not an `extern crate` item
|
||||
//~^ NOTE: not a function or static
|
||||
//~^^ NOTE: not a function or closure
|
||||
// This is testing whether various builtin attributes signals an
|
||||
// error or warning when put in "weird" places.
|
||||
//
|
||||
|
|
@ -7,9 +10,25 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// Crate-level is accepted, though it is almost certainly unused?
|
||||
#![macro_export]
|
||||
//~^ ERROR: `macro_export` attribute cannot be used at crate level
|
||||
#![main]
|
||||
//~^ ERROR: `main` attribute cannot be used at crate level
|
||||
#![start]
|
||||
//~^ ERROR: `start` attribute cannot be used at crate level
|
||||
#![repr()]
|
||||
//~^ ERROR: `repr` attribute cannot be used at crate level
|
||||
#![path = "3800"]
|
||||
//~^ ERROR: `path` attribute cannot be used at crate level
|
||||
#![automatically_derived]
|
||||
//~^ ERROR: `automatically_derived` attribute cannot be used at crate level
|
||||
#![no_mangle]
|
||||
#![no_link]
|
||||
//~^ ERROR: attribute should be applied to an `extern crate` item
|
||||
#![export_name = "2200"]
|
||||
//~^ ERROR: attribute should be applied to a function or static
|
||||
#![inline]
|
||||
|
||||
//~^ ERROR: attribute should be applied to function or closure
|
||||
#[inline]
|
||||
//~^ ERROR attribute should be applied to function or closure
|
||||
mod inline {
|
||||
|
|
@ -88,4 +107,40 @@ mod export_name {
|
|||
//~| NOTE not a function or static
|
||||
}
|
||||
|
||||
#[main]
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
mod main {
|
||||
mod inner { #![main] }
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
|
||||
// for `fn f()` case, see feature-gate-main.rs
|
||||
|
||||
#[main] struct S;
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
|
||||
#[main] type T = S;
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
|
||||
#[main] impl S { }
|
||||
//~^ ERROR: `main` attribute can only be used on functions
|
||||
}
|
||||
|
||||
#[start]
|
||||
//~^ ERROR: `start` attribute can only be used on functions
|
||||
mod start {
|
||||
mod inner { #![start] }
|
||||
//~^ ERROR: `start` attribute can only be used on functions
|
||||
|
||||
// for `fn f()` case, see feature-gate-start.rs
|
||||
|
||||
#[start] struct S;
|
||||
//~^ ERROR: `start` attribute can only be used on functions
|
||||
|
||||
#[start] type T = S;
|
||||
//~^ ERROR: `start` attribute can only be used on functions
|
||||
|
||||
#[start] impl S { }
|
||||
//~^ ERROR: `start` attribute can only be used on functions
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:22:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:41:5
|
||||
|
|
||||
LL | #[inline = "2100"] fn f() { }
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,8 +8,68 @@ LL | #[inline = "2100"] fn f() { }
|
|||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:110:1
|
||||
|
|
||||
LL | #[main]
|
||||
| ^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:17
|
||||
|
|
||||
LL | mod inner { #![main] }
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:118:5
|
||||
|
|
||||
LL | #[main] struct S;
|
||||
| ^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:121:5
|
||||
|
|
||||
LL | #[main] type T = S;
|
||||
| ^^^^^^^
|
||||
|
||||
error: `main` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:124:5
|
||||
|
|
||||
LL | #[main] impl S { }
|
||||
| ^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:128:1
|
||||
|
|
||||
LL | #[start]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:17
|
||||
|
|
||||
LL | mod inner { #![start] }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:136:5
|
||||
|
|
||||
LL | #[start] struct S;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:139:5
|
||||
|
|
||||
LL | #[start] type T = S;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute can only be used on functions
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:142:5
|
||||
|
|
||||
LL | #[start] impl S { }
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:13:1
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1
|
||||
|
|
||||
LL | #[inline]
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -24,7 +84,7 @@ LL | | }
|
|||
| |_- not a function or closure
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:41:1
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:60:1
|
||||
|
|
||||
LL | #[no_link]
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -39,7 +99,7 @@ LL | | }
|
|||
| |_- not an `extern crate` item
|
||||
|
||||
error: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:1
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:1
|
||||
|
|
||||
LL | #[export_name = "2200"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -53,84 +113,138 @@ LL | |
|
|||
LL | | }
|
||||
| |_- not a function or static
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1
|
||||
|
|
||||
LL | #![no_link]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1
|
||||
|
|
||||
LL | #![export_name = "2200"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:18:17
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1
|
||||
|
|
||||
LL | #![inline]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `macro_export` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:13:1
|
||||
|
|
||||
LL | #![macro_export]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `main` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:15:1
|
||||
|
|
||||
LL | #![main]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `start` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1
|
||||
|
|
||||
LL | #![start]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `repr` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1
|
||||
|
|
||||
LL | #![repr()]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `path` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1
|
||||
|
|
||||
LL | #![path = "3800"]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `automatically_derived` attribute cannot be used at crate level
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1
|
||||
|
|
||||
LL | #![automatically_derived]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:37:17
|
||||
|
|
||||
LL | mod inner { #![inline] }
|
||||
| ------------^^^^^^^^^^-- not a function or closure
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:47:5
|
||||
|
|
||||
LL | #[inline] struct S;
|
||||
| ^^^^^^^^^ --------- not a function or closure
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:51:5
|
||||
|
|
||||
LL | #[inline] type T = S;
|
||||
| ^^^^^^^^^ ----------- not a function or closure
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:36:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:55:5
|
||||
|
|
||||
LL | #[inline] impl S { }
|
||||
| ^^^^^^^^^ ---------- not a function or closure
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:17
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:17
|
||||
|
|
||||
LL | mod inner { #![no_link] }
|
||||
| ------------^^^^^^^^^^^-- not an `extern crate` item
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:50:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:69:5
|
||||
|
|
||||
LL | #[no_link] fn f() { }
|
||||
| ^^^^^^^^^^ ---------- not an `extern crate` item
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:54:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5
|
||||
|
|
||||
LL | #[no_link] struct S;
|
||||
| ^^^^^^^^^^ --------- not an `extern crate` item
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:58:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:77:5
|
||||
|
|
||||
LL | #[no_link]type T = S;
|
||||
| ^^^^^^^^^^----------- not an `extern crate` item
|
||||
|
||||
error: attribute should be applied to an `extern crate` item
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:62:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:81:5
|
||||
|
|
||||
LL | #[no_link] impl S { }
|
||||
| ^^^^^^^^^^ ---------- not an `extern crate` item
|
||||
|
||||
error: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:72:17
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:17
|
||||
|
|
||||
LL | mod inner { #![export_name="2200"] }
|
||||
| ------------^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
|
||||
|
||||
error: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:78:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:97:5
|
||||
|
|
||||
LL | #[export_name = "2200"] struct S;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
|
||||
|
||||
error: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:101:5
|
||||
|
|
||||
LL | #[export_name = "2200"] type T = S;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
|
||||
|
||||
error: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:105:5
|
||||
|
|
||||
LL | #[export_name = "2200"] impl S { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0518`.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
//~ NOTE not a function
|
||||
//~^ NOTE not a foreign function or static
|
||||
//~^^ NOTE not a function or static
|
||||
// This test enumerates as many compiler-builtin ungated attributes as
|
||||
// possible (that is, all the mutually compatible ones), and checks
|
||||
// that we get "expected" (*) warnings for each in the various weird
|
||||
|
|
@ -52,20 +55,8 @@
|
|||
#![forbid(x5200)] //~ WARN unknown lint: `x5200`
|
||||
#![deny(x5100)] //~ WARN unknown lint: `x5100`
|
||||
#![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
|
||||
#![macro_export] //~ WARN unused attribute
|
||||
// skipping testing of cfg
|
||||
// skipping testing of cfg_attr
|
||||
#![main] //~ WARN unused attribute
|
||||
#![start] //~ WARN unused attribute
|
||||
// see issue-43106-gating-of-test.rs for crate-level; but non crate-level is below at "4200"
|
||||
// see issue-43106-gating-of-bench.rs for crate-level; but non crate-level is below at "4100"
|
||||
#![repr()]
|
||||
//~^ WARN unused attribute
|
||||
#![path = "3800"] //~ WARN unused attribute
|
||||
#![automatically_derived] //~ WARN unused attribute
|
||||
#![no_mangle]
|
||||
#![no_link] //~ WARN unused attribute
|
||||
// see issue-43106-gating-of-derive.rs
|
||||
#![should_panic] //~ WARN unused attribute
|
||||
#![ignore] //~ WARN unused attribute
|
||||
#![no_implicit_prelude]
|
||||
|
|
@ -75,12 +66,16 @@
|
|||
// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
|
||||
#![proc_macro_derive()] //~ WARN unused attribute
|
||||
#![doc = "2400"]
|
||||
#![cold]
|
||||
#![export_name = "2200"]
|
||||
#![cold] //~ WARN attribute should be applied to a function
|
||||
//~^ WARN
|
||||
// see issue-43106-gating-of-builtin-attrs-error.rs
|
||||
#![link()]
|
||||
#![link_name = "1900"]
|
||||
//~^ WARN attribute should be applied to a foreign function
|
||||
//~^^ WARN this was previously accepted by the compiler
|
||||
#![link_section = "1800"]
|
||||
//~^ WARN attribute should be applied to a function or static
|
||||
//~^^ WARN this was previously accepted by the compiler
|
||||
// see issue-43106-gating-of-rustc_deprecated.rs
|
||||
#![must_use]
|
||||
// see issue-43106-gating-of-stable.rs
|
||||
|
|
@ -254,42 +249,6 @@ mod plugin_registrar {
|
|||
//~| HELP may be removed in a future compiler version
|
||||
}
|
||||
|
||||
#[main]
|
||||
//~^ WARN unused attribute
|
||||
mod main {
|
||||
mod inner { #![main] }
|
||||
//~^ WARN unused attribute
|
||||
|
||||
// for `fn f()` case, see feature-gate-main.rs
|
||||
|
||||
#[main] struct S;
|
||||
//~^ WARN unused attribute
|
||||
|
||||
#[main] type T = S;
|
||||
//~^ WARN unused attribute
|
||||
|
||||
#[main] impl S { }
|
||||
//~^ WARN unused attribute
|
||||
}
|
||||
|
||||
#[start]
|
||||
//~^ WARN unused attribute
|
||||
mod start {
|
||||
mod inner { #![start] }
|
||||
//~^ WARN unused attribute
|
||||
|
||||
// for `fn f()` case, see feature-gate-start.rs
|
||||
|
||||
#[start] struct S;
|
||||
//~^ WARN unused attribute
|
||||
|
||||
#[start] type T = S;
|
||||
//~^ WARN unused attribute
|
||||
|
||||
#[start] impl S { }
|
||||
//~^ WARN unused attribute
|
||||
}
|
||||
|
||||
// At time of unit test authorship, if compiling without `--test` then
|
||||
// non-crate-level #[test] attributes seem to be ignored.
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
6
src/test/ui/traits/issue-75627.rs
Normal file
6
src/test/ui/traits/issue-75627.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
struct Foo<T>(T, *const ());
|
||||
|
||||
unsafe impl Send for Foo<T> {}
|
||||
//~^ ERROR cannot find type
|
||||
|
||||
fn main() {}
|
||||
9
src/test/ui/traits/issue-75627.stderr
Normal file
9
src/test/ui/traits/issue-75627.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0412]: cannot find type `T` in this scope
|
||||
--> $DIR/issue-75627.rs:3:26
|
||||
|
|
||||
LL | unsafe impl Send for Foo<T> {}
|
||||
| ^ not found in this scope
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0412`.
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#![feature(try_blocks)]
|
||||
|
||||
#![inline(never)]
|
||||
#[inline(never)]
|
||||
fn do_something_with<T>(_x: T) {}
|
||||
|
||||
// This test checks that borrows made and returned inside try blocks are properly constrained
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#![feature(try_blocks)]
|
||||
|
||||
#![inline(never)]
|
||||
#[inline(never)]
|
||||
fn do_something_with<T>(_x: T) {}
|
||||
|
||||
// This test checks that borrows made and returned inside try blocks are properly constrained
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue