Fix duplicate error messages in const_generics tests
This commit is contained in:
parent
7a7a28d6bb
commit
668f63d833
@ -5,7 +5,7 @@ LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
|
||||
|
||||
error[E0747]: lifetime provided when a type was expected
|
||||
--> $DIR/argument_order.rs:21:23
|
||||
--> $DIR/argument_order.rs:20:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
||||
|
@ -17,7 +17,7 @@ LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
|
||||
|
||||
error[E0747]: lifetime provided when a type was expected
|
||||
--> $DIR/argument_order.rs:21:23
|
||||
--> $DIR/argument_order.rs:20:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
||||
|
@ -10,15 +10,13 @@ struct Bad<const N: usize, T> {
|
||||
}
|
||||
|
||||
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
//[full]~^ ERROR lifetime parameters must be declared prior
|
||||
//[min]~^^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//[min]~^^^ ERROR type parameters must be declared prior to const parameters
|
||||
//~^ ERROR lifetime parameters must be declared prior
|
||||
//[min]~^^ ERROR type parameters must be declared prior to const parameters
|
||||
a: &'a T,
|
||||
b: &'b U,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
//[full]~^ ERROR lifetime provided when a type was expected
|
||||
//[min]~^^ ERROR lifetime provided when a type was expected
|
||||
//~^ ERROR lifetime provided when a type was expected
|
||||
}
|
||||
|
@ -6,8 +6,7 @@
|
||||
type Array<T, const N: usize> = [T; N];
|
||||
|
||||
fn foo<const N: usize>() -> Array<N, ()> {
|
||||
//[full]~^ ERROR constant provided when a type was expected
|
||||
//[min]~^^ ERROR constant provided when a type was expected
|
||||
//~^ ERROR constant provided when a type was expected
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
|
||||
|
||||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:12:21
|
||||
--> $DIR/const-param-before-other-params.rs:11:21
|
||||
|
|
||||
LL | fn foo<const X: (), T>(_: &T) {}
|
||||
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
|
||||
@ -20,7 +20,7 @@ LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-before-other-params.rs:12:17
|
||||
--> $DIR/const-param-before-other-params.rs:11:17
|
||||
|
|
||||
LL | fn foo<const X: (), T>(_: &T) {}
|
||||
| ^^
|
||||
|
@ -4,9 +4,8 @@
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
//[full]~^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//[min]~^^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//[min]~^^^ ERROR `()` is forbidden as the type of a const generic parameter
|
||||
//~^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
|
||||
}
|
||||
|
||||
fn foo<const X: (), T>(_: &T) {}
|
||||
|
@ -8,10 +8,8 @@ struct B;
|
||||
impl A for B {}
|
||||
|
||||
fn test<const T: &'static dyn A>() {
|
||||
//[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
|
||||
//[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden as the type of
|
||||
// a const generic parameter
|
||||
//[min]~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
|
||||
//[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
| ^^^ the type must not depend on the parameter `LEN`
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-71169.rs:12:14
|
||||
--> $DIR/issue-71169.rs:11:14
|
||||
|
|
||||
LL | foo::<4, DATA>();
|
||||
| ^^^^
|
||||
|
@ -4,9 +4,8 @@
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
//[full]~^ ERROR the type of const parameters must not
|
||||
//[min]~^^ ERROR the type of const parameters must not
|
||||
//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
//~^ ERROR the type of const parameters must not
|
||||
//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
fn main() {
|
||||
const DATA: [u8; 4] = *b"ABCD";
|
||||
foo::<4, DATA>();
|
||||
|
@ -5,7 +5,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
|
||||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71381.rs:26:40
|
||||
--> $DIR/issue-71381.rs:24:40
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
@ -17,7 +17,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:26:19
|
||||
--> $DIR/issue-71381.rs:24:19
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -5,7 +5,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
|
||||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71381.rs:26:40
|
||||
--> $DIR/issue-71381.rs:24:40
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
@ -17,7 +17,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:26:19
|
||||
--> $DIR/issue-71381.rs:24:19
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -13,10 +13,8 @@ unsafe extern "C" fn pass(args: PassArg) {
|
||||
|
||||
impl Test {
|
||||
pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
|
||||
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[full]~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
//[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[min]~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
self.0 = Self::trampiline::<Args, IDX, FN> as _
|
||||
}
|
||||
|
||||
@ -24,10 +22,8 @@ impl Test {
|
||||
Args: Sized,
|
||||
const IDX: usize,
|
||||
const FN: unsafe extern "C" fn(Args),
|
||||
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[full]~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
//[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[min]~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
>(
|
||||
args: Args,
|
||||
) {
|
||||
|
@ -15,8 +15,7 @@ impl Test {
|
||||
}
|
||||
|
||||
fn test<const FN: fn()>(&self) {
|
||||
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[min]~^^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
FN();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,8 @@
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[full]~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
//[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[min]~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//~| ERROR: the type of const parameters must not depend on other generic parameters
|
||||
F(outer);
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,7 @@
|
||||
use std::ffi::{CStr, CString};
|
||||
|
||||
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//[min]~^^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
F(CStr::from_ptr(ptr))
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
pub const fn func_name<const X: *const u32>() {}
|
||||
//[full]~^ ERROR using raw pointers
|
||||
//[min]~^^ ERROR using raw pointers as const generic parameters is forbidden
|
||||
//~^ ERROR using raw pointers
|
||||
|
||||
fn main() {}
|
||||
|
@ -35,7 +35,7 @@ LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:30:26
|
||||
--> $DIR/const-generics-range.rs:29:26
|
||||
|
|
||||
LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -44,7 +44,7 @@ LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:35:35
|
||||
--> $DIR/const-generics-range.rs:34:35
|
||||
|
|
||||
LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -6,35 +6,33 @@
|
||||
|
||||
// `Range` should be usable within const generics:
|
||||
struct _Range<const R: std::ops::Range<usize>>;
|
||||
//[min]~^ ERROR `std::ops::Range<usize>` is forbidden as the type of a const generic parameter
|
||||
//[min]~^ ERROR `std::ops::Range<usize>` is forbidden
|
||||
const RANGE : _Range<{ 0 .. 1000 }> = _Range;
|
||||
|
||||
// `RangeFrom` should be usable within const generics:
|
||||
struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter
|
||||
//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden
|
||||
const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom;
|
||||
|
||||
// `RangeFull` should be usable within const generics:
|
||||
struct _RangeFull<const R: std::ops::RangeFull>;
|
||||
//[min]~^ ERROR `std::ops::RangeFull` is forbidden as the type of a const generic parameter
|
||||
//[min]~^ ERROR `std::ops::RangeFull` is forbidden
|
||||
const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull;
|
||||
|
||||
// Regression test for #70155
|
||||
// `RangeInclusive` should be usable within const generics:
|
||||
struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden as the type of a const generic
|
||||
// parameter
|
||||
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden
|
||||
const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive;
|
||||
|
||||
// `RangeTo` should be usable within const generics:
|
||||
struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter
|
||||
//[min]~^ ERROR `std::ops::RangeTo<usize>` is forbidden
|
||||
const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo;
|
||||
|
||||
// `RangeToInclusive` should be usable within const generics:
|
||||
struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic
|
||||
// parameter
|
||||
//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden
|
||||
const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive;
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -15,8 +15,7 @@ impl Test {
|
||||
}
|
||||
|
||||
fn test<const FN: fn() -> u8>(&self) -> u8 {
|
||||
//[full]~^ ERROR using function pointers as const generic parameters is forbidden
|
||||
//[min]~^^ ERROR using function pointers as const generic parameters is forbidden
|
||||
//~^ ERROR using function pointers as const generic parameters is forbidden
|
||||
FN()
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,5 @@ impl R {
|
||||
}
|
||||
fn main() {
|
||||
assert_eq!(R.method::<1u16>(), 1);
|
||||
//[full]~^ ERROR mismatched types
|
||||
//[min]~^^ ERROR mismatched types
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data
|
||||
found type `4_u32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/types-mismatch-const-args.rs:18:41
|
||||
--> $DIR/types-mismatch-const-args.rs:17:41
|
||||
|
|
||||
LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
|
||||
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
|
||||
|
@ -10,7 +10,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data
|
||||
found struct `A<'_, _, 4_u32, _>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/types-mismatch-const-args.rs:18:41
|
||||
--> $DIR/types-mismatch-const-args.rs:17:41
|
||||
|
|
||||
LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
|
||||
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
|
||||
|
@ -13,11 +13,9 @@ struct A<'a, T, const X: u32, const Y: u32> {
|
||||
|
||||
fn a<'a, 'b>() {
|
||||
let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
|
||||
//[full]~^ ERROR mismatched types
|
||||
//[min]~^^ ERROR mismatched types
|
||||
//~^ ERROR mismatched types
|
||||
let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
|
||||
//[full]~^ ERROR mismatched types
|
||||
//[min]~^^ ERROR mismatched types
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user