Skip to content

Commit d2e37b9

Browse files
committed
fix(hygiene): Resolve relative paths through inline const parents
Treat inline const blocks as transparent scopes when finding relative paths to adjacent local definitions.
1 parent a6d2c30 commit d2e37b9

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

mutest-emit/src/analysis/res.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pub fn locally_visible_def_path<'tcx>(tcx: TyCtxt<'tcx>, def_id: hir::DefId, mut
514514
| hir::DefKind::Trait | hir::DefKind::Impl { .. } | hir::DefKind::TraitAlias
515515
| hir::DefKind::Fn | hir::DefKind::Const | hir::DefKind::Static { .. } | hir::DefKind::Ctor(..)
516516
| hir::DefKind::AssocTy | hir::DefKind::AssocFn | hir::DefKind::AssocConst
517-
| hir::DefKind::AnonConst
517+
| hir::DefKind::AnonConst | hir::DefKind::InlineConst
518518
);
519519
while is_transparent(tcx.def_kind(scope)) && let Some(parent_scope) = tcx.opt_parent(scope) {
520520
scope = parent_scope;

tests/ui/hygiene/builtins.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#[cfg(test)]
55
mod tests {
6+
thread_local! {
7+
static TLS: () = Default::default();
8+
}
9+
610
#[test]
711
fn test_builtins() {
812
println!("{:?}, {:?}, {:?}", 3, 2, Some(1));
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ build
2+
//@ stderr: empty
3+
4+
#![feature(decl_macro)]
5+
6+
macro m() {
7+
// TEST: Relative path to item in parent scope through transparent inline const block.
8+
const _: () = {
9+
const fn f() {}
10+
const { f() };
11+
};
12+
}
13+
14+
m!();

0 commit comments

Comments
 (0)