Approximate -> Applicability
This commit is contained in:
parent
b9c44ebd3f
commit
4e2cd4104a
|
@ -1270,7 +1270,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
|
||||
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
|
||||
themselves"),
|
||||
approximate_suggestions: bool = (false, parse_bool, [UNTRACKED],
|
||||
suggestion_applicability: bool = (false, parse_bool, [UNTRACKED],
|
||||
"include machine-applicability of suggestions in JSON output"),
|
||||
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
|
||||
"Present the input source, unstable (and less-pretty) variants;
|
||||
|
|
|
@ -1002,7 +1002,7 @@ pub fn build_session_with_codemap(
|
|||
Some(registry),
|
||||
codemap.clone(),
|
||||
pretty,
|
||||
sopts.debugging_opts.approximate_suggestions,
|
||||
sopts.debugging_opts.suggestion_applicability,
|
||||
).ui_testing(sopts.debugging_opts.ui_testing),
|
||||
),
|
||||
(config::ErrorOutputType::Json(pretty), Some(dst)) => Box::new(
|
||||
|
@ -1011,7 +1011,7 @@ pub fn build_session_with_codemap(
|
|||
Some(registry),
|
||||
codemap.clone(),
|
||||
pretty,
|
||||
sopts.debugging_opts.approximate_suggestions,
|
||||
sopts.debugging_opts.suggestion_applicability,
|
||||
).ui_testing(sopts.debugging_opts.ui_testing),
|
||||
),
|
||||
(config::ErrorOutputType::Short(color_config), None) => Box::new(
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use CodeSuggestion;
|
||||
use SubstitutionPart;
|
||||
use Substitution;
|
||||
use SuggestionApproximate;
|
||||
use Applicability;
|
||||
use Level;
|
||||
use std::fmt;
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
|
@ -223,7 +223,7 @@ impl Diagnostic {
|
|||
}],
|
||||
msg: msg.to_owned(),
|
||||
show_code_when_inline: false,
|
||||
approximate: SuggestionApproximate::Unspecified,
|
||||
applicability: Applicability::Unspecified,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ impl Diagnostic {
|
|||
}],
|
||||
msg: msg.to_owned(),
|
||||
show_code_when_inline: true,
|
||||
approximate: SuggestionApproximate::Unspecified,
|
||||
applicability: Applicability::Unspecified,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
@ -270,16 +270,16 @@ impl Diagnostic {
|
|||
}).collect(),
|
||||
msg: msg.to_owned(),
|
||||
show_code_when_inline: true,
|
||||
approximate: SuggestionApproximate::Unspecified,
|
||||
applicability: Applicability::Unspecified,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
/// 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,
|
||||
pub fn span_suggestion_with_applicability(&mut self, sp: Span, msg: &str,
|
||||
suggestion: String,
|
||||
approximate: SuggestionApproximate) -> &mut Self {
|
||||
applicability: Applicability) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: vec![SubstitutionPart {
|
||||
|
@ -289,14 +289,14 @@ impl Diagnostic {
|
|||
}],
|
||||
msg: msg.to_owned(),
|
||||
show_code_when_inline: true,
|
||||
approximate,
|
||||
applicability,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn span_approximate_suggestions(&mut self, sp: Span, msg: &str,
|
||||
pub fn span_suggestions_with_applicability(&mut self, sp: Span, msg: &str,
|
||||
suggestions: Vec<String>,
|
||||
approximate: SuggestionApproximate) -> &mut Self {
|
||||
applicability: Applicability) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: suggestions.into_iter().map(|snippet| Substitution {
|
||||
parts: vec![SubstitutionPart {
|
||||
|
@ -306,7 +306,7 @@ impl Diagnostic {
|
|||
}).collect(),
|
||||
msg: msg.to_owned(),
|
||||
show_code_when_inline: true,
|
||||
approximate,
|
||||
applicability,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use Diagnostic;
|
||||
use DiagnosticId;
|
||||
use DiagnosticStyledString;
|
||||
use SuggestionApproximate;
|
||||
use Applicability;
|
||||
|
||||
use Level;
|
||||
use Handler;
|
||||
|
@ -188,17 +188,17 @@ impl<'a> DiagnosticBuilder<'a> {
|
|||
msg: &str,
|
||||
suggestions: Vec<String>)
|
||||
-> &mut Self);
|
||||
forward!(pub fn span_approximate_suggestion(&mut self,
|
||||
forward!(pub fn span_suggestion_with_applicability(&mut self,
|
||||
sp: Span,
|
||||
msg: &str,
|
||||
suggestion: String,
|
||||
approximate: SuggestionApproximate)
|
||||
applicability: Applicability)
|
||||
-> &mut Self);
|
||||
forward!(pub fn span_approximate_suggestions(&mut self,
|
||||
forward!(pub fn span_suggestions_with_applicability(&mut self,
|
||||
sp: Span,
|
||||
msg: &str,
|
||||
suggestions: Vec<String>,
|
||||
approximate: SuggestionApproximate)
|
||||
applicability: Applicability)
|
||||
-> &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);
|
||||
|
|
|
@ -57,7 +57,7 @@ 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 {
|
||||
pub enum Applicability {
|
||||
MachineApplicable,
|
||||
HasPlaceholders,
|
||||
MaybeIncorrect,
|
||||
|
@ -95,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: SuggestionApproximate,
|
||||
pub applicability: Applicability,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
|
|
|
@ -177,7 +177,7 @@ pub fn run_core(search_paths: SearchPaths,
|
|||
None,
|
||||
codemap.clone(),
|
||||
pretty,
|
||||
sessopts.debugging_opts.approximate_suggestions,
|
||||
sessopts.debugging_opts.suggestion_applicability,
|
||||
).ui_testing(sessopts.debugging_opts.ui_testing)
|
||||
),
|
||||
ErrorOutputType::Short(color_config) => Box::new(
|
||||
|
|
|
@ -23,7 +23,7 @@ use codemap::{CodeMap, FilePathMapping};
|
|||
use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan};
|
||||
use errors::registry::Registry;
|
||||
use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, CodeMapper};
|
||||
use errors::{DiagnosticId, SuggestionApproximate};
|
||||
use errors::{DiagnosticId, Applicability};
|
||||
use errors::emitter::{Emitter, EmitterWriter};
|
||||
|
||||
use rustc_data_structures::sync::{self, Lrc};
|
||||
|
@ -39,7 +39,7 @@ pub struct JsonEmitter {
|
|||
cm: Lrc<CodeMapper + sync::Send + sync::Sync>,
|
||||
pretty: bool,
|
||||
/// Whether "approximate suggestions" are enabled in the config
|
||||
approximate_suggestions: bool,
|
||||
suggestion_applicability: bool,
|
||||
ui_testing: bool,
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,13 @@ impl JsonEmitter {
|
|||
pub fn stderr(registry: Option<Registry>,
|
||||
code_map: Lrc<CodeMap>,
|
||||
pretty: bool,
|
||||
approximate_suggestions: bool) -> JsonEmitter {
|
||||
suggestion_applicability: bool) -> JsonEmitter {
|
||||
JsonEmitter {
|
||||
dst: Box::new(io::stderr()),
|
||||
registry,
|
||||
cm: code_map,
|
||||
pretty,
|
||||
approximate_suggestions,
|
||||
suggestion_applicability,
|
||||
ui_testing: false,
|
||||
}
|
||||
}
|
||||
|
@ -68,13 +68,13 @@ impl JsonEmitter {
|
|||
registry: Option<Registry>,
|
||||
code_map: Lrc<CodeMap>,
|
||||
pretty: bool,
|
||||
approximate_suggestions: bool) -> JsonEmitter {
|
||||
suggestion_applicability: bool) -> JsonEmitter {
|
||||
JsonEmitter {
|
||||
dst,
|
||||
registry,
|
||||
cm: code_map,
|
||||
pretty,
|
||||
approximate_suggestions,
|
||||
suggestion_applicability,
|
||||
ui_testing: false,
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ struct DiagnosticSpan {
|
|||
suggested_replacement: Option<String>,
|
||||
/// If the suggestion is approximate
|
||||
#[rustc_serialize_exclude_null]
|
||||
suggestion_approximate: Option<SuggestionApproximate>,
|
||||
suggestion_applicability: Option<Applicability>,
|
||||
/// Macro invocations that created the code at this span, if any.
|
||||
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ impl Diagnostic {
|
|||
|
||||
impl DiagnosticSpan {
|
||||
fn from_span_label(span: SpanLabel,
|
||||
suggestion: Option<(&String, SuggestionApproximate)>,
|
||||
suggestion: Option<(&String, Applicability)>,
|
||||
je: &JsonEmitter)
|
||||
-> DiagnosticSpan {
|
||||
Self::from_span_etc(span.span,
|
||||
|
@ -252,7 +252,7 @@ impl DiagnosticSpan {
|
|||
fn from_span_etc(span: Span,
|
||||
is_primary: bool,
|
||||
label: Option<String>,
|
||||
suggestion: Option<(&String, SuggestionApproximate)>,
|
||||
suggestion: Option<(&String, Applicability)>,
|
||||
je: &JsonEmitter)
|
||||
-> DiagnosticSpan {
|
||||
// obtain the full backtrace from the `macro_backtrace`
|
||||
|
@ -272,7 +272,7 @@ impl DiagnosticSpan {
|
|||
fn from_span_full(span: Span,
|
||||
is_primary: bool,
|
||||
label: Option<String>,
|
||||
suggestion: Option<(&String, SuggestionApproximate)>,
|
||||
suggestion: Option<(&String, Applicability)>,
|
||||
mut backtrace: vec::IntoIter<MacroBacktrace>,
|
||||
je: &JsonEmitter)
|
||||
-> DiagnosticSpan {
|
||||
|
@ -301,7 +301,7 @@ impl DiagnosticSpan {
|
|||
})
|
||||
});
|
||||
|
||||
let suggestion_approximate = if je.approximate_suggestions {
|
||||
let suggestion_applicability = if je.suggestion_applicability {
|
||||
suggestion.map(|x| x.1)
|
||||
} else {
|
||||
None
|
||||
|
@ -318,7 +318,7 @@ impl DiagnosticSpan {
|
|||
is_primary,
|
||||
text: DiagnosticSpanLine::from_span(span, je),
|
||||
suggested_replacement: suggestion.map(|x| x.0.clone()),
|
||||
suggestion_approximate,
|
||||
suggestion_applicability,
|
||||
expansion: backtrace_step,
|
||||
label,
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ impl DiagnosticSpan {
|
|||
};
|
||||
DiagnosticSpan::from_span_label(span_label,
|
||||
Some((&suggestion_inner.snippet,
|
||||
suggestion.approximate)),
|
||||
suggestion.applicability)),
|
||||
je)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue