Compute proper module parent during resolution#77984
Conversation
|
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
|
This same code is copied in rustdoc: rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 750 to 767 in b385598 Maybe it's worth making this a query or method on tcx?
|
|
@jyn514: It's not quite the same code - we don't have a tcx available in the resolver, so we need to go through the |
|
So, the sad part here is that the If const _: () = {
#[macro_export]
macro_rules! my_macro {
() => {};
}
};was written in the current crate, then We don't track blocks for other crates, so we simply cannot produce a correct answer here. So, returning the closest |
0567261 to
c07f8f8
Compare
|
r=me with the test changes #77984 (comment) |
Fixes rust-lang#75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
c07f8f8 to
283053a
Compare
|
@petrochenkov: Your suggested test caught a bug in my implementation. We also need to perform the parent-walking in |
|
@bors r+ |
|
📌 Commit 283053a has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#77984 (Compute proper module parent during resolution) - rust-lang#78085 (MIR validation should check `SwitchInt` values are valid for the type) - rust-lang#78208 (replace `#[allow_internal_unstable]` with `#[rustc_allow_const_fn_unstable]` for `const fn`s) - rust-lang#78209 (Update `compiler_builtins` to 0.1.36) - rust-lang#78276 (Bump backtrace-rs to enable Mach-O support on iOS.) - rust-lang#78320 (Link to cargo's `build-std` feature instead of `xargo` in custom target docs) - rust-lang#78322 (BTreeMap: stop mistaking node::MIN_LEN for a node level constraint) - rust-lang#78326 (Split out statement attributes changes from rust-lang#78306) Failed merges: r? `@ghost`
Fixes #75982
The direct parent of a module may not be a module
(e.g.
const _: () = { #[path = "foo.rs"] mod foo; };).To find the parent of a module for purposes of resolution, we need to
walk up the tree until we hit a module or a crate root.