mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Account for rustc_on_unimplemented
This commit is contained in:
parent
0f7f2346a6
commit
7a2f3ee73f
@ -776,6 +776,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
&mut err,
|
&mut err,
|
||||||
&trait_ref,
|
&trait_ref,
|
||||||
points_at_arg,
|
points_at_arg,
|
||||||
|
have_alt_message,
|
||||||
) {
|
) {
|
||||||
self.note_obligation_cause(&mut err, obligation);
|
self.note_obligation_cause(&mut err, obligation);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -1318,6 +1319,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
err: &mut DiagnosticBuilder<'tcx>,
|
err: &mut DiagnosticBuilder<'tcx>,
|
||||||
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
|
has_custom_message: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if !points_at_arg {
|
if !points_at_arg {
|
||||||
return false;
|
return false;
|
||||||
@ -1346,14 +1348,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
// original type obligation, not the last one that failed, which is arbitrary.
|
// original type obligation, not the last one that failed, which is arbitrary.
|
||||||
// Because of this, we modify the error to refer to the original obligation and
|
// Because of this, we modify the error to refer to the original obligation and
|
||||||
// return early in the caller.
|
// return early in the caller.
|
||||||
err.message = vec![(
|
let msg = format!(
|
||||||
format!(
|
"the trait bound `{}: {}` is not satisfied",
|
||||||
"the trait bound `{}: {}` is not satisfied",
|
found,
|
||||||
found,
|
obligation.parent_trait_ref.skip_binder(),
|
||||||
obligation.parent_trait_ref.skip_binder(),
|
);
|
||||||
),
|
if has_custom_message {
|
||||||
Style::NoStyle,
|
err.note(&msg);
|
||||||
)];
|
} else {
|
||||||
|
err.message = vec![(msg, Style::NoStyle)];
|
||||||
|
}
|
||||||
if snippet.starts_with('&') {
|
if snippet.starts_with('&') {
|
||||||
// This is already a literal borrow and the obligation is failing
|
// This is already a literal borrow and the obligation is failing
|
||||||
// somewhere else in the obligation chain. Do not suggest non-sense.
|
// somewhere else in the obligation chain. Do not suggest non-sense.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied
|
error[E0277]: the trait bound `std::boxed::Box<{integer}>: Foo` is not satisfied
|
||||||
--> $DIR/kindck-inherited-copy-bound.rs:21:16
|
--> $DIR/kindck-inherited-copy-bound.rs:21:16
|
||||||
|
|
|
|
||||||
LL | fn take_param<T:Foo>(foo: &T) { }
|
LL | fn take_param<T:Foo>(foo: &T) { }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error[E0277]: the trait bound `std::string::String: std::str::pattern::Pattern<'_>` is not satisfied
|
error[E0277]: expected a `std::ops::FnMut<(char,)>` closure, found `std::string::String`
|
||||||
--> $DIR/issue-62843.rs:4:32
|
--> $DIR/issue-62843.rs:4:32
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", line.find(pattern));
|
LL | println!("{:?}", line.find(pattern));
|
||||||
@ -7,6 +7,7 @@ LL | println!("{:?}", line.find(pattern));
|
|||||||
| expected an implementor of trait `std::str::pattern::Pattern<'_>`
|
| expected an implementor of trait `std::str::pattern::Pattern<'_>`
|
||||||
| help: consider borrowing here: `&pattern`
|
| help: consider borrowing here: `&pattern`
|
||||||
|
|
|
|
||||||
|
= note: the trait bound `std::string::String: std::str::pattern::Pattern<'_>` is not satisfied
|
||||||
= note: required because of the requirements on the impl of `std::str::pattern::Pattern<'_>` for `std::string::String`
|
= note: required because of the requirements on the impl of `std::str::pattern::Pattern<'_>` for `std::string::String`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
@ -46,7 +46,7 @@ fn dummy2() {
|
|||||||
impl !Send for TestType {}
|
impl !Send for TestType {}
|
||||||
|
|
||||||
is_send(Box::new(TestType));
|
is_send(Box::new(TestType));
|
||||||
//~^ ERROR the trait bound `dummy2::TestType: std::marker::Send` is not satisfied
|
//~^ ERROR `dummy2::TestType` cannot be sent between threads safely
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dummy3() {
|
fn dummy3() {
|
||||||
@ -64,5 +64,5 @@ fn main() {
|
|||||||
// This will complain about a missing Send impl because `Sync` is implement *just*
|
// This will complain about a missing Send impl because `Sync` is implement *just*
|
||||||
// for T that are `Send`. Look at #20366 and #19950
|
// for T that are `Send`. Look at #20366 and #19950
|
||||||
is_sync(Outer2(TestType));
|
is_sync(Outer2(TestType));
|
||||||
//~^ ERROR the trait bound `main::TestType: std::marker::Sync` is not satisfied
|
//~^ ERROR `main::TestType` cannot be sent between threads safely
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ LL | is_send((8, TestType));
|
|||||||
= help: within `({integer}, dummy1c::TestType)`, the trait `std::marker::Send` is not implemented for `dummy1c::TestType`
|
= help: within `({integer}, dummy1c::TestType)`, the trait `std::marker::Send` is not implemented for `dummy1c::TestType`
|
||||||
= note: required because it appears within the type `({integer}, dummy1c::TestType)`
|
= note: required because it appears within the type `({integer}, dummy1c::TestType)`
|
||||||
|
|
||||||
error[E0277]: the trait bound `dummy2::TestType: std::marker::Send` is not satisfied
|
error[E0277]: `dummy2::TestType` cannot be sent between threads safely
|
||||||
--> $DIR/traits-negative-impls.rs:48:13
|
--> $DIR/traits-negative-impls.rs:48:13
|
||||||
|
|
|
|
||||||
LL | fn is_send<T: Send>(_: T) {}
|
LL | fn is_send<T: Send>(_: T) {}
|
||||||
@ -55,6 +55,7 @@ LL | is_send(Box::new(TestType));
|
|||||||
| expected an implementor of trait `std::marker::Send`
|
| expected an implementor of trait `std::marker::Send`
|
||||||
| help: consider borrowing here: `&Box::new(TestType)`
|
| help: consider borrowing here: `&Box::new(TestType)`
|
||||||
|
|
|
|
||||||
|
= note: the trait bound `dummy2::TestType: std::marker::Send` is not satisfied
|
||||||
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dummy2::TestType>`
|
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dummy2::TestType>`
|
||||||
= note: required because it appears within the type `std::boxed::Box<dummy2::TestType>`
|
= note: required because it appears within the type `std::boxed::Box<dummy2::TestType>`
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ LL | is_send(Box::new(Outer2(TestType)));
|
|||||||
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<Outer2<dummy3::TestType>>`
|
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<Outer2<dummy3::TestType>>`
|
||||||
= note: required because it appears within the type `std::boxed::Box<Outer2<dummy3::TestType>>`
|
= note: required because it appears within the type `std::boxed::Box<Outer2<dummy3::TestType>>`
|
||||||
|
|
||||||
error[E0277]: the trait bound `main::TestType: std::marker::Sync` is not satisfied
|
error[E0277]: `main::TestType` cannot be sent between threads safely
|
||||||
--> $DIR/traits-negative-impls.rs:66:13
|
--> $DIR/traits-negative-impls.rs:66:13
|
||||||
|
|
|
|
||||||
LL | fn is_sync<T: Sync>(_: T) {}
|
LL | fn is_sync<T: Sync>(_: T) {}
|
||||||
@ -84,6 +85,7 @@ LL | is_sync(Outer2(TestType));
|
|||||||
| expected an implementor of trait `std::marker::Sync`
|
| expected an implementor of trait `std::marker::Sync`
|
||||||
| help: consider borrowing here: `&Outer2(TestType)`
|
| help: consider borrowing here: `&Outer2(TestType)`
|
||||||
|
|
|
|
||||||
|
= note: the trait bound `main::TestType: std::marker::Sync` is not satisfied
|
||||||
= note: required because of the requirements on the impl of `std::marker::Sync` for `Outer2<main::TestType>`
|
= note: required because of the requirements on the impl of `std::marker::Sync` for `Outer2<main::TestType>`
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
Loading…
Reference in New Issue
Block a user