Skip to content

Commit 92dcf6d

Browse files
authored
Rollup merge of #78999 - petrochenkov:deprid, r=eddyb
stability: More precise location for deprecation lint on macros One missing piece of #73178.
2 parents 61134aa + 909c894 commit 92dcf6d

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

compiler/rustc_middle/src/middle/stability.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pub use self::StabilityLevel::*;
55

66
use crate::ty::{self, TyCtxt};
7-
use rustc_ast::CRATE_NODE_ID;
7+
use rustc_ast::NodeId;
88
use rustc_attr::{self as attr, ConstStability, Deprecation, Stability};
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1010
use rustc_errors::{Applicability, DiagnosticBuilder};
@@ -211,13 +211,14 @@ pub fn early_report_deprecation(
211211
suggestion: Option<Symbol>,
212212
lint: &'static Lint,
213213
span: Span,
214+
node_id: NodeId,
214215
) {
215216
if span.in_derive_expansion() {
216217
return;
217218
}
218219

219220
let diag = BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span);
220-
lint_buffer.buffer_lint_with_diagnostic(lint, CRATE_NODE_ID, span, message, diag);
221+
lint_buffer.buffer_lint_with_diagnostic(lint, node_id, span, message, diag);
221222
}
222223

223224
fn late_report_deprecation(

compiler/rustc_resolve/src/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ impl<'a> Resolver<'a> {
10341034
depr.suggestion,
10351035
lint,
10361036
span,
1037+
node_id,
10371038
);
10381039
}
10391040
}

src/test/ui/lint/expansion-time.rs

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ mod benches {
1212
fn foo() {}
1313
}
1414

15+
#[deprecated = "reason"]
16+
macro_rules! deprecated {
17+
() => {}
18+
}
19+
20+
#[allow(deprecated)]
21+
mod deprecated {
22+
deprecated!(); // No warning
23+
}
24+
1525
#[warn(incomplete_include)]
1626
fn main() {
1727
// WARN see in the stderr file, the warning points to the included file.

src/test/ui/lint/expansion-time.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LL | 2
3333
| ^
3434
|
3535
note: the lint level is defined here
36-
--> $DIR/expansion-time.rs:15:8
36+
--> $DIR/expansion-time.rs:25:8
3737
|
3838
LL | #[warn(incomplete_include)]
3939
| ^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)