Skip to content

Commit 2baefd3

Browse files
committed
Move IntercrateAmbiguityCause to librustc_trait_selection.
1 parent e288d05 commit 2baefd3

File tree

2 files changed

+41
-41
lines changed
  • src
    • librustc_middle/traits
    • librustc_trait_selection/traits/select

2 files changed

+41
-41
lines changed

src/librustc_middle/traits/select.rs

-41
Original file line numberDiff line numberDiff line change
@@ -253,44 +253,3 @@ impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
253253
SelectionError::Overflow
254254
}
255255
}
256-
257-
#[derive(Clone, Debug)]
258-
pub enum IntercrateAmbiguityCause {
259-
DownstreamCrate { trait_desc: String, self_desc: Option<String> },
260-
UpstreamCrateUpdate { trait_desc: String, self_desc: Option<String> },
261-
ReservationImpl { message: String },
262-
}
263-
264-
impl IntercrateAmbiguityCause {
265-
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
266-
/// See #23980 for details.
267-
pub fn add_intercrate_ambiguity_hint(&self, err: &mut rustc_errors::DiagnosticBuilder<'_>) {
268-
err.note(&self.intercrate_ambiguity_hint());
269-
}
270-
271-
pub fn intercrate_ambiguity_hint(&self) -> String {
272-
match self {
273-
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
274-
let self_desc = if let &Some(ref ty) = self_desc {
275-
format!(" for type `{}`", ty)
276-
} else {
277-
String::new()
278-
};
279-
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
280-
}
281-
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
282-
let self_desc = if let &Some(ref ty) = self_desc {
283-
format!(" for type `{}`", ty)
284-
} else {
285-
String::new()
286-
};
287-
format!(
288-
"upstream crates may add a new impl of trait `{}`{} \
289-
in future versions",
290-
trait_desc, self_desc
291-
)
292-
}
293-
&IntercrateAmbiguityCause::ReservationImpl { ref message } => message.clone(),
294-
}
295-
}
296-
}

src/librustc_trait_selection/traits/select/mod.rs

+41
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,47 @@ pub use rustc_middle::traits::select::*;
5151
mod candidate_assembly;
5252
mod confirmation;
5353

54+
#[derive(Clone, Debug)]
55+
pub enum IntercrateAmbiguityCause {
56+
DownstreamCrate { trait_desc: String, self_desc: Option<String> },
57+
UpstreamCrateUpdate { trait_desc: String, self_desc: Option<String> },
58+
ReservationImpl { message: String },
59+
}
60+
61+
impl IntercrateAmbiguityCause {
62+
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
63+
/// See #23980 for details.
64+
pub fn add_intercrate_ambiguity_hint(&self, err: &mut rustc_errors::DiagnosticBuilder<'_>) {
65+
err.note(&self.intercrate_ambiguity_hint());
66+
}
67+
68+
pub fn intercrate_ambiguity_hint(&self) -> String {
69+
match self {
70+
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
71+
let self_desc = if let &Some(ref ty) = self_desc {
72+
format!(" for type `{}`", ty)
73+
} else {
74+
String::new()
75+
};
76+
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
77+
}
78+
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
79+
let self_desc = if let &Some(ref ty) = self_desc {
80+
format!(" for type `{}`", ty)
81+
} else {
82+
String::new()
83+
};
84+
format!(
85+
"upstream crates may add a new impl of trait `{}`{} \
86+
in future versions",
87+
trait_desc, self_desc
88+
)
89+
}
90+
&IntercrateAmbiguityCause::ReservationImpl { ref message } => message.clone(),
91+
}
92+
}
93+
}
94+
5495
pub struct SelectionContext<'cx, 'tcx> {
5596
infcx: &'cx InferCtxt<'cx, 'tcx>,
5697

0 commit comments

Comments
 (0)