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
90 additions
and
10 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
27 changes: 27 additions & 0 deletions
27
src/test/ui/pattern/usefulness/issue-80501-or-pat-and-macro.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,27 @@ | ||
#![deny(unreachable_patterns)] | ||
//~^ NOTE: lint level is defined here | ||
pub enum TypeCtor { | ||
Slice, | ||
Array, | ||
} | ||
|
||
pub struct ApplicationTy(TypeCtor); | ||
|
||
macro_rules! ty_app { | ||
($ctor:pat) => { | ||
ApplicationTy($ctor) //~ ERROR unreachable pattern | ||
}; | ||
} | ||
|
||
fn _foo(ty: ApplicationTy) { | ||
match ty { | ||
ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {} //~ NOTE: in this expansion | ||
} | ||
|
||
// same as above, with the macro expanded | ||
match ty { | ||
ApplicationTy(TypeCtor::Array) | ApplicationTy(TypeCtor::Slice) => {} | ||
} | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/pattern/usefulness/issue-80501-or-pat-and-macro.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,18 @@ | ||
error: unreachable pattern | ||
--> $DIR/issue-80501-or-pat-and-macro.rs:12:9 | ||
| | ||
LL | ApplicationTy($ctor) | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {} | ||
| ------------------------ in this macro invocation | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/issue-80501-or-pat-and-macro.rs:1:9 | ||
| | ||
LL | #![deny(unreachable_patterns)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to previous error | ||
|