Skip to content

Commit d746230

Browse files
committed
tests: add #![rustc_no_implicit_bounds]
After reviewing all tests with `?Sized`, these tests seem like they could probably benefit from `#![rustc_no_implicit_bounds]`. - Skipping most of `tests/ui/unsized` as these seem to want to test `?Sized` - Skipping tests that used `Box<T>` because it's still bound by `T: MetaSized` - Skipping parsing or other tests that cared about `?Sized` syntactically - Skipping tests for `derive(CoercePointee)` because this appears to check that the pointee type is relaxed with `?Sized` explicitly
1 parent 01915a7 commit d746230

File tree

92 files changed

+507
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+507
-394
lines changed

tests/ui/cast/cast-rfc0401-vtable-kinds.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//@ run-pass
2+
3+
#![feature(rustc_attrs)]
4+
#![rustc_no_implicit_bounds]
5+
26
// Check that you can cast between different pointers to trait objects
37
// whose vtable have the same kind (both lengths, or both trait pointers).
48

@@ -9,11 +13,11 @@ trait Bar { //~ WARN trait `Bar` is never used
913
impl Bar for () {}
1014

1115
#[repr(C)]
12-
struct FooS<T:?Sized>(T);
16+
struct FooS<T>(T);
1317
#[repr(C)]
14-
struct BarS<T:?Sized>(T);
18+
struct BarS<T>(T);
1519

16-
fn foo_to_bar<T:?Sized>(u: *const FooS<T>) -> *const BarS<T> {
20+
fn foo_to_bar<T>(u: *const FooS<T>) -> *const BarS<T> {
1721
u as *const BarS<T>
1822
}
1923

tests/ui/cast/cast-rfc0401-vtable-kinds.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: trait `Bar` is never used
2-
--> $DIR/cast-rfc0401-vtable-kinds.rs:5:7
2+
--> $DIR/cast-rfc0401-vtable-kinds.rs:9:7
33
|
44
LL | trait Bar {
55
| ^^^

tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.current.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:27
2+
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:26:27
33
|
44
LL | fn m<'a>() {
55
| -- lifetime `'a` defined here

tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:27
2+
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:26:27
33
|
44
LL | fn m<'a>() {
55
| -- lifetime `'a` defined here

tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
//@ ignore-compare-mode-next-solver (explicit revisions)
33
//@[next] compile-flags: -Znext-solver
44
//@ check-fail
5-
//
5+
#![feature(rustc_attrs)]
6+
#![rustc_no_implicit_bounds]
7+
68
// Make sure we can't trick the compiler by using a projection.
79

810
trait Cat<'a> {}
911
impl Cat<'_> for () {}
1012

1113
trait Id {
12-
type Id: ?Sized;
14+
type Id;
1315
}
14-
impl<T: ?Sized> Id for T {
16+
impl<T> Id for T {
1517
type Id = T;
1618
}
1719

18-
struct S<T: ?Sized> {
20+
struct S<T> {
1921
tail: <T as Id>::Id,
2022
}
2123

tests/ui/coercion/codegen-smart-pointer-with-alias.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88
// system, which isn't guaranteed to be normalized after substitution.
99

1010
#![feature(coerce_unsized)]
11+
#![feature(rustc_attrs)]
12+
#![rustc_no_implicit_bounds]
1113

1214
use std::ops::CoerceUnsized;
1315

1416
trait Mirror {
15-
type Assoc: ?Sized;
17+
type Assoc;
1618
}
17-
impl<T: ?Sized> Mirror for T {
19+
impl<T> Mirror for T {
1820
type Assoc = T;
1921
}
2022

2123
trait Any {}
2224
impl<T> Any for T {}
2325

24-
struct Signal<'a, T: ?Sized>(<&'a T as Mirror>::Assoc);
26+
struct Signal<'a, T>(<&'a T as Mirror>::Assoc);
2527

2628
// This `CoerceUnsized` impl isn't special; it's a bit more restricted than we'd see in the wild,
2729
// but this ICE also reproduces if we were to make it general over `Signal<T> -> Signal<U>`.

tests/ui/coercion/issue-26905-rpass.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
//@ run-pass
22
#![feature(unsize, coerce_unsized)]
3+
#![feature(rustc_attrs)]
4+
#![rustc_no_implicit_bounds]
35

46
// Verfies that PhantomData is ignored for DST coercions
57

68
use std::marker::{Unsize, PhantomData};
79
use std::ops::CoerceUnsized;
810

9-
struct MyRc<T: ?Sized> {
11+
struct MyRc<T> {
1012
_ptr: *const T,
1113
_boo: PhantomData<T>,
1214
}
1315

14-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{ }
16+
impl<T: Unsize<U>, U> CoerceUnsized<MyRc<U>> for MyRc<T>{ }
1517

1618
fn main() {
1719
let data = [1, 2, 3];

tests/ui/coercion/issue-26905.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#![feature(unsize, coerce_unsized)]
2+
#![feature(rustc_attrs)]
3+
#![rustc_no_implicit_bounds]
24

35
// Verfies that non-PhantomData ZSTs still cause coercions to fail.
46
// They might have additional semantics that we don't want to bulldoze.
57

68
use std::marker::{Unsize, PhantomData};
79
use std::ops::CoerceUnsized;
810

9-
struct NotPhantomData<T: ?Sized>(PhantomData<T>);
11+
struct NotPhantomData<T>(PhantomData<T>);
1012

11-
struct MyRc<T: ?Sized> {
13+
struct MyRc<T> {
1214
_ptr: *const T,
1315
_boo: NotPhantomData<T>,
1416
}
1517

16-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{ } //~ERROR
18+
impl<T: Unsize<U>, U> CoerceUnsized<MyRc<U>> for MyRc<T>{ } //~ERROR
1719

1820
fn main() {
1921
let data = [1, 2, 3];

tests/ui/coercion/issue-26905.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0375]: implementing `CoerceUnsized` does not allow multiple fields to be coerced
2-
--> $DIR/issue-26905.rs:16:40
2+
--> $DIR/issue-26905.rs:18:23
33
|
4-
LL | impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{ }
5-
| ^^^^^^^^^^^^^^^^^^^^^^
4+
LL | impl<T: Unsize<U>, U> CoerceUnsized<MyRc<U>> for MyRc<T>{ }
5+
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: the trait `CoerceUnsized` may only be implemented when a single field is being coerced
8-
--> $DIR/issue-26905.rs:12:5
8+
--> $DIR/issue-26905.rs:14:5
99
|
1010
LL | _ptr: *const T,
1111
| ^^^^^^^^^^^^^^

tests/ui/coercion/sub-principals.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
// a non-higer-ranked instantiation.
88

99
#![feature(unsize)]
10+
#![feature(rustc_attrs)]
11+
#![rustc_no_implicit_bounds]
1012

1113
use std::marker::Unsize;
1214

13-
fn test<T: ?Sized, U: ?Sized>()
15+
fn test<T, U>()
1416
where
1517
T: Unsize<U>,
1618
{

tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.explicit.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error: conflicting implementations of trait `FnMarker` for type `fn(&_)`
2-
--> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:21:1
2+
--> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:23:1
33
|
4-
LL | impl<T: ?Sized + Marker> FnMarker for fn(T) {}
5-
| ------------------------------------------- first implementation here
6-
LL | impl<T: ?Sized> FnMarker for fn(&T) {}
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&_)`
4+
LL | impl<T: Marker> FnMarker for fn(T) {}
5+
| ---------------------------------- first implementation here
6+
LL | impl<T> FnMarker for fn(&T) {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&_)`
88
|
99
= warning: the behavior may change in a future release
1010
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>

tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33

44
#![forbid(coherence_leak_check)]
55
#![feature(negative_impls, with_negative_coherence)]
6+
#![feature(rustc_attrs)]
7+
#![rustc_no_implicit_bounds]
68

79
pub trait Marker {}
810

911
#[cfg(implicit)]
10-
impl<T: ?Sized> !Marker for &T {}
12+
impl<T> !Marker for &T {}
1113

1214
#[cfg(explicit)]
13-
impl<'a, T: ?Sized + 'a> !Marker for &'a T {}
15+
impl<'a, T: 'a> !Marker for &'a T {}
1416

1517
trait FnMarker {}
1618

1719
// Unifying these two impls below results in a `T: '!0` obligation
1820
// that we shouldn't need to care about. Ideally, we'd treat that
1921
// as an assumption when proving `&'!0 T: Marker`...
20-
impl<T: ?Sized + Marker> FnMarker for fn(T) {}
21-
impl<T: ?Sized> FnMarker for fn(&T) {}
22+
impl<T: Marker> FnMarker for fn(T) {}
23+
impl<T> FnMarker for fn(&T) {}
2224
//[explicit]~^ ERROR conflicting implementations of trait `FnMarker` for type `fn(&_)`
2325
//[explicit]~| WARN the behavior may change in a future release
2426

tests/ui/const-generics/issues/issue-88119.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//@ compile-flags: -Znext-solver
33
#![allow(incomplete_features)]
44
#![feature(const_trait_impl, generic_const_exprs)]
5+
#![feature(rustc_attrs)]
6+
#![rustc_no_implicit_bounds]
57

68
#[const_trait]
79
trait ConstName {
@@ -12,18 +14,18 @@ impl const ConstName for u8 {
1214
const NAME_BYTES: &'static [u8] = b"u8";
1315
}
1416

15-
const fn name_len<T: ?Sized + ConstName>() -> usize {
17+
const fn name_len<T: ConstName>() -> usize {
1618
T::NAME_BYTES.len()
1719
}
1820

19-
impl<T: ?Sized + ConstName> const ConstName for &T
21+
impl<T: ConstName> const ConstName for &T
2022
where
2123
[(); name_len::<T>()]:,
2224
{
2325
const NAME_BYTES: &'static [u8] = b"&T";
2426
}
2527

26-
impl<T: ?Sized + ConstName> const ConstName for &mut T
28+
impl<T: ConstName> const ConstName for &mut T
2729
where
2830
[(); name_len::<T>()]:,
2931
{

tests/ui/const-generics/issues/issue-88119.stderr

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,85 +7,85 @@ LL | #![feature(const_trait_impl, generic_const_exprs)]
77
= help: remove one of these features
88

99
error[E0275]: overflow evaluating the requirement `&T: ~const ConstName`
10-
--> $DIR/issue-88119.rs:19:49
10+
--> $DIR/issue-88119.rs:21:40
1111
|
12-
LL | impl<T: ?Sized + ConstName> const ConstName for &T
13-
| ^^
12+
LL | impl<T: ConstName> const ConstName for &T
13+
| ^^
1414

1515
error[E0275]: overflow evaluating the requirement `&T: ConstName`
16-
--> $DIR/issue-88119.rs:19:49
16+
--> $DIR/issue-88119.rs:21:40
1717
|
18-
LL | impl<T: ?Sized + ConstName> const ConstName for &T
19-
| ^^
18+
LL | impl<T: ConstName> const ConstName for &T
19+
| ^^
2020

2121
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
22-
--> $DIR/issue-88119.rs:21:5
22+
--> $DIR/issue-88119.rs:23:5
2323
|
2424
LL | [(); name_len::<T>()]:,
2525
| ^^^^^^^^^^^^^^^^^^^^^
2626
|
2727
note: required by a bound in `<&T as ConstName>`
28-
--> $DIR/issue-88119.rs:21:5
28+
--> $DIR/issue-88119.rs:23:5
2929
|
3030
LL | [(); name_len::<T>()]:,
3131
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
3232

3333
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
34-
--> $DIR/issue-88119.rs:21:10
34+
--> $DIR/issue-88119.rs:23:10
3535
|
3636
LL | [(); name_len::<T>()]:,
3737
| ^^^^^^^^^^^^^^^
3838
|
3939
note: required by a bound in `<&T as ConstName>`
40-
--> $DIR/issue-88119.rs:21:5
40+
--> $DIR/issue-88119.rs:23:5
4141
|
4242
LL | [(); name_len::<T>()]:,
4343
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
4444

4545
error[E0275]: overflow evaluating the requirement `&mut T: ~const ConstName`
46-
--> $DIR/issue-88119.rs:26:49
46+
--> $DIR/issue-88119.rs:28:40
4747
|
48-
LL | impl<T: ?Sized + ConstName> const ConstName for &mut T
49-
| ^^^^^^
48+
LL | impl<T: ConstName> const ConstName for &mut T
49+
| ^^^^^^
5050

5151
error[E0275]: overflow evaluating the requirement `&mut T: ConstName`
52-
--> $DIR/issue-88119.rs:26:49
52+
--> $DIR/issue-88119.rs:28:40
5353
|
54-
LL | impl<T: ?Sized + ConstName> const ConstName for &mut T
55-
| ^^^^^^
54+
LL | impl<T: ConstName> const ConstName for &mut T
55+
| ^^^^^^
5656

5757
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
58-
--> $DIR/issue-88119.rs:28:5
58+
--> $DIR/issue-88119.rs:30:5
5959
|
6060
LL | [(); name_len::<T>()]:,
6161
| ^^^^^^^^^^^^^^^^^^^^^
6262
|
6363
note: required by a bound in `<&mut T as ConstName>`
64-
--> $DIR/issue-88119.rs:28:5
64+
--> $DIR/issue-88119.rs:30:5
6565
|
6666
LL | [(); name_len::<T>()]:,
6767
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`
6868

6969
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
70-
--> $DIR/issue-88119.rs:28:10
70+
--> $DIR/issue-88119.rs:30:10
7171
|
7272
LL | [(); name_len::<T>()]:,
7373
| ^^^^^^^^^^^^^^^
7474
|
7575
note: required by a bound in `<&mut T as ConstName>`
76-
--> $DIR/issue-88119.rs:28:5
76+
--> $DIR/issue-88119.rs:30:5
7777
|
7878
LL | [(); name_len::<T>()]:,
7979
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`
8080

8181
error[E0275]: overflow evaluating the requirement `&&mut u8: ConstName`
82-
--> $DIR/issue-88119.rs:33:35
82+
--> $DIR/issue-88119.rs:35:35
8383
|
8484
LL | pub const ICE_1: &'static [u8] = <&&mut u8 as ConstName>::NAME_BYTES;
8585
| ^^^^^^^^
8686

8787
error[E0275]: overflow evaluating the requirement `&mut &u8: ConstName`
88-
--> $DIR/issue-88119.rs:34:35
88+
--> $DIR/issue-88119.rs:36:35
8989
|
9090
LL | pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES;
9191
| ^^^^^^^^

tests/ui/consts/issue-67529.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//@ compile-flags: -Z mir-opt-level=3
22
//@ run-pass
33

4-
struct Baz<T: ?Sized> {
4+
#![feature(rustc_attrs)]
5+
#![rustc_no_implicit_bounds]
6+
7+
struct Baz<T> {
58
a: T
69
}
710

tests/ui/dst/dst-bad-coerce1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Attempt to change the type as well as unsizing.
2+
#![feature(rustc_attrs)]
3+
#![rustc_no_implicit_bounds]
24

3-
struct Fat<T: ?Sized> {
5+
struct Fat<T> {
46
ptr: T
57
}
68

0 commit comments

Comments
 (0)