Skip to content

Commit 3ea12d4

Browse files
committed
Reword E0277 default error message
``` error[E0277]: the trait `Copy` is not implemented for `X` --> $DIR/trait-impl-bound-suggestions.rs:14:52 | LL | fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `X` ```
1 parent af91dd2 commit 3ea12d4

File tree

698 files changed

+1282
-1270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

698 files changed

+1282
-1270
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
29412941
}
29422942
})
29432943
.unwrap_or_else(|| {
2944-
format!("the trait bound `{trait_predicate}` is not satisfied{post_message}")
2944+
if let ty::ImplPolarity::Positive = trait_predicate.polarity() {
2945+
format!(
2946+
"the trait `{}` is not implemented for `{}`{post_message}",
2947+
trait_predicate.print_modifiers_and_trait_path(),
2948+
self.tcx
2949+
.short_ty_string(trait_predicate.skip_binder().self_ty(), &mut None),
2950+
)
2951+
} else {
2952+
// "the trait bound `!Send: T` is not satisfied" reads better than "`!Send` is
2953+
// not implemented for `T`".
2954+
format!("the trait bound `{trait_predicate}` is not satisfied{post_message}")
2955+
}
29452956
})
29462957
}
29472958

tests/incremental/const-generics/hash-tyvid-regression-1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ where
2020
{
2121
use std::convert::TryFrom;
2222
<[T; N.get()]>::try_from(())
23-
//~^ error: the trait bound
24-
//~| error: the trait bound
23+
//~^ ERROR the trait `From<()>` is not implemented for `[T; N.get()]`
24+
//~| ERROR the trait `From<()>` is not implemented for `[T; N.get()]`
2525
//~| error: mismatched types
2626
}
2727

tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ where
1111
C: Delegates<FileCap<{ false }>>,
1212
{
1313
writes_to_specific_path(&cap);
14-
//~^ error: the trait bound
14+
//~^ ERROR the trait `Delegates<FileCap<false>>` is not implemented for `&C`
1515
}
1616

1717
fn writes_to_specific_path<C>(cap: &C)

tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ where
1414
[(); { S * 2 }]: Default;
1515

1616
impl<'a, T, const S: usize> Iterator for BufferIter<'a, T, S> {
17-
//~^ error: the trait bound
18-
//~^^ error: unconstrained generic constant
17+
//~^ ERROR the trait `Default` is not implemented for `[(); { S * 2 }]`
18+
//~| ERROR unconstrained generic constant
1919
type Item = &'a T;
2020

2121
fn next(&mut self) -> Option<Self::Item> {
22-
//~^ error: the trait bound
23-
//~^^ error: unconstrained generic constant
22+
//~^ ERROR the trait `Default` is not implemented for `[(); { S * 2 }]`
23+
//~| ERROR unconstrained generic constant
2424
None
2525
}
2626
}

tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Test {
3434
span: Span,
3535
/// A doc comment
3636
arg: NotIntoDiagnosticArg,
37-
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
37+
//~^ ERROR trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
3838
}
3939

4040
#[derive(Subdiagnostic)]
@@ -44,5 +44,5 @@ struct SubTest {
4444
span: Span,
4545
/// A doc comment
4646
arg: NotIntoDiagnosticArg,
47-
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
47+
//~^ ERROR trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
4848
}

tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
1+
error[E0277]: the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
22
--> $DIR/diagnostic-derive-doc-comment-field.rs:36:10
33
|
44
LL | #[derive(Diagnostic)]
@@ -12,7 +12,7 @@ note: required by a bound in `Diag::<'a, G>::arg`
1212
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
1313
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

15-
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
15+
error[E0277]: the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
1616
--> $DIR/diagnostic-derive-doc-comment-field.rs:46:10
1717
|
1818
LL | #[derive(Subdiagnostic)]

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ struct ArgFieldWithoutSkip {
347347
#[primary_span]
348348
span: Span,
349349
other: Hello,
350-
//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
350+
//~^ ERROR trait `IntoDiagnosticArg` is not implemented for `Hello`
351351
}
352352

353353
#[derive(Diagnostic)]

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ LL | #[derive(Diagnostic)]
618618
|
619619
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
620620

621-
error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
621+
error[E0277]: the trait `IntoDiagnosticArg` is not implemented for `Hello`
622622
--> $DIR/diagnostic-derive.rs:349:12
623623
|
624624
LL | #[derive(Diagnostic)]

tests/ui/allocator/not-an-allocator.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
1+
error[E0277]: the trait `GlobalAlloc` is not implemented for `usize`
22
--> $DIR/not-an-allocator.rs:2:11
33
|
44
LL | #[global_allocator]
@@ -9,7 +9,7 @@ LL | static A: usize = 0;
99
= help: the trait `GlobalAlloc` is implemented for `System`
1010
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

12-
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
12+
error[E0277]: the trait `GlobalAlloc` is not implemented for `usize`
1313
--> $DIR/not-an-allocator.rs:2:11
1414
|
1515
LL | #[global_allocator]
@@ -21,7 +21,7 @@ LL | static A: usize = 0;
2121
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2222
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
2323

24-
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
24+
error[E0277]: the trait `GlobalAlloc` is not implemented for `usize`
2525
--> $DIR/not-an-allocator.rs:2:11
2626
|
2727
LL | #[global_allocator]
@@ -33,7 +33,7 @@ LL | static A: usize = 0;
3333
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3434
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
3535

36-
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
36+
error[E0277]: the trait `GlobalAlloc` is not implemented for `usize`
3737
--> $DIR/not-an-allocator.rs:2:11
3838
|
3939
LL | #[global_allocator]

tests/ui/array-slice-vec/repeat_empty_ok.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ pub struct Header<'a> {
66

77
pub fn test() {
88
let headers = [Header{value: &[]}; 128];
9-
//~^ ERROR the trait bound
9+
//~^ ERROR the trait
1010
}
1111

1212
pub fn test2() {
1313
let headers = [Header{value: &[0]}; 128];
14-
//~^ ERROR the trait bound
14+
//~^ ERROR the trait
1515
}

0 commit comments

Comments
 (0)