-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #127181 - BoxyUwU:dump_def_parents, r=compiler-errors
Introduce a `rustc_` attribute to dump all the `DefId` parents of a `DefId` We've run into a bunch of issues with anon consts having the wrong generics and it would have been incredibly helpful to be able to quickly slap a `rustc_` attribute to check what `tcx.parent(` will return on the relevant DefIds. I wasn't sure of a better way to make this work for anon consts than requiring the attribute to be on the enclosing item and then walking the inside of it to look for any anon consts. This particular method will honestly break at some point when we stop having a `DefId` available for anon consts in hir but that's for another day... r? ``@compiler-errors``
- Loading branch information
Showing
6 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//@ normalize-stderr-test "DefId\(.+?\)" -> "DefId(..)" | ||
#![feature(rustc_attrs)] | ||
|
||
fn bar() { | ||
fn foo() { | ||
fn baz() { | ||
#[rustc_dump_def_parents] | ||
|| { | ||
//~^ ERROR: rustc_dump_def_parents: DefId | ||
qux::< | ||
{ | ||
//~^ ERROR: rustc_dump_def_parents: DefId | ||
fn inhibits_dump() { | ||
qux::< | ||
{ | ||
"hi"; | ||
1 | ||
}, | ||
>(); | ||
} | ||
|
||
qux::<{ 1 + 1 }>(); | ||
//~^ ERROR: rustc_dump_def_parents: DefId | ||
1 | ||
}, | ||
>(); | ||
}; | ||
} | ||
} | ||
} | ||
|
||
const fn qux<const N: usize>() {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
error: rustc_dump_def_parents: DefId(..) | ||
--> $DIR/dump_def_parents.rs:8:13 | ||
| | ||
LL | || { | ||
| ^^ | ||
| | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:6:9 | ||
| | ||
LL | fn baz() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:5:5 | ||
| | ||
LL | fn foo() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:4:1 | ||
| | ||
LL | fn bar() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:2:1 | ||
| | ||
LL | / #![feature(rustc_attrs)] | ||
LL | | | ||
LL | | fn bar() { | ||
LL | | fn foo() { | ||
... | | ||
LL | | | ||
LL | | fn main() {} | ||
| |____________^ | ||
|
||
error: rustc_dump_def_parents: DefId(..) | ||
--> $DIR/dump_def_parents.rs:11:21 | ||
| | ||
LL | / { | ||
LL | | | ||
LL | | fn inhibits_dump() { | ||
LL | | qux::< | ||
... | | ||
LL | | 1 | ||
LL | | }, | ||
| |_____________________^ | ||
| | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:8:13 | ||
| | ||
LL | || { | ||
| ^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:6:9 | ||
| | ||
LL | fn baz() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:5:5 | ||
| | ||
LL | fn foo() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:4:1 | ||
| | ||
LL | fn bar() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:2:1 | ||
| | ||
LL | / #![feature(rustc_attrs)] | ||
LL | | | ||
LL | | fn bar() { | ||
LL | | fn foo() { | ||
... | | ||
LL | | | ||
LL | | fn main() {} | ||
| |____________^ | ||
|
||
error: rustc_dump_def_parents: DefId(..) | ||
--> $DIR/dump_def_parents.rs:22:31 | ||
| | ||
LL | qux::<{ 1 + 1 }>(); | ||
| ^^^^^^^^^ | ||
| | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:11:21 | ||
| | ||
LL | / { | ||
LL | | | ||
LL | | fn inhibits_dump() { | ||
LL | | qux::< | ||
... | | ||
LL | | 1 | ||
LL | | }, | ||
| |_____________________^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:8:13 | ||
| | ||
LL | || { | ||
| ^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:6:9 | ||
| | ||
LL | fn baz() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:5:5 | ||
| | ||
LL | fn foo() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:4:1 | ||
| | ||
LL | fn bar() { | ||
| ^^^^^^^^ | ||
note: DefId(..) | ||
--> $DIR/dump_def_parents.rs:2:1 | ||
| | ||
LL | / #![feature(rustc_attrs)] | ||
LL | | | ||
LL | | fn bar() { | ||
LL | | fn foo() { | ||
... | | ||
LL | | | ||
LL | | fn main() {} | ||
| |____________^ | ||
|
||
error: aborting due to 3 previous errors | ||
|