Skip to content

Commit 9838591

Browse files
authored
Rollup merge of #138518 - yotamofek:pr/hir-lint-typo, r=compiler-errors
Fix typo in hir lowering lint diag
2 parents 7977592 + e6f7ab5 commit 9838591

8 files changed

+16
-14
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,16 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
411411
Applicability::MachineApplicable,
412412
);
413413
if !is_dyn_compatible {
414-
diag.note(format!("`{trait_name}` it is dyn-incompatible, so it can't be `dyn`"));
414+
diag.note(format!(
415+
"`{trait_name}` is dyn-incompatible, otherwise a trait object could be used"
416+
));
415417
} else {
416418
// No ampersand in suggestion if it's borrowed already
417419
let (dyn_str, paren_dyn_str) =
418420
if borrowed { ("dyn ", "(dyn ") } else { ("&dyn ", "&(dyn ") };
419421

420422
let sugg = if let hir::TyKind::TraitObject([_, _, ..], _) = self_ty.kind {
421-
// There are more than one trait bound, we need surrounding parentheses.
423+
// There is more than one trait bound, we need surrounding parentheses.
422424
vec![
423425
(self_ty.span.shrink_to_lo(), paren_dyn_str.to_string()),
424426
(self_ty.span.shrink_to_hi(), ")".to_string()),

tests/ui/dyn-compatibility/avoid-ice-on-warning-2.new.stderr

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

tests/ui/dyn-compatibility/avoid-ice-on-warning-3.new.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
44
LL | trait A { fn g(b: B) -> B; }
55
| ^
66
|
7-
= note: `B` it is dyn-incompatible, so it can't be `dyn`
7+
= note: `B` is dyn-incompatible, otherwise a trait object could be used
88
help: use a new generic type parameter, constrained by `B`
99
|
1010
LL - trait A { fn g(b: B) -> B; }
@@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
3232
LL | trait B { fn f(a: A) -> A; }
3333
| ^
3434
|
35-
= note: `A` it is dyn-incompatible, so it can't be `dyn`
35+
= note: `A` is dyn-incompatible, otherwise a trait object could be used
3636
help: use a new generic type parameter, constrained by `A`
3737
|
3838
LL - trait B { fn f(a: A) -> A; }

tests/ui/rust-2021/ice-return-unsized-can-impl-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
44
LL | fn concrete(b: B) -> B;
55
| ^
66
|
7-
= note: `B` it is dyn-incompatible, so it can't be `dyn`
7+
= note: `B` is dyn-incompatible, otherwise a trait object could be used
88
help: use a new generic type parameter, constrained by `B`
99
|
1010
LL - fn concrete(b: B) -> B;
@@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
3232
LL | fn f(a: A) -> A;
3333
| ^
3434
|
35-
= note: `A` it is dyn-incompatible, so it can't be `dyn`
35+
= note: `A` is dyn-incompatible, otherwise a trait object could be used
3636
help: use a new generic type parameter, constrained by `A`
3737
|
3838
LL - fn f(a: A) -> A;

tests/ui/rust-2021/ice-return-unsized-can-impl.stderr

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

tests/ui/rust-2021/ice-unsized-fn-params-2.stderr

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

tests/ui/rust-2021/ice-unsized-fn-params.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
44
LL | fn g(b: B) -> B;
55
| ^
66
|
7-
= note: `B` it is dyn-incompatible, so it can't be `dyn`
7+
= note: `B` is dyn-incompatible, otherwise a trait object could be used
88
help: use a new generic type parameter, constrained by `B`
99
|
1010
LL - fn g(b: B) -> B;
@@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
3232
LL | fn f(a: A) -> A;
3333
| ^
3434
|
35-
= note: `A` it is dyn-incompatible, so it can't be `dyn`
35+
= note: `A` is dyn-incompatible, otherwise a trait object could be used
3636
help: use a new generic type parameter, constrained by `A`
3737
|
3838
LL - fn f(a: A) -> A;

tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0782]: expected a type, found a trait
44
LL | fn f(a: A) -> A;
55
| ^
66
|
7-
= note: `A` it is dyn-incompatible, so it can't be `dyn`
7+
= note: `A` is dyn-incompatible, otherwise a trait object could be used
88
help: use a new generic type parameter, constrained by `A`
99
|
1010
LL - fn f(a: A) -> A;
@@ -32,7 +32,7 @@ error[E0782]: expected a type, found a trait
3232
LL | fn f(b: B) -> B;
3333
| ^
3434
|
35-
= note: `B` it is dyn-incompatible, so it can't be `dyn`
35+
= note: `B` is dyn-incompatible, otherwise a trait object could be used
3636
help: use a new generic type parameter, constrained by `B`
3737
|
3838
LL - fn f(b: B) -> B;
@@ -60,7 +60,7 @@ error[E0782]: expected a type, found a trait
6060
LL | fn f(&self, c: C) -> C;
6161
| ^
6262
|
63-
= note: `C` it is dyn-incompatible, so it can't be `dyn`
63+
= note: `C` is dyn-incompatible, otherwise a trait object could be used
6464
help: use a new generic type parameter, constrained by `C`
6565
|
6666
LL - fn f(&self, c: C) -> C;

0 commit comments

Comments
 (0)