granite-rust/tests
bors d3a8524e80 Auto merge of #129137 - camelid:lazy-def-macro-const, r=BoxyUwU
Fix anon const def-creation when macros are involved

Fixes #128016.

Ever since #125915, some `ast::AnonConst`s turn into `hir::ConstArgKind::Path`s,
which don't have associated `DefId`s. To deal with the fact that we don't have
resolution information in `DefCollector`, we decided to implement a process
where if the anon const *appeared* to be trivial (i.e., `N` or `{ N }`), we
would avoid creating a def for it in `DefCollector`. If later, in AST lowering,
we realized it turned out to be a unit struct literal, or we were lowering it
to something that didn't use `hir::ConstArg`, we'd create its def there.

However, let's say we have a macro `m!()` that expands to a reference to a free
constant `FOO`. If we use `m!()` in the body of an anon const (e.g., `Foo<{ m!() }>`),
then in def collection, it appears to be a nontrivial anon const and we create
a def. But the macro expands to something that looks like a trivial const arg,
but is not, so in AST lowering we "fix" the mistake we assumed def collection
made and create a def for it. This causes a duplicate definition ICE.

The long-term fix for this is to delay the creation of defs for all expression-like
nodes until AST lowering (see #128844 for an incomplete attempt at this). This
would avoid issues like this one that are caused by hacky workarounds. However,
doing this uncovers a pre-existing bug with opaque types that is quite involved
to fix (see #129023).

In the meantime, this PR fixes the bug by delaying def creation for anon consts
whose bodies are macro invocations until after we expand the macro and know
what is inside it. This is accomplished by adding information to create the
anon const's def to the data in `Resolver.invocation_parents`.

r? `@BoxyUwU`
2024-09-13 01:10:51 +00:00
..
assembly Auto merge of #117465 - paulmenage:small-data-limit, r=compiler-errors 2024-09-12 04:27:08 +00:00
auxiliary
codegen Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errors 2024-09-10 22:47:40 +00:00
codegen-units Fix and enable disabled codegen-units tests 2024-08-10 14:03:27 -04:00
coverage coverage: Treat await similar to a macro 2024-09-06 17:01:59 +12:00
coverage-run-rustdoc coverage: Extract hole spans from HIR instead of MIR 2024-07-08 21:22:56 +10:00
crashes Revert 'Stabilize -Znext-solver=coherence' 2024-09-11 17:57:04 -04:00
debuginfo Ban non-array SIMD 2024-09-09 19:39:43 -07:00
incremental Ban non-array SIMD 2024-09-09 19:39:43 -07:00
mir-opt Rollup merge of #129706 - compiler-errors:scratch, r=estebank 2024-09-05 18:58:55 +02:00
pretty Use doc(hidden) instead of allow(missing_docs) in the test harness 2024-09-11 12:14:35 +02:00
run-make Rollup merge of #130156 - nebulark:test_buildinfo, r=jieyouxu 2024-09-12 20:37:15 +10:00
run-pass-valgrind rustfmt tests/run-pass-valgrind/. 2024-06-04 09:53:02 +10:00
rustdoc Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errors 2024-09-10 22:47:40 +00:00
rustdoc-gui Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notriddle 2024-09-05 18:58:56 +02:00
rustdoc-js rustdoc-search: allow trailing Foo -> arg search 2024-09-05 17:58:05 -07:00
rustdoc-js-std rustdoc-search: allow trailing Foo -> arg search 2024-09-05 17:58:05 -07:00
rustdoc-json rustdoc: normalise type/field names in rustdoc-json-types/jsondoclint 2024-09-01 23:58:08 +03:00
rustdoc-ui rustdoc: add two regression tests 2024-09-09 22:35:10 +02:00
ui Auto merge of #129137 - camelid:lazy-def-macro-const, r=BoxyUwU 2024-09-13 01:10:51 +00:00
ui-fulldeps Re-enable ConstArgKind::Path lowering by default 2024-09-12 13:56:01 -04:00
COMPILER_TESTS.md