Skip to content

Commit 52d0e51

Browse files
author
Virgil Palanciuc
committed
relax restriction - allow errors to be emmitted within macro spans, as long as the same error message has not been used before (i.e. use the None as the span key, for errors that occur within macros)
1 parent 4e16e30 commit 52d0e51

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/librustc/middle/stability.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -598,29 +598,28 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
598598
None => format!("use of unstable library feature '{}'", &feature)
599599
};
600600

601+
601602
let msp: MultiSpan = span.into();
602603
let cm = &self.sess.parse_sess.codemap();
603-
let real_file_location =
604+
let span_key =
604605
msp.primary_span().and_then(|sp:Span|
605606
if sp != DUMMY_SP {
606607
let fname = cm.lookup_char_pos(sp.lo()).file.as_ref().name.clone();
607608
if fname.starts_with("<") && fname.ends_with(" macros>") {
608609
None
609610
} else {
610-
Some(fname)
611+
Some(span)
611612
}
612613
} else {
613614
None
614615
}
615616
);
616617

617-
if let Some(_) = real_file_location {
618-
let tuple = (None, Some(span), msg.clone());
619-
let fresh = self.sess.one_time_diagnostics.borrow_mut().insert(tuple);
620-
if fresh {
621-
emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span,
622-
GateIssue::Library(Some(issue)), &msg);
623-
}
618+
let tuple = (None, span_key, msg.clone());
619+
let fresh = self.sess.one_time_diagnostics.borrow_mut().insert(tuple);
620+
if fresh {
621+
emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span,
622+
GateIssue::Library(Some(issue)), &msg);
624623
}
625624

626625
}

0 commit comments

Comments
 (0)