-
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.
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/test/ui/type-alias-impl-trait/structural-match-no-leak.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,20 @@ | ||
#![feature(const_fn, type_alias_impl_trait)] | ||
|
||
type Bar = impl Send; | ||
|
||
// While i32 is structural-match, we do not want to leak this information. | ||
// (See https://github.com/rust-lang/rust/issues/72156) | ||
const fn leak_free() -> Bar { | ||
7i32 | ||
} | ||
const LEAK_FREE: Bar = leak_free(); | ||
|
||
fn leak_free_test() { | ||
match todo!() { | ||
LEAK_FREE => (), | ||
//~^ opaque types cannot be used in patterns | ||
_ => (), | ||
} | ||
} | ||
|
||
fn main() { } |
8 changes: 8 additions & 0 deletions
8
src/test/ui/type-alias-impl-trait/structural-match-no-leak.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: opaque types cannot be used in patterns | ||
--> $DIR/structural-match-no-leak.rs:14:9 | ||
| | ||
LL | LEAK_FREE => (), | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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,21 @@ | ||
#![feature(const_fn, type_alias_impl_trait)] | ||
|
||
type Foo = impl Send; | ||
|
||
// This is not structural-match | ||
struct A; | ||
|
||
const fn value() -> Foo { | ||
A | ||
} | ||
const VALUE: Foo = value(); | ||
|
||
fn test() { | ||
match todo!() { | ||
VALUE => (), | ||
//~^ opaque types cannot be used in patterns | ||
_ => (), | ||
} | ||
} | ||
|
||
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,8 @@ | ||
error: opaque types cannot be used in patterns | ||
--> $DIR/structural-match.rs:15:9 | ||
| | ||
LL | VALUE => (), | ||
| ^^^^^ | ||
|
||
error: aborting due to previous error | ||
|