diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-06-12 12:28:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-12 12:28:25 +0200 |
| commit | 657a41fe73942006a01d67598bcbe80b8b03e69e (patch) | |
| tree | f6f5c255dc50760f8f95ad85f8288acf9ee1b562 /src/librustc_hir | |
| parent | c06799e4c4103330c972eb04f08aa72b7c1d5ace (diff) | |
| parent | d60df536d5d6a4ad2d6b2cdf4c443e022fe35d30 (diff) | |
| download | rust-657a41fe73942006a01d67598bcbe80b8b03e69e.tar.gz rust-657a41fe73942006a01d67598bcbe80b8b03e69e.zip | |
Rollup merge of #73178 - petrochenkov:explint, r=varkor
expand: More precise locations for expansion-time lints First commit: a macro expansion doesn't have a `NodeId` associated with it, but it has a parent `DefId` which we can use for linting. The observable effect is that lints associated with macro expansions can now be `allow`ed at finer-grained level than whole crate. Second commit: each macro definition has a `NodeId` which we can use for linting, unless that macro definition was decoded from other crate.
Diffstat (limited to 'src/librustc_hir')
| -rw-r--r-- | src/librustc_hir/definitions.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_hir/definitions.rs b/src/librustc_hir/definitions.rs index 2dd5e27ead2..b63dd653c4d 100644 --- a/src/librustc_hir/definitions.rs +++ b/src/librustc_hir/definitions.rs @@ -519,6 +519,12 @@ impl Definitions { let old_index = self.placeholder_field_indices.insert(node_id, index); assert!(old_index.is_none(), "placeholder field index is reset for a node ID"); } + + pub fn lint_node_id(&mut self, expn_id: ExpnId) -> ast::NodeId { + self.invocation_parents + .get(&expn_id) + .map_or(ast::CRATE_NODE_ID, |id| self.def_id_to_node_id[*id]) + } } impl DefPathData { |
