forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#133522 - estebank:dont-suggest-unstable-trait…
…, r=compiler-errors Don't suggest restricting bound with unstable traits on stable and mention it's unstable on nightly On nightly, we mention the trait is unstable ``` error[E0277]: the trait bound `T: Unstable` is not satisfied --> $DIR/unstable-trait-suggestion.rs:13:9 | LL | foo(t) | --- ^ the trait `Unstable` is not implemented for `T` | | | required by a bound introduced by this call | note: required by a bound in `foo` --> $DIR/unstable-trait-suggestion.rs:9:11 | LL | fn foo<T: Unstable>(_: T) {} | ^^^^^^^^ required by this bound in `foo` help: consider restricting type parameter `T` but it is an `unstable` trait | LL | pub fn demo<T: Unstable>(t: T) { | ++++++++++ ``` On stable, we don't suggest the trait at all ``` error[E0277]: the trait bound `T: Unstable` is not satisfied --> $DIR/unstable-trait-suggestion.rs:13:9 | LL | foo(t) | --- ^ the trait `Unstable` is not implemented for `T` | | | required by a bound introduced by this call | note: required by a bound in `foo` --> $DIR/unstable-trait-suggestion.rs:9:11 | LL | fn foo<T: Unstable>(_: T) {} | ^^^^^^^^ required by this bound in `foo` ``` Fix rust-lang#133511.
- Loading branch information
Showing
160 changed files
with
486 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub fn baz<T>(t: std::ops::Range<T>) { | ||
for _ in t {} | ||
} | ||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
tests/run-make/missing-unstable-trait-bound/missing-bound.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0277]: the trait bound `T: Step` is not satisfied | ||
--> missing-bound.rs:2:14 | ||
| | ||
2 | for _ in t {} | ||
| ^ the trait `Step` is not implemented for `T` | ||
| | ||
= note: required for `std::ops::Range<T>` to implement `Iterator` | ||
= note: required for `std::ops::Range<T>` to implement `IntoIterator` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@ only-linux | ||
//@ ignore-wasm32 | ||
//@ ignore-wasm64 | ||
// ignore-tidy-linelength | ||
|
||
// Ensure that on stable we don't suggest restricting with an unsafe trait and we continue | ||
// mentioning the rest of the obligation chain. | ||
|
||
use run_make_support::{diff, rust_lib_name, rustc}; | ||
|
||
fn main() { | ||
let out = rustc() | ||
.env("RUSTC_BOOTSTRAP", "-1") | ||
.input("missing-bound.rs") | ||
.run_fail() | ||
.assert_stderr_not_contains("help: consider restricting type parameter `T`") | ||
.assert_stderr_contains( | ||
r#" | ||
= note: required for `std::ops::Range<T>` to implement `Iterator` | ||
= note: required for `std::ops::Range<T>` to implement `IntoIterator`"#, | ||
) | ||
.stderr_utf8(); | ||
diff().expected_file("missing-bound.stderr").actual_text("(stable rustc)", &out).run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.