Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #133783

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
72d2db7
Implement lint against `Symbol::intern` on a string literal
clubby789 Nov 27, 2024
71b698c
Replace `Symbol::intern` calls with preinterned symbols
clubby789 Nov 27, 2024
0554993
Don't suggest restricting bound with unstable traits on stable
estebank Nov 27, 2024
e3dfae8
reword trait bound suggestion message to include the bounds
estebank Nov 28, 2024
7e38a45
Add test for lack of suggestion in stable
estebank Nov 28, 2024
c34079a
Use trait name instead of full constraint in suggestion message
estebank Nov 28, 2024
5c9e5d1
Mention type parameter in more cases and don't suggest ~const bound a…
estebank Nov 28, 2024
442ec3d
Account for `impl Trait` in "add bound" suggestion message
estebank Nov 28, 2024
055dbc5
fix rustdoc test
estebank Nov 28, 2024
6b758e2
Do not talk about "trait `<Foo = Bar>`"
estebank Nov 28, 2024
05e6714
Use run-make `diff` output for stable output test
estebank Nov 29, 2024
2d61c09
reduce false positives on some common cases from if-let-rescope
dingxiangfei2009 Dec 2, 2024
69a9312
Stabilize noop_waker
eholk Nov 16, 2024
2b88e4c
stabilize const_{size,align}_of_val
RalfJung Dec 2, 2024
2f45ea5
rustc_const_stable not needed for consts
eholk Dec 2, 2024
0609b99
Structurally resolve in probe_adt
compiler-errors Nov 28, 2024
ebb9a38
document -Zrandomize-layout in the unstable book
the8472 Dec 2, 2024
2807ba7
Use correct `hir_id` for array const arg infers
BoxyUwU Dec 3, 2024
7167e68
Rollup merge of #133089 - eholk:stabilize-noop-waker, r=dtolnay
matthiaskrgr Dec 3, 2024
fec05e2
Rollup merge of #133522 - estebank:dont-suggest-unstable-trait, r=com…
matthiaskrgr Dec 3, 2024
fa58c6b
Rollup merge of #133545 - clubby789:symbol-intern-lit, r=jieyouxu
matthiaskrgr Dec 3, 2024
69f63ed
Rollup merge of #133558 - compiler-errors:structurally-resolve-probe-…
matthiaskrgr Dec 3, 2024
139e402
Rollup merge of #133753 - dingxiangfei2009:reduce-false-positive-if-l…
matthiaskrgr Dec 3, 2024
0044daa
Rollup merge of #133762 - RalfJung:const-size-of-val, r=workingjubilee
matthiaskrgr Dec 3, 2024
d00ed3e
Rollup merge of #133777 - the8472:document-randomize-layout, r=jieyouxu
matthiaskrgr Dec 3, 2024
0b5f3f1
Rollup merge of #133779 - BoxyUwU:array_const_arg_infer_hir_id, r=com…
matthiaskrgr Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for lack of suggestion in stable
This test will break when `Step` gets stabilized, but punt until then.
  • Loading branch information
estebank committed Nov 28, 2024
commit 7e38a45aaff258f3c545b720174eb7079aa4f8e7
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -488,7 +488,7 @@ pub fn suggest_constraining_type_params<'a>(
.into_iter()
.filter(|(span, _, _, _)| !span.in_derive_expansion())
.collect::<Vec<_>>();

let suggested = !suggestions.is_empty();
if suggestions.len() == 1 {
let (span, constraint, suggestion, msg) = suggestions.pop().unwrap();
let post = format!(
@@ -524,7 +524,7 @@ pub fn suggest_constraining_type_params<'a>(
);
}

true
suggested
}

/// Collect al types that have an implicit `'static` obligation that we could suggest `'_` for.
4 changes: 4 additions & 0 deletions tests/run-make/missing-unstable-trait-bound/missing-bound.rs
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() {}
22 changes: 22 additions & 0 deletions tests/run-make/missing-unstable-trait-bound/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ 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::{rust_lib_name, rustc};

fn main() {
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`"#,
);
}
6 changes: 5 additions & 1 deletion tests/ui/trait-bounds/unstable-trait-suggestion.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,11 @@ pub trait Unstable {}
fn foo<T: Unstable>(_: T) {}

#[stable(feature = "unit_test", since = "1.0.0")]
pub fn demo<T>(t: T) { //~ HELP consider restricting type parameter `T` with unstable trait `Unstable`
pub fn bar<T>(t: T) { //~ HELP consider restricting type parameter `T` with unstable trait `Unstable`
foo(t) //~ ERROR E0277
}
#[stable(feature = "unit_test", since = "1.0.0")]
pub fn baz<T>(t: std::ops::Range<T>) { //~ HELP consider restricting type parameter `T` with unstable trait
for _ in t {} //~ ERROR E0277
}
fn main() {}
19 changes: 16 additions & 3 deletions tests/ui/trait-bounds/unstable-trait-suggestion.stderr
Original file line number Diff line number Diff line change
@@ -13,9 +13,22 @@ LL | fn foo<T: Unstable>(_: T) {}
| ^^^^^^^^ required by this bound in `foo`
help: consider restricting type parameter `T` with unstable trait `Unstable`
|
LL | pub fn demo<T: Unstable>(t: T) {
| ++++++++++
LL | pub fn bar<T: Unstable>(t: T) {
| ++++++++++

error: aborting due to 1 previous error
error[E0277]: the trait bound `T: Step` is not satisfied
--> $DIR/unstable-trait-suggestion.rs:17:14
|
LL | 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`
help: consider restricting type parameter `T` with unstable trait `std::iter::Step`
|
LL | pub fn baz<T: std::iter::Step>(t: std::ops::Range<T>) {
| +++++++++++++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.