stability: Do not use buffer_lint after lowering to HIR
This commit is contained in:
parent
58b54911fa
commit
ceb4c3fa30
4 changed files with 32 additions and 6 deletions
|
|
@ -485,7 +485,13 @@ pub fn provide(providers: &mut Providers<'_>) {
|
|||
}
|
||||
|
||||
pub fn report_unstable(
|
||||
sess: &Session, feature: Symbol, reason: Option<Symbol>, issue: u32, is_soft: bool, span: Span
|
||||
sess: &Session,
|
||||
feature: Symbol,
|
||||
reason: Option<Symbol>,
|
||||
issue: u32,
|
||||
is_soft: bool,
|
||||
span: Span,
|
||||
soft_handler: impl FnOnce(&'static lint::Lint, Span, &str),
|
||||
) {
|
||||
let msg = match reason {
|
||||
Some(r) => format!("use of unstable library feature '{}': {}", feature, r),
|
||||
|
|
@ -511,7 +517,7 @@ pub fn report_unstable(
|
|||
let fresh = sess.one_time_diagnostics.borrow_mut().insert(error_id);
|
||||
if fresh {
|
||||
if is_soft {
|
||||
sess.buffer_lint(lint::builtin::SOFT_UNSTABLE, CRATE_NODE_ID, span, &msg);
|
||||
soft_handler(lint::builtin::SOFT_UNSTABLE, span, &msg)
|
||||
} else {
|
||||
emit_feature_err(
|
||||
&sess.parse_sess, feature, span, GateIssue::Library(Some(issue)), &msg
|
||||
|
|
@ -779,10 +785,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// Additionally, this function will also check if the item is deprecated. If so, and `id` is
|
||||
/// not `None`, a deprecated lint attached to `id` will be emitted.
|
||||
pub fn check_stability(self, def_id: DefId, id: Option<HirId>, span: Span) {
|
||||
let soft_handler =
|
||||
|lint, span, msg: &_| self.lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg);
|
||||
match self.eval_stability(def_id, id, span) {
|
||||
EvalResult::Allow => {}
|
||||
EvalResult::Deny { feature, reason, issue, is_soft } =>
|
||||
report_unstable(self.sess, feature, reason, issue, is_soft, span),
|
||||
report_unstable(self.sess, feature, reason, issue, is_soft, span, soft_handler),
|
||||
EvalResult::Unmarked => {
|
||||
// The API could be uncallable for other reasons, for example when a private module
|
||||
// was referenced.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue