forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#131498 - Urgau:transparent-const-anons, r=lcnr
Consider outermost const-anon in `non_local_def` lint This PR change the logic for finding the parent of the `impl` definition in the `non_local_definitions` lint to consider multiple level of const-anon items, instead of only one currently. I also took the opportunity to cleanup the related code. cc `@traviscross` Fixes rust-lang#131474
- Loading branch information
Showing
6 changed files
with
148 additions
and
34 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
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
34 changes: 34 additions & 0 deletions
34
tests/ui/lint/non-local-defs/convoluted-locals-131474-with-mods.rs
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 @@ | ||
// This test check that no matter the nesting of const-anons and modules | ||
// we consider them as transparent. | ||
// | ||
// Similar to https://github.com/rust-lang/rust/issues/131474 | ||
|
||
//@ check-pass | ||
|
||
pub mod tmp { | ||
pub mod tmp { | ||
pub struct Test; | ||
} | ||
} | ||
|
||
const _: () = { | ||
const _: () = { | ||
const _: () = { | ||
const _: () = { | ||
impl tmp::tmp::Test {} | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
const _: () = { | ||
const _: () = { | ||
mod tmp { | ||
pub(super) struct InnerTest; | ||
} | ||
|
||
impl tmp::InnerTest {} | ||
}; | ||
}; | ||
|
||
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,24 @@ | ||
// This test check that no matter the nesting of const-anons we consider | ||
// them as transparent. | ||
// | ||
// https://github.com/rust-lang/rust/issues/131474 | ||
|
||
//@ check-pass | ||
|
||
pub struct Test; | ||
|
||
const _: () = { | ||
const _: () = { | ||
impl Test {} | ||
}; | ||
}; | ||
|
||
const _: () = { | ||
const _: () = { | ||
struct InnerTest; | ||
|
||
impl InnerTest {} | ||
}; | ||
}; | ||
|
||
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