diff options
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/diagnostic.rs | 17 | ||||
| -rw-r--r-- | src/librustc_errors/diagnostic_builder.rs | 7 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 10 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 40e4efb397d..bfeb351f1a4 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -11,6 +11,7 @@ use CodeSuggestion; use SubstitutionPart; use Substitution; +use SuggestionApproximate; use Level; use std::fmt; use syntax_pos::{MultiSpan, Span}; @@ -222,7 +223,7 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: false, - approximate: false, + approximate: SuggestionApproximate::Unspecified, }); self } @@ -253,7 +254,7 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: true, - approximate: false, + approximate: SuggestionApproximate::Unspecified, }); self } @@ -269,7 +270,7 @@ impl Diagnostic { }).collect(), msg: msg.to_owned(), show_code_when_inline: true, - approximate: false, + approximate: SuggestionApproximate::Unspecified, }); self } @@ -277,7 +278,8 @@ impl Diagnostic { /// This is a suggestion that may contain mistakes or fillers and should /// be read and understood by a human. pub fn span_approximate_suggestion(&mut self, sp: Span, msg: &str, - suggestion: String) -> &mut Self { + suggestion: String, + approximate: SuggestionApproximate) -> &mut Self { self.suggestions.push(CodeSuggestion { substitutions: vec![Substitution { parts: vec![SubstitutionPart { @@ -287,13 +289,14 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: true, - approximate: true, + approximate, }); self } pub fn span_approximate_suggestions(&mut self, sp: Span, msg: &str, - suggestions: Vec<String>) -> &mut Self { + suggestions: Vec<String>, + approximate: SuggestionApproximate) -> &mut Self { self.suggestions.push(CodeSuggestion { substitutions: suggestions.into_iter().map(|snippet| Substitution { parts: vec![SubstitutionPart { @@ -303,7 +306,7 @@ impl Diagnostic { }).collect(), msg: msg.to_owned(), show_code_when_inline: true, - approximate: true, + approximate, }); self } diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 945ecce7ab3..31eacb527ee 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -11,6 +11,7 @@ use Diagnostic; use DiagnosticId; use DiagnosticStyledString; +use SuggestionApproximate; use Level; use Handler; @@ -190,12 +191,14 @@ impl<'a> DiagnosticBuilder<'a> { forward!(pub fn span_approximate_suggestion(&mut self, sp: Span, msg: &str, - suggestion: String) + suggestion: String, + approximate: SuggestionApproximate) -> &mut Self); forward!(pub fn span_approximate_suggestions(&mut self, sp: Span, msg: &str, - suggestions: Vec<String>) + suggestions: Vec<String>, + approximate: SuggestionApproximate) -> &mut Self); forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self); forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index ce3efef08cc..9abb5b38c05 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -56,6 +56,14 @@ mod lock; use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION}; +#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] +pub enum SuggestionApproximate { + MachineApplicable, + HasPlaceholders, + MaybeIncorrect, + Unspecified +} + #[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub struct CodeSuggestion { /// Each substitute can have multiple variants due to multiple @@ -87,7 +95,7 @@ pub struct CodeSuggestion { /// Sometimes we may show suggestions with placeholders, /// which are useful for users but not useful for /// tools like rustfix - pub approximate: bool, + pub approximate: SuggestionApproximate, } #[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] |
