Rollup merge of #138518 - yotamofek:pr/hir-lint-typo, r=compiler-errors

Fix typo in hir lowering lint diag
This commit is contained in:
León Orell Valerian Liehr 2025-03-15 00:18:27 +01:00 committed by GitHub
commit 9838591694
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 16 additions and 14 deletions

View file

@ -411,14 +411,16 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
Applicability::MachineApplicable,
);
if !is_dyn_compatible {
diag.note(format!("`{trait_name}` it is dyn-incompatible, so it can't be `dyn`"));
diag.note(format!(
"`{trait_name}` is dyn-incompatible, otherwise a trait object could be used"
));
} else {
// No ampersand in suggestion if it's borrowed already
let (dyn_str, paren_dyn_str) =
if borrowed { ("dyn ", "(dyn ") } else { ("&dyn ", "&(dyn ") };
let sugg = if let hir::TyKind::TraitObject([_, _, ..], _) = self_ty.kind {
// There are more than one trait bound, we need surrounding parentheses.
// There is more than one trait bound, we need surrounding parentheses.
vec![
(self_ty.span.shrink_to_lo(), paren_dyn_str.to_string()),
(self_ty.span.shrink_to_hi(), ")".to_string()),

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | fn id<F>(f: Copy) -> usize {
| ^^^^
|
= note: `Copy` it is dyn-incompatible, so it can't be `dyn`
= note: `Copy` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `Copy`
|
LL - fn id<F>(f: Copy) -> usize {

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | trait A { fn g(b: B) -> B; }
| ^
|
= note: `B` it is dyn-incompatible, so it can't be `dyn`
= note: `B` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `B`
|
LL - trait A { fn g(b: B) -> B; }
@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
LL | trait B { fn f(a: A) -> A; }
| ^
|
= note: `A` it is dyn-incompatible, so it can't be `dyn`
= note: `A` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `A`
|
LL - trait B { fn f(a: A) -> A; }

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | fn concrete(b: B) -> B;
| ^
|
= note: `B` it is dyn-incompatible, so it can't be `dyn`
= note: `B` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `B`
|
LL - fn concrete(b: B) -> B;
@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
LL | fn f(a: A) -> A;
| ^
|
= note: `A` it is dyn-incompatible, so it can't be `dyn`
= note: `A` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `A`
|
LL - fn f(a: A) -> A;

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | fn g(new: B) -> B;
| ^
|
= note: `B` it is dyn-incompatible, so it can't be `dyn`
= note: `B` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `B`
|
LL - fn g(new: B) -> B;

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | fn guard(_s: Copy) -> bool {
| ^^^^
|
= note: `Copy` it is dyn-incompatible, so it can't be `dyn`
= note: `Copy` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `Copy`
|
LL - fn guard(_s: Copy) -> bool {

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | fn g(b: B) -> B;
| ^
|
= note: `B` it is dyn-incompatible, so it can't be `dyn`
= note: `B` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `B`
|
LL - fn g(b: B) -> B;
@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
LL | fn f(a: A) -> A;
| ^
|
= note: `A` it is dyn-incompatible, so it can't be `dyn`
= note: `A` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `A`
|
LL - fn f(a: A) -> A;

View file

@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
LL | fn f(a: A) -> A;
| ^
|
= note: `A` it is dyn-incompatible, so it can't be `dyn`
= note: `A` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `A`
|
LL - fn f(a: A) -> A;
@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
LL | fn f(b: B) -> B;
| ^
|
= note: `B` it is dyn-incompatible, so it can't be `dyn`
= note: `B` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `B`
|
LL - fn f(b: B) -> B;
@ -60,7 +60,7 @@ error[E0782]: expected a type, found a trait
LL | fn f(&self, c: C) -> C;
| ^
|
= note: `C` it is dyn-incompatible, so it can't be `dyn`
= note: `C` is dyn-incompatible, otherwise a trait object could be used
help: use a new generic type parameter, constrained by `C`
|
LL - fn f(&self, c: C) -> C;