Skip to content

Commit 3e5259d

Browse files
committed
Move IntercrateAmbiguityCause back to rustc::traits::select.
1 parent 5ed3453 commit 3e5259d

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

src/librustc/traits/select.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,44 @@ impl<T: Clone> WithDepNode<T> {
288288
self.cached_value.clone()
289289
}
290290
}
291+
292+
#[derive(Clone, Debug)]
293+
pub enum IntercrateAmbiguityCause {
294+
DownstreamCrate { trait_desc: String, self_desc: Option<String> },
295+
UpstreamCrateUpdate { trait_desc: String, self_desc: Option<String> },
296+
ReservationImpl { message: String },
297+
}
298+
299+
impl IntercrateAmbiguityCause {
300+
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
301+
/// See #23980 for details.
302+
pub fn add_intercrate_ambiguity_hint(&self, err: &mut rustc_errors::DiagnosticBuilder<'_>) {
303+
err.note(&self.intercrate_ambiguity_hint());
304+
}
305+
306+
pub fn intercrate_ambiguity_hint(&self) -> String {
307+
match self {
308+
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
309+
let self_desc = if let &Some(ref ty) = self_desc {
310+
format!(" for type `{}`", ty)
311+
} else {
312+
String::new()
313+
};
314+
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
315+
}
316+
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
317+
let self_desc = if let &Some(ref ty) = self_desc {
318+
format!(" for type `{}`", ty)
319+
} else {
320+
String::new()
321+
};
322+
format!(
323+
"upstream crates may add a new impl of trait `{}`{} \
324+
in future versions",
325+
trait_desc, self_desc
326+
)
327+
}
328+
&IntercrateAmbiguityCause::ReservationImpl { ref message } => message.clone(),
329+
}
330+
}
331+
}

src/librustc_infer/traits/select.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -95,47 +95,6 @@ pub struct SelectionContext<'cx, 'tcx> {
9595
query_mode: TraitQueryMode,
9696
}
9797

98-
#[derive(Clone, Debug)]
99-
pub enum IntercrateAmbiguityCause {
100-
DownstreamCrate { trait_desc: String, self_desc: Option<String> },
101-
UpstreamCrateUpdate { trait_desc: String, self_desc: Option<String> },
102-
ReservationImpl { message: String },
103-
}
104-
105-
impl IntercrateAmbiguityCause {
106-
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
107-
/// See #23980 for details.
108-
pub fn add_intercrate_ambiguity_hint(&self, err: &mut rustc_errors::DiagnosticBuilder<'_>) {
109-
err.note(&self.intercrate_ambiguity_hint());
110-
}
111-
112-
pub fn intercrate_ambiguity_hint(&self) -> String {
113-
match self {
114-
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
115-
let self_desc = if let &Some(ref ty) = self_desc {
116-
format!(" for type `{}`", ty)
117-
} else {
118-
String::new()
119-
};
120-
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
121-
}
122-
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
123-
let self_desc = if let &Some(ref ty) = self_desc {
124-
format!(" for type `{}`", ty)
125-
} else {
126-
String::new()
127-
};
128-
format!(
129-
"upstream crates may add a new impl of trait `{}`{} \
130-
in future versions",
131-
trait_desc, self_desc
132-
)
133-
}
134-
&IntercrateAmbiguityCause::ReservationImpl { ref message } => message.clone(),
135-
}
136-
}
137-
}
138-
13998
// A stack that walks back up the stack frame.
14099
struct TraitObligationStack<'prev, 'tcx> {
141100
obligation: &'prev TraitObligation<'tcx>,

0 commit comments

Comments
 (0)