-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Avoid repetition on “use of unstable library feature 'rustc_private'” #45540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; | |
use ty::{self, TyCtxt}; | ||
use middle::privacy::AccessLevels; | ||
use syntax::symbol::Symbol; | ||
use syntax_pos::{Span, DUMMY_SP}; | ||
use syntax_pos::{Span, MultiSpan, DUMMY_SP}; | ||
use syntax::ast; | ||
use syntax::ast::{NodeId, Attribute}; | ||
use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version}; | ||
|
@@ -597,8 +597,31 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { | |
feature.as_str(), &r), | ||
None => format!("use of unstable library feature '{}'", &feature) | ||
}; | ||
emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span, | ||
GateIssue::Library(Some(issue)), &msg); | ||
|
||
|
||
let msp: MultiSpan = span.into(); | ||
let cm = &self.sess.parse_sess.codemap(); | ||
let span_key = | ||
msp.primary_span().and_then(|sp:Span| | ||
if sp != DUMMY_SP { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean up the formatting for this entire block to avoid as having as much left padding. |
||
let fname = cm.lookup_char_pos(sp.lo()).file.as_ref().name.clone(); | ||
if fname.starts_with("<") && fname.ends_with(" macros>") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This piece of code could be better as a method of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you meant. Hopefully the way it's written now is better (well, it is better, I don't exactly know why I felt I needed to make it so complicated... ) |
||
None | ||
} else { | ||
Some(span) | ||
} | ||
} else { | ||
None | ||
} | ||
); | ||
|
||
let tuple = (None, span_key, msg.clone()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to give |
||
let fresh = self.sess.one_time_diagnostics.borrow_mut().insert(tuple); | ||
if fresh { | ||
emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span, | ||
GateIssue::Library(Some(issue)), &msg); | ||
} | ||
|
||
} | ||
Some(_) => { | ||
// Stable APIs are always ok to call and deprecated APIs are | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ pub struct Session { | |
/// Set of (LintId, Option<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<FxHashSet<(lint::LintId, Option<Span>, String)>>, | ||
pub one_time_diagnostics: RefCell<FxHashSet<(Option<lint::LintId>, Option<Span>, String)>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, instead of making the first tuple field an option, I would suggest making the |
||
pub plugin_llvm_passes: RefCell<Vec<String>>, | ||
pub plugin_attributes: RefCell<Vec<(String, AttributeType)>>, | ||
pub crate_types: RefCell<Vec<config::CrateType>>, | ||
|
@@ -361,7 +361,7 @@ impl Session { | |
}, | ||
_ => { | ||
let lint_id = lint::LintId::of(lint); | ||
let id_span_message = (lint_id, span, message.to_owned()); | ||
let id_span_message = (Some(lint_id), span, message.to_owned()); | ||
let fresh = self.one_time_diagnostics.borrow_mut().insert(id_span_message); | ||
if fresh { | ||
do_method() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably fit the following line on this one.