Skip to content

Commit 668f63d

Browse files
committed
Fix duplicate error messages in const_generics tests
1 parent 7a7a28d commit 668f63d

23 files changed

+42
-64
lines changed

src/test/ui/const-generics/argument_order.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
55
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
66

77
error[E0747]: lifetime provided when a type was expected
8-
--> $DIR/argument_order.rs:21:23
8+
--> $DIR/argument_order.rs:20:23
99
|
1010
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
1111
| ^^^^^^^

src/test/ui/const-generics/argument_order.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
1717
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
1818

1919
error[E0747]: lifetime provided when a type was expected
20-
--> $DIR/argument_order.rs:21:23
20+
--> $DIR/argument_order.rs:20:23
2121
|
2222
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
2323
| ^^^^^^^

src/test/ui/const-generics/argument_order.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ struct Bad<const N: usize, T> {
1010
}
1111

1212
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
13-
//[full]~^ ERROR lifetime parameters must be declared prior
14-
//[min]~^^ ERROR lifetime parameters must be declared prior to const parameters
15-
//[min]~^^^ ERROR type parameters must be declared prior to const parameters
13+
//~^ ERROR lifetime parameters must be declared prior
14+
//[min]~^^ ERROR type parameters must be declared prior to const parameters
1615
a: &'a T,
1716
b: &'b U,
1817
}
1918

2019
fn main() {
2120
let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
22-
//[full]~^ ERROR lifetime provided when a type was expected
23-
//[min]~^^ ERROR lifetime provided when a type was expected
21+
//~^ ERROR lifetime provided when a type was expected
2422
}

src/test/ui/const-generics/const-arg-type-arg-misordered.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
type Array<T, const N: usize> = [T; N];
77

88
fn foo<const N: usize>() -> Array<N, ()> {
9-
//[full]~^ ERROR constant provided when a type was expected
10-
//[min]~^^ ERROR constant provided when a type was expected
9+
//~^ ERROR constant provided when a type was expected
1110
unimplemented!()
1211
}
1312

src/test/ui/const-generics/const-param-before-other-params.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn bar<const X: (), 'a>(_: &'a ()) {
55
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
66

77
error: type parameters must be declared prior to const parameters
8-
--> $DIR/const-param-before-other-params.rs:12:21
8+
--> $DIR/const-param-before-other-params.rs:11:21
99
|
1010
LL | fn foo<const X: (), T>(_: &T) {}
1111
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
@@ -20,7 +20,7 @@ LL | fn bar<const X: (), 'a>(_: &'a ()) {
2020
= note: more complex types are supported with `#[feature(const_generics)]`
2121

2222
error: `()` is forbidden as the type of a const generic parameter
23-
--> $DIR/const-param-before-other-params.rs:12:17
23+
--> $DIR/const-param-before-other-params.rs:11:17
2424
|
2525
LL | fn foo<const X: (), T>(_: &T) {}
2626
| ^^

src/test/ui/const-generics/const-param-before-other-params.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#![cfg_attr(min, feature(min_const_generics))]
55

66
fn bar<const X: (), 'a>(_: &'a ()) {
7-
//[full]~^ ERROR lifetime parameters must be declared prior to const parameters
8-
//[min]~^^ ERROR lifetime parameters must be declared prior to const parameters
9-
//[min]~^^^ ERROR `()` is forbidden as the type of a const generic parameter
7+
//~^ ERROR lifetime parameters must be declared prior to const parameters
8+
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
109
}
1110

1211
fn foo<const X: (), T>(_: &T) {}

src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ struct B;
88
impl A for B {}
99

1010
fn test<const T: &'static dyn A>() {
11-
//[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
12-
//[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden as the type of
13-
// a const generic parameter
14-
//[min]~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
11+
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
12+
//[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden
1513
unimplemented!()
1614
}
1715

src/test/ui/const-generics/issues/issue-71169.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
55
| ^^^ the type must not depend on the parameter `LEN`
66

77
error: constant expression depends on a generic parameter
8-
--> $DIR/issue-71169.rs:12:14
8+
--> $DIR/issue-71169.rs:11:14
99
|
1010
LL | foo::<4, DATA>();
1111
| ^^^^

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#![cfg_attr(min, feature(min_const_generics))]
55

66
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
7-
//[full]~^ ERROR the type of const parameters must not
8-
//[min]~^^ ERROR the type of const parameters must not
9-
//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter
7+
//~^ ERROR the type of const parameters must not
8+
//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
109
fn main() {
1110
const DATA: [u8; 4] = *b"ABCD";
1211
foo::<4, DATA>();

src/test/ui/const-generics/issues/issue-71381.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
55
| ^^^^ the type must not depend on the parameter `Args`
66

77
error[E0770]: the type of const parameters must not depend on other generic parameters
8-
--> $DIR/issue-71381.rs:26:40
8+
--> $DIR/issue-71381.rs:24:40
99
|
1010
LL | const FN: unsafe extern "C" fn(Args),
1111
| ^^^^ 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 "
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: using function pointers as const generic parameters is forbidden
20-
--> $DIR/issue-71381.rs:26:19
20+
--> $DIR/issue-71381.rs:24:19
2121
|
2222
LL | const FN: unsafe extern "C" fn(Args),
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/const-generics/issues/issue-71381.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
55
| ^^^^ the type must not depend on the parameter `Args`
66

77
error[E0770]: the type of const parameters must not depend on other generic parameters
8-
--> $DIR/issue-71381.rs:26:40
8+
--> $DIR/issue-71381.rs:24:40
99
|
1010
LL | const FN: unsafe extern "C" fn(Args),
1111
| ^^^^ 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 "
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: using function pointers as const generic parameters is forbidden
20-
--> $DIR/issue-71381.rs:26:19
20+
--> $DIR/issue-71381.rs:24:19
2121
|
2222
LL | const FN: unsafe extern "C" fn(Args),
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@ unsafe extern "C" fn pass(args: PassArg) {
1313

1414
impl Test {
1515
pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
16-
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
17-
//[full]~| ERROR: the type of const parameters must not depend on other generic parameters
18-
//[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden
19-
//[min]~| ERROR: the type of const parameters must not depend on other generic parameters
16+
//~^ ERROR: using function pointers as const generic parameters is forbidden
17+
//~| ERROR: the type of const parameters must not depend on other generic parameters
2018
self.0 = Self::trampiline::<Args, IDX, FN> as _
2119
}
2220

2321
unsafe extern "C" fn trampiline<
2422
Args: Sized,
2523
const IDX: usize,
2624
const FN: unsafe extern "C" fn(Args),
27-
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
28-
//[full]~| ERROR: the type of const parameters must not depend on other generic parameters
29-
//[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden
30-
//[min]~| ERROR: the type of const parameters must not depend on other generic parameters
25+
//~^ ERROR: using function pointers as const generic parameters is forbidden
26+
//~| ERROR: the type of const parameters must not depend on other generic parameters
3127
>(
3228
args: Args,
3329
) {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ impl Test {
1515
}
1616

1717
fn test<const FN: fn()>(&self) {
18-
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
19-
//[min]~^^ ERROR: using function pointers as const generic parameters is forbidden
18+
//~^ ERROR: using function pointers as const generic parameters is forbidden
2019
FN();
2120
}
2221
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
#![cfg_attr(min, feature(min_const_generics))]
55

66
fn func<A, const F: fn(inner: A)>(outer: A) {
7-
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
8-
//[full]~| ERROR: the type of const parameters must not depend on other generic parameters
9-
//[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden
10-
//[min]~| ERROR: the type of const parameters must not depend on other generic parameters
7+
//~^ ERROR: using function pointers as const generic parameters is forbidden
8+
//~| ERROR: the type of const parameters must not depend on other generic parameters
119
F(outer);
1210
}
1311

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
use std::ffi::{CStr, CString};
77

88
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
9-
//[full]~^ ERROR: using function pointers as const generic parameters is forbidden
10-
//[min]~^^ ERROR: using function pointers as const generic parameters is forbidden
9+
//~^ ERROR: using function pointers as const generic parameters is forbidden
1110
F(CStr::from_ptr(ptr))
1211
}
1312

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![cfg_attr(min, feature(min_const_generics))]
55

66
pub const fn func_name<const X: *const u32>() {}
7-
//[full]~^ ERROR using raw pointers
8-
//[min]~^^ ERROR using raw pointers as const generic parameters is forbidden
7+
//~^ ERROR using raw pointers
98

109
fn main() {}

src/test/ui/const-generics/std/const-generics-range.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
3535
= note: more complex types are supported with `#[feature(const_generics)]`
3636

3737
error: `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter
38-
--> $DIR/const-generics-range.rs:30:26
38+
--> $DIR/const-generics-range.rs:29:26
3939
|
4040
LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -44,7 +44,7 @@ LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
4444
= note: more complex types are supported with `#[feature(const_generics)]`
4545

4646
error: `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
47-
--> $DIR/const-generics-range.rs:35:35
47+
--> $DIR/const-generics-range.rs:34:35
4848
|
4949
LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/const-generics/std/const-generics-range.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,33 @@
66

77
// `Range` should be usable within const generics:
88
struct _Range<const R: std::ops::Range<usize>>;
9-
//[min]~^ ERROR `std::ops::Range<usize>` is forbidden as the type of a const generic parameter
9+
//[min]~^ ERROR `std::ops::Range<usize>` is forbidden
1010
const RANGE : _Range<{ 0 .. 1000 }> = _Range;
1111

1212
// `RangeFrom` should be usable within const generics:
1313
struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
14-
//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter
14+
//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden
1515
const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom;
1616

1717
// `RangeFull` should be usable within const generics:
1818
struct _RangeFull<const R: std::ops::RangeFull>;
19-
//[min]~^ ERROR `std::ops::RangeFull` is forbidden as the type of a const generic parameter
19+
//[min]~^ ERROR `std::ops::RangeFull` is forbidden
2020
const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull;
2121

2222
// Regression test for #70155
2323
// `RangeInclusive` should be usable within const generics:
2424
struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
25-
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden as the type of a const generic
26-
// parameter
25+
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden
2726
const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive;
2827

2928
// `RangeTo` should be usable within const generics:
3029
struct _RangeTo<const R: std::ops::RangeTo<usize>>;
31-
//[min]~^ ERROR `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter
30+
//[min]~^ ERROR `std::ops::RangeTo<usize>` is forbidden
3231
const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo;
3332

3433
// `RangeToInclusive` should be usable within const generics:
3534
struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
36-
//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic
37-
// parameter
35+
//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden
3836
const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive;
3937

4038
pub fn main() {}

src/test/ui/const-generics/type-dependent/issue-71382.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ impl Test {
1515
}
1616

1717
fn test<const FN: fn() -> u8>(&self) -> u8 {
18-
//[full]~^ ERROR using function pointers as const generic parameters is forbidden
19-
//[min]~^^ ERROR using function pointers as const generic parameters is forbidden
18+
//~^ ERROR using function pointers as const generic parameters is forbidden
2019
FN()
2120
}
2221
}

src/test/ui/const-generics/type-dependent/type-mismatch.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ impl R {
1010
}
1111
fn main() {
1212
assert_eq!(R.method::<1u16>(), 1);
13-
//[full]~^ ERROR mismatched types
14-
//[min]~^^ ERROR mismatched types
13+
//~^ ERROR mismatched types
1514
}

src/test/ui/const-generics/types-mismatch-const-args.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data
88
found type `4_u32`
99

1010
error[E0308]: mismatched types
11-
--> $DIR/types-mismatch-const-args.rs:18:41
11+
--> $DIR/types-mismatch-const-args.rs:17:41
1212
|
1313
LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
1414
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`

src/test/ui/const-generics/types-mismatch-const-args.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data
1010
found struct `A<'_, _, 4_u32, _>`
1111

1212
error[E0308]: mismatched types
13-
--> $DIR/types-mismatch-const-args.rs:18:41
13+
--> $DIR/types-mismatch-const-args.rs:17:41
1414
|
1515
LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
1616
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`

src/test/ui/const-generics/types-mismatch-const-args.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ struct A<'a, T, const X: u32, const Y: u32> {
1313

1414
fn a<'a, 'b>() {
1515
let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
16-
//[full]~^ ERROR mismatched types
17-
//[min]~^^ ERROR mismatched types
16+
//~^ ERROR mismatched types
1817
let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
19-
//[full]~^ ERROR mismatched types
20-
//[min]~^^ ERROR mismatched types
18+
//~^ ERROR mismatched types
2119
}
2220

2321
pub fn main() {}

0 commit comments

Comments
 (0)