mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
RFC 2027: "first draft" of implementation
These are a squashed series of commits.
This commit is contained in:
committed by
Niko Matsakis
parent
d28a9c38fe
commit
ef5acdeceb
@@ -152,6 +152,32 @@ pub fn note_expected_found(&mut self,
|
||||
self.note_expected_found_extra(label, expected, found, &"", &"")
|
||||
}
|
||||
|
||||
pub fn note_unsuccessfull_coercion(&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString)
|
||||
-> &mut Self
|
||||
{
|
||||
let mut msg: Vec<_> =
|
||||
vec![(format!("required when trying to coerce from type `"),
|
||||
Style::NoStyle)];
|
||||
msg.extend(expected.0.iter()
|
||||
.map(|x| match *x {
|
||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
||||
}));
|
||||
msg.push((format!("` to type '"), Style::NoStyle));
|
||||
msg.extend(found.0.iter()
|
||||
.map(|x| match *x {
|
||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
||||
}));
|
||||
msg.push((format!("`"), Style::NoStyle));
|
||||
|
||||
// For now, just attach these as notes
|
||||
self.highlighted_note(msg);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn note_expected_found_extra(&mut self,
|
||||
label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
|
||||
@@ -209,6 +209,11 @@ pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self
|
||||
found_extra: &dyn fmt::Display,
|
||||
) -> &mut Self);
|
||||
|
||||
forward!(pub fn note_unsuccessfull_coercion(&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self);
|
||||
|
||||
forward!(pub fn note(&mut self, msg: &str) -> &mut Self);
|
||||
forward!(pub fn span_note<S: Into<MultiSpan>>(&mut self,
|
||||
sp: S,
|
||||
|
||||
Reference in New Issue
Block a user