mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Don't add a note for implementing a trait if its inner type is erroneous
This commit is contained in:
parent
cef44f5303
commit
715d4a8949
@ -371,23 +371,28 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
if !candidate_set.ambiguous && no_candidates_apply {
|
||||
let trait_ref = stack.obligation.predicate.skip_binder().trait_ref;
|
||||
let self_ty = trait_ref.self_ty();
|
||||
let (trait_desc, self_desc) = with_no_trimmed_paths!({
|
||||
let trait_desc = trait_ref.print_only_trait_path().to_string();
|
||||
let self_desc = if self_ty.has_concrete_skeleton() {
|
||||
Some(self_ty.to_string())
|
||||
if !trait_ref.references_error() {
|
||||
let self_ty = trait_ref.self_ty();
|
||||
let (trait_desc, self_desc) = with_no_trimmed_paths!({
|
||||
let trait_desc = trait_ref.print_only_trait_path().to_string();
|
||||
let self_desc = if self_ty.has_concrete_skeleton() {
|
||||
Some(self_ty.to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
(trait_desc, self_desc)
|
||||
});
|
||||
let cause = if let Conflict::Upstream = conflict {
|
||||
IntercrateAmbiguityCause::UpstreamCrateUpdate {
|
||||
trait_desc,
|
||||
self_desc,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc }
|
||||
};
|
||||
(trait_desc, self_desc)
|
||||
});
|
||||
let cause = if let Conflict::Upstream = conflict {
|
||||
IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_desc, self_desc }
|
||||
} else {
|
||||
IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc }
|
||||
};
|
||||
debug!(?cause, "evaluate_stack: pushing cause");
|
||||
self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
|
||||
debug!(?cause, "evaluate_stack: pushing cause");
|
||||
self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
src/test/ui/trait-bounds/impl-bound-with-references-error.rs
Normal file
20
src/test/ui/trait-bounds/impl-bound-with-references-error.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Regression test for #105138.
|
||||
// This test ensures that the compiler does not add note
|
||||
// for implementation of trait whose inner type is erroneous.
|
||||
|
||||
pub enum LabelText {
|
||||
Plain,
|
||||
}
|
||||
|
||||
impl<T> From<T> for LabelText
|
||||
//~^ ERROR conflicting implementations of trait `From<LabelText>` for type `LabelText` [E0119]
|
||||
where
|
||||
T: Into<Cow<'static, str>>,
|
||||
//~^ ERROR cannot find type `Cow` in this scope [E0412]
|
||||
{
|
||||
fn from(text: T) -> Self {
|
||||
LabelText::Plain(text.into())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,24 @@
|
||||
error[E0412]: cannot find type `Cow` in this scope
|
||||
--> $DIR/impl-bound-with-references-error.rs:12:13
|
||||
|
|
||||
LL | T: Into<Cow<'static, str>>,
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: consider importing this enum
|
||||
|
|
||||
LL | use std::borrow::Cow;
|
||||
|
|
||||
|
||||
error[E0119]: conflicting implementations of trait `From<LabelText>` for type `LabelText`
|
||||
--> $DIR/impl-bound-with-references-error.rs:9:1
|
||||
|
|
||||
LL | impl<T> From<T> for LabelText
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: conflicting implementation in crate `core`:
|
||||
- impl<T> From<T> for T;
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0119, E0412.
|
||||
For more information about an error, try `rustc --explain E0119`.
|
Loading…
Reference in New Issue
Block a user