Skip to content

Commit

Permalink
Rollup merge of rust-lang#78999 - petrochenkov:deprid, r=eddyb
Browse files Browse the repository at this point in the history
stability: More precise location for deprecation lint on macros

One missing piece of rust-lang#73178.
  • Loading branch information
m-ou-se authored Nov 18, 2020
2 parents 61134aa + 909c894 commit 92dcf6d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub use self::StabilityLevel::*;

use crate::ty::{self, TyCtxt};
use rustc_ast::CRATE_NODE_ID;
use rustc_ast::NodeId;
use rustc_attr::{self as attr, ConstStability, Deprecation, Stability};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{Applicability, DiagnosticBuilder};
Expand Down Expand Up @@ -211,13 +211,14 @@ pub fn early_report_deprecation(
suggestion: Option<Symbol>,
lint: &'static Lint,
span: Span,
node_id: NodeId,
) {
if span.in_derive_expansion() {
return;
}

let diag = BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span);
lint_buffer.buffer_lint_with_diagnostic(lint, CRATE_NODE_ID, span, message, diag);
lint_buffer.buffer_lint_with_diagnostic(lint, node_id, span, message, diag);
}

fn late_report_deprecation(
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ impl<'a> Resolver<'a> {
depr.suggestion,
lint,
span,
node_id,
);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/lint/expansion-time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ mod benches {
fn foo() {}
}

#[deprecated = "reason"]
macro_rules! deprecated {
() => {}
}

#[allow(deprecated)]
mod deprecated {
deprecated!(); // No warning
}

#[warn(incomplete_include)]
fn main() {
// WARN see in the stderr file, the warning points to the included file.
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/expansion-time.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LL | 2
| ^
|
note: the lint level is defined here
--> $DIR/expansion-time.rs:15:8
--> $DIR/expansion-time.rs:25:8
|
LL | #[warn(incomplete_include)]
| ^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 92dcf6d

Please sign in to comment.