diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-02 17:02:48 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-02 17:02:48 +0000 |
commit | 7e66cde76460d61cb19a19e4bb7bc1f6642e993d (patch) | |
tree | c8c20aff862d670f1baebd33d95e645a1281ca7f /crates/hir_def/src/nameres | |
parent | 12e8cc4aa29f616e43b4951e18b1f1f231e539a3 (diff) | |
parent | 5914f86d473f34e0fa78dc150024b07bd26a2db9 (diff) |
Merge #7525
7525: Fix resolution of `crate` paths from within blocks r=jonas-schievink a=jonas-schievink
They resolve to the crate root, not the DefMap's root module (which
can be a block)
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r-- | crates/hir_def/src/nameres/path_resolution.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index 2d1477160..ecf75c777 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs | |||
@@ -152,7 +152,7 @@ impl DefMap { | |||
152 | PathKind::DollarCrate(krate) => { | 152 | PathKind::DollarCrate(krate) => { |
153 | if krate == self.krate { | 153 | if krate == self.krate { |
154 | mark::hit!(macro_dollar_crate_self); | 154 | mark::hit!(macro_dollar_crate_self); |
155 | PerNs::types(self.module_id(self.root).into(), Visibility::Public) | 155 | PerNs::types(self.crate_root().into(), Visibility::Public) |
156 | } else { | 156 | } else { |
157 | let def_map = db.crate_def_map(krate); | 157 | let def_map = db.crate_def_map(krate); |
158 | let module = def_map.module_id(def_map.root); | 158 | let module = def_map.module_id(def_map.root); |
@@ -160,7 +160,7 @@ impl DefMap { | |||
160 | PerNs::types(module.into(), Visibility::Public) | 160 | PerNs::types(module.into(), Visibility::Public) |
161 | } | 161 | } |
162 | } | 162 | } |
163 | PathKind::Crate => PerNs::types(self.module_id(self.root).into(), Visibility::Public), | 163 | PathKind::Crate => PerNs::types(self.crate_root().into(), Visibility::Public), |
164 | // plain import or absolute path in 2015: crate-relative with | 164 | // plain import or absolute path in 2015: crate-relative with |
165 | // fallback to extern prelude (with the simplification in | 165 | // fallback to extern prelude (with the simplification in |
166 | // rust-lang/rust#57745) | 166 | // rust-lang/rust#57745) |