use session::search_paths::PathKind;
use session::config::DebugInfoLevel;
use ty::tls;
-use util::nodemap::{NodeMap, FnvHashMap};
+use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
use util::common::duration_to_secs_str;
use mir::transform as mir_pass;
pub working_dir: PathBuf,
pub lint_store: RefCell<lint::LintStore>,
pub lints: RefCell<NodeMap<Vec<(lint::LintId, Span, String)>>>,
+ /// Set of (span, message) tuples tracking lint (sub)diagnostics that have
+ /// been set once, but should not be set again, in order to avoid
+ /// redundantly verbose output (Issue #24690).
+ pub one_time_diagnostics: RefCell<FnvHashSet<(Span, String)>>,
pub plugin_llvm_passes: RefCell<Vec<String>>,
pub mir_passes: RefCell<mir_pass::Passes>,
pub plugin_attributes: RefCell<Vec<(String, AttributeType)>>,
pub fn diagnostic<'a>(&'a self) -> &'a errors::Handler {
&self.parse_sess.span_diagnostic
}
+
+ /// Analogous to calling `.span_note` on the given DiagnosticBuilder, but
+ /// deduplicates on span and message for this `Session`.
+ //
+ // FIXME: if the need arises for one-time diagnostics other than
+ // `span_note`, we almost certainly want to generalize this
+ // "check/insert-into the one-time diagnostics map, then set message if
+ // it's not already there" code to accomodate all of them
+ pub fn diag_span_note_once<'a, 'b>(&'a self,
+ diag_builder: &'b mut DiagnosticBuilder<'a>,
+ span: Span, message: &str) {
+ let span_message = (span, message.to_owned());
+ let fresh = self.one_time_diagnostics.borrow_mut().insert(span_message);
+ if fresh {
+ diag_builder.span_note(span, &message);
+ }
+ }
+
pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
self.parse_sess.codemap()
}
working_dir: env::current_dir().unwrap(),
lint_store: RefCell::new(lint::LintStore::new()),
lints: RefCell::new(NodeMap()),
+ one_time_diagnostics: RefCell::new(FnvHashSet()),
plugin_llvm_passes: RefCell::new(Vec::new()),
mir_passes: RefCell::new(mir_pass::Passes::new()),
plugin_attributes: RefCell::new(Vec::new()),