forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#79294 - petrochenkov:determ, r=varkor
resolve: Do not put macros into `module.unexpanded_invocations` unless necessary Macro invocations in modules <sup>(*)</sup> need to be tracked because they can produce named items when expanded. We cannot give definite answer to queries like "does this module declare name `n`?" until all macro calls in that module are expanded. Previously we marked too many macros as potentially producing named items. E.g. in this example ```rust mod m { const C: u32 = line!(); } ``` `line!()` cannot emit any items into module `m`, but it was still marked. This PR fixes that and marks macro calls as "unexpanded in module" only if they can actually emit named items into that module. Diagnostics in UI test outputs have different order now because this change affects macro expansion order. <sup>*</sup> Any containers for named items are called modules in resolve (that includes blocks, traits and enums in addition to `mod` items).
- Loading branch information
Showing
7 changed files
with
115 additions
and
97 deletions.
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
128 changes: 64 additions & 64 deletions
128
src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr
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 |
---|---|---|
@@ -1,104 +1,104 @@ | ||
error: cannot find attribute `lt_hof` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:51:21 | ||
error: cannot find attribute `lt_struct` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:4:15 | ||
| | ||
LL | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 | ||
| ^^^^^^ | ||
LL | struct StLt<#[lt_struct] 'a>(&'a u32); | ||
| ^^^^^^^^^ | ||
|
||
error: cannot find attribute `ty_meth` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:46:15 | ||
error: cannot find attribute `ty_struct` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:6:15 | ||
| | ||
LL | fn m_ty<#[ty_meth] P>(_: P) { } | ||
| ^^^^^^^ | ||
LL | struct StTy<#[ty_struct] I>(I); | ||
| ^^^^^^^^^ | ||
|
||
error: cannot find attribute `lt_meth` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:44:15 | ||
error: cannot find attribute `lt_enum` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:9:13 | ||
| | ||
LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } | ||
| ^^^^^^^ | ||
LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } | ||
| ^^^^^^^ | ||
|
||
error: cannot find attribute `ty_fn` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:40:11 | ||
error: cannot find attribute `ty_enum` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:11:13 | ||
| | ||
LL | fn f_ty<#[ty_fn] O>(_: O) { } | ||
| ^^^^^ | ||
LL | enum EnTy<#[ty_enum] J> { A(J), B } | ||
| ^^^^^^^ | ||
|
||
error: cannot find attribute `lt_fn` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:38:11 | ||
error: cannot find attribute `lt_trait` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:14:14 | ||
| | ||
LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } | ||
| ^^^^^ | ||
LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } | ||
| ^^^^^^^^ | ||
|
||
error: cannot find attribute `ty_impl_for` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:33:8 | ||
error: cannot find attribute `ty_trait` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:16:14 | ||
| | ||
LL | impl<#[ty_impl_for] N> TrTy<N> for StTy<N> { | ||
| ^^^^^^^^^^^ | ||
LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } | ||
| ^^^^^^^^ | ||
|
||
error: cannot find attribute `lt_impl_for` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:29:8 | ||
error: cannot find attribute `lt_type` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:19:13 | ||
| | ||
LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { | ||
| ^^^^^^^^^^^ | ||
LL | type TyLt<#[lt_type] 'd> = &'d u32; | ||
| ^^^^^^^ | ||
|
||
error: cannot find attribute `ty_inherent` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:26:8 | ||
error: cannot find attribute `ty_type` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:21:13 | ||
| | ||
LL | impl<#[ty_inherent] M> StTy<M> { } | ||
| ^^^^^^^^^^^ | ||
LL | type TyTy<#[ty_type] L> = (L, ); | ||
| ^^^^^^^ | ||
|
||
error: cannot find attribute `lt_inherent` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:24:8 | ||
| | ||
LL | impl<#[lt_inherent] 'e> StLt<'e> { } | ||
| ^^^^^^^^^^^ | ||
|
||
error: cannot find attribute `ty_type` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:21:13 | ||
error: cannot find attribute `ty_inherent` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:26:8 | ||
| | ||
LL | type TyTy<#[ty_type] L> = (L, ); | ||
| ^^^^^^^ | ||
LL | impl<#[ty_inherent] M> StTy<M> { } | ||
| ^^^^^^^^^^^ | ||
|
||
error: cannot find attribute `lt_type` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:19:13 | ||
error: cannot find attribute `lt_impl_for` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:29:8 | ||
| | ||
LL | type TyLt<#[lt_type] 'd> = &'d u32; | ||
| ^^^^^^^ | ||
LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { | ||
| ^^^^^^^^^^^ | ||
|
||
error: cannot find attribute `ty_trait` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:16:14 | ||
error: cannot find attribute `ty_impl_for` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:33:8 | ||
| | ||
LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } | ||
| ^^^^^^^^ | ||
LL | impl<#[ty_impl_for] N> TrTy<N> for StTy<N> { | ||
| ^^^^^^^^^^^ | ||
|
||
error: cannot find attribute `lt_trait` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:14:14 | ||
error: cannot find attribute `lt_fn` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:38:11 | ||
| | ||
LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } | ||
| ^^^^^^^^ | ||
LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } | ||
| ^^^^^ | ||
|
||
error: cannot find attribute `ty_enum` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:11:13 | ||
error: cannot find attribute `ty_fn` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:40:11 | ||
| | ||
LL | enum EnTy<#[ty_enum] J> { A(J), B } | ||
| ^^^^^^^ | ||
LL | fn f_ty<#[ty_fn] O>(_: O) { } | ||
| ^^^^^ | ||
|
||
error: cannot find attribute `lt_enum` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:9:13 | ||
error: cannot find attribute `lt_meth` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:44:15 | ||
| | ||
LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } | ||
| ^^^^^^^ | ||
LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } | ||
| ^^^^^^^ | ||
|
||
error: cannot find attribute `ty_struct` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:6:15 | ||
error: cannot find attribute `ty_meth` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:46:15 | ||
| | ||
LL | struct StTy<#[ty_struct] I>(I); | ||
| ^^^^^^^^^ | ||
LL | fn m_ty<#[ty_meth] P>(_: P) { } | ||
| ^^^^^^^ | ||
|
||
error: cannot find attribute `lt_struct` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:4:15 | ||
error: cannot find attribute `lt_hof` in this scope | ||
--> $DIR/feature-gate-custom_attribute2.rs:51:21 | ||
| | ||
LL | struct StLt<#[lt_struct] 'a>(&'a u32); | ||
| ^^^^^^^^^ | ||
LL | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 | ||
| ^^^^^^ | ||
|
||
error: aborting due to 17 previous errors | ||
|
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
error: cannot find macro `m` in this scope | ||
--> $DIR/issue-40845.rs:4:10 | ||
| | ||
LL | impl S { m!(); } | ||
| ^ | ||
|
||
error: cannot find macro `m` in this scope | ||
--> $DIR/issue-40845.rs:1:11 | ||
| | ||
LL | trait T { m!(); } | ||
| ^ | ||
|
||
error: cannot find macro `m` in this scope | ||
--> $DIR/issue-40845.rs:4:10 | ||
| | ||
LL | impl S { m!(); } | ||
| ^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
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,7 @@ | ||
// check-pass | ||
|
||
use std as line; | ||
|
||
const C: u32 = line!(); | ||
|
||
fn main() {} |