Skip to content

Commit

Permalink
Tweak wording
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Dec 7, 2024
1 parent 6277fb0 commit 25ad047
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ pub fn suggest_constraining_type_params<'a>(
trait_names.dedup();
let n = trait_names.len();
let stable = if all_stable { "" } else { "unstable " };
let trait_ = if all_known { "trait" } else { "" };
format!("{stable}{trait_}{} {}", pluralize!(n), match &trait_names[..] {
[t] => t.to_string(),
[ts @ .., last] => format!("{} and {last}", ts.join(", ")),
let trait_ = if all_known { format!("trait{}", pluralize!(n)) } else { String::new() };
format!("{stable}{trait_}{}", match &trait_names[..] {
[t] => format!(" {t}"),
[ts @ .., last] => format!(" {} and {last}", ts.join(", ")),
[] => return false,
},)
} else {
Expand Down Expand Up @@ -531,7 +531,7 @@ pub fn suggest_constraining_type_params<'a>(
let (span, post, suggestion, msg) = suggestions.pop().unwrap();
let msg = match msg {
SuggestChangingConstraintsMessage::RestrictBoundFurther => {
format!("consider further restricting this bound with {post}")
format!("consider further restricting this bound")
}
SuggestChangingConstraintsMessage::RestrictTypeFurther { ty }
| SuggestChangingConstraintsMessage::RestrictType { ty }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LL | trait UnsafeCopy<'a, T: Copy>
LL | where
LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
| ^^^^^^^^^^ required by this bound in `UnsafeCopy`
help: consider further restricting this bound with `<Target = T>`
help: consider further restricting this bound
|
LL | impl<T: Copy + std::ops::Deref<Target = T>> UnsafeCopy<'_, T> for T {
| ++++++++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ note: required by a bound in `UnsafeCopy::Item`
|
LL | type Item<'a>: std::ops::Deref<Target = T>;
| ^^^^^^^^^^ required by this bound in `UnsafeCopy::Item`
help: consider further restricting this bound with `<Target = T>`
help: consider further restricting this bound
|
LL | impl<T: Copy + std::ops::Deref<Target = T>> UnsafeCopy<T> for T {
| ++++++++++++
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/generic-associated-types/missing-bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ note: tuple struct defined here
|
LL | struct A<B>(B);
| ^
help: consider further restricting this bound with `<Output = B>`
help: consider further restricting this bound
|
LL | impl<B> Add for A<B> where B: Add<Output = B> {
| ++++++++++++
Expand All @@ -58,7 +58,7 @@ note: tuple struct defined here
|
LL | struct C<B>(B);
| ^
help: consider further restricting this bound with `<Output = B>`
help: consider further restricting this bound
|
LL | impl<B: Add<Output = B>> Add for C<B> {
| ++++++++++++
Expand Down Expand Up @@ -94,7 +94,7 @@ note: tuple struct defined here
|
LL | struct E<B>(B);
| ^
help: consider further restricting this bound with `<Output = B>`
help: consider further restricting this bound
|
LL | impl<B: Add<Output = B>> Add for E<B> where <B as Add>::Output = B {
| ++++++++++++
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/suggestions/restrict-existing-type-bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LL | Ok(self)
| this argument influences the type of `Ok`
note: tuple variant defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
help: consider further restricting this bound with `<Output = T>`
help: consider further restricting this bound
|
LL | impl<T: TryAdd<Output = T>> TryAdd for Option<T> {
| ++++++++++++
Expand All @@ -47,7 +47,7 @@ LL | Ok(self)
| this argument influences the type of `Ok`
note: tuple variant defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
help: consider further restricting this bound with `, Output = T`
help: consider further restricting this bound
|
LL | impl<T: TryAdd<Error = X, Output = T>> TryAdd for Other<T> {
| ++++++++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | return a.bar();
= note: expected type parameter `B`
found associated type `<A as MyTrait>::T`
= note: the caller chooses a type for `B` which can be different from `<A as MyTrait>::T`
help: consider further restricting this bound with `<T = B>`
help: consider further restricting this bound
|
LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B {
| +++++++
Expand Down

0 comments on commit 25ad047

Please sign in to comment.