-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #81922 - magurotuna:issue81522, r=matthewjasper
Let `#[allow(unstable_name_collisions)]` work for things other than function Fixes #81522 In addition to the report in #81522, currently `#[allow(unstable_name_collisions)]` doesn't suppress the corresponding diagnostics even if this attribute is appended to an expression statement or a let statement. It seems like this is because the wrong `HirId` is passed to `struct_span_lint_hir`. It's fixed in this PR, and a regression test for it is also added.
- Loading branch information
Showing
2 changed files
with
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Regression test for #81522. | ||
// Ensures that `#[allow(unstable_name_collisions)]` appended to things other than function | ||
// suppresses the corresponding diagnostics emitted from inside them. | ||
// But note that this attribute doesn't work for macro invocations if it is appended directly. | ||
|
||
// aux-build:inference_unstable_iterator.rs | ||
// aux-build:inference_unstable_itertools.rs | ||
// run-pass | ||
|
||
extern crate inference_unstable_iterator; | ||
extern crate inference_unstable_itertools; | ||
|
||
#[allow(unused_imports)] | ||
use inference_unstable_iterator::IpuIterator; | ||
use inference_unstable_itertools::IpuItertools; | ||
|
||
fn main() { | ||
// expression statement | ||
#[allow(unstable_name_collisions)] | ||
'x'.ipu_flatten(); | ||
|
||
// let statement | ||
#[allow(unstable_name_collisions)] | ||
let _ = 'x'.ipu_flatten(); | ||
|
||
// block expression | ||
#[allow(unstable_name_collisions)] | ||
{ | ||
'x'.ipu_flatten(); | ||
} | ||
} |