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.
AST validation: Improve handling of inherent impls nested within func…
…tions and anon consts
- Loading branch information
Showing
4 changed files
with
102 additions
and
27 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
35 changes: 35 additions & 0 deletions
35
tests/ui/parser/impls-nested-within-anon-consts-semantic.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,35 @@ | ||
// Regression test for issue #89342 and for part of #119924. | ||
//@ check-pass | ||
|
||
struct Expr<const N: u32>; | ||
|
||
trait Trait0 { | ||
fn required(_: Expr<{ | ||
struct Type; | ||
|
||
impl Type { | ||
// This visibility qualifier used to get rejected. | ||
pub fn perform() {} | ||
} | ||
|
||
0 | ||
}>); | ||
} | ||
|
||
trait Trait1 {} | ||
|
||
impl Trait1 for () | ||
where | ||
[(); { | ||
struct Type; | ||
|
||
impl Type { | ||
// This visibility qualifier used to get rejected. | ||
pub const STORE: Self = Self; | ||
} | ||
|
||
0 | ||
}]: | ||
{} | ||
|
||
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,15 @@ | ||
// Regression test for #121607 and for part of issue #119924. | ||
//@ check-pass | ||
|
||
trait Trait { | ||
fn provided() { | ||
pub struct Type; | ||
|
||
impl Type { | ||
// This visibility qualifier used to get rejected. | ||
pub fn perform() {} | ||
} | ||
} | ||
} | ||
|
||
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,22 @@ | ||
// Regression test for part of issue #119924. | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
|
||
#[const_trait] | ||
trait Trait { | ||
fn required(); | ||
} | ||
|
||
impl const Trait for () { | ||
fn required() { | ||
pub struct Type; | ||
|
||
impl Type { | ||
// This visibility qualifier used to get rejected. | ||
pub fn perform() {} | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |