Skip to content

Commit 0f5c221

Browse files
committed
Regression test for "unstable" traits in force-unstable builds
1 parent 1396514 commit 0f5c221

4 files changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ edition: 2024
2+
//@ compile-flags: -Zforce-unstable-if-unmarked
3+
4+
// Auxiliary crate that uses `-Zforce-unstable-if-unmarked` to export an
5+
// "unstable" trait.
6+
7+
pub trait ForeignTrait {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0277]: the trait bound `(): LocalTrait` is not satisfied
2+
--> $DIR/nightly-only-unstable.rs:25:21
3+
|
4+
LL | use_local_trait(());
5+
| --------------- ^^ the nightly-only, unstable trait `LocalTrait` is not implemented for `()`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
help: this trait has no implementations, consider adding one
10+
--> $DIR/nightly-only-unstable.rs:14:1
11+
|
12+
LL | trait LocalTrait {}
13+
| ^^^^^^^^^^^^^^^^
14+
note: required by a bound in `use_local_trait`
15+
--> $DIR/nightly-only-unstable.rs:16:28
16+
|
17+
LL | fn use_local_trait(_: impl LocalTrait) {}
18+
| ^^^^^^^^^^ required by this bound in `use_local_trait`
19+
20+
error[E0277]: the trait bound `(): ForeignTrait` is not satisfied
21+
--> $DIR/nightly-only-unstable.rs:31:23
22+
|
23+
LL | use_foreign_trait(());
24+
| ----------------- ^^ the nightly-only, unstable trait `ForeignTrait` is not implemented for `()`
25+
| |
26+
| required by a bound introduced by this call
27+
|
28+
note: required by a bound in `use_foreign_trait`
29+
--> $DIR/nightly-only-unstable.rs:20:30
30+
|
31+
LL | fn use_foreign_trait(_: impl force_unstable::ForeignTrait) {}
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `use_foreign_trait`
33+
34+
error: aborting due to 2 previous errors
35+
36+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0277]: the trait bound `(): LocalTrait` is not satisfied
2+
--> $DIR/nightly-only-unstable.rs:25:21
3+
|
4+
LL | use_local_trait(());
5+
| --------------- ^^ the trait `LocalTrait` is not implemented for `()`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
help: this trait has no implementations, consider adding one
10+
--> $DIR/nightly-only-unstable.rs:14:1
11+
|
12+
LL | trait LocalTrait {}
13+
| ^^^^^^^^^^^^^^^^
14+
note: required by a bound in `use_local_trait`
15+
--> $DIR/nightly-only-unstable.rs:16:28
16+
|
17+
LL | fn use_local_trait(_: impl LocalTrait) {}
18+
| ^^^^^^^^^^ required by this bound in `use_local_trait`
19+
20+
error[E0277]: the trait bound `(): ForeignTrait` is not satisfied
21+
--> $DIR/nightly-only-unstable.rs:31:23
22+
|
23+
LL | use_foreign_trait(());
24+
| ----------------- ^^ the nightly-only, unstable trait `ForeignTrait` is not implemented for `()`
25+
| |
26+
| required by a bound introduced by this call
27+
|
28+
note: required by a bound in `use_foreign_trait`
29+
--> $DIR/nightly-only-unstable.rs:20:30
30+
|
31+
LL | fn use_foreign_trait(_: impl force_unstable::ForeignTrait) {}
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `use_foreign_trait`
33+
34+
error: aborting due to 2 previous errors
35+
36+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//@ revisions: normal force
2+
//@ edition: 2024
3+
//@ aux-crate: force_unstable=force_unstable.rs
4+
//@[force] compile-flags: -Zforce-unstable-if-unmarked
5+
6+
#![feature(rustc_private)]
7+
8+
// Regression test for <https://github.com/rust-lang/rust/issues/152692>.
9+
//
10+
// When building a crate with `-Zforce-unstable-if-unmarked` (e.g. the compiler or stdlib),
11+
// it's unhelpful to mention that a not-implemented trait is unstable, because that will
12+
// be true of every local and foreign trait that isn't explicitly marked stable.
13+
14+
trait LocalTrait {}
15+
16+
fn use_local_trait(_: impl LocalTrait) {}
17+
//~^ NOTE required by a bound in `use_local_trait`
18+
//~| NOTE required by this bound in `use_local_trait`
19+
20+
fn use_foreign_trait(_: impl force_unstable::ForeignTrait) {}
21+
//~^ NOTE required by a bound in `use_foreign_trait`
22+
//~| NOTE required by this bound in `use_foreign_trait`
23+
24+
fn main() {
25+
use_local_trait(());
26+
//~^ ERROR the trait bound `(): LocalTrait` is not satisfied
27+
//[normal]~| NOTE the trait `LocalTrait` is not implemented for `()`
28+
//[force]~| NOTE the nightly-only, unstable trait `LocalTrait` is not implemented for `()`
29+
//~| NOTE required by a bound introduced by this call
30+
31+
use_foreign_trait(());
32+
//~^ ERROR the trait bound `(): ForeignTrait` is not satisfied
33+
//[normal]~| NOTE the nightly-only, unstable trait `ForeignTrait` is not implemented for `()`
34+
//[force]~| NOTE the nightly-only, unstable trait `ForeignTrait` is not implemented for `()`
35+
//~| NOTE required by a bound introduced by this call
36+
}

0 commit comments

Comments
 (0)