Skip to content

Commit e00df17

Browse files
committed
merge the accepted-structural-match tests into one
1 parent 45d01b8 commit e00df17

File tree

2 files changed

+14
-34
lines changed

2 files changed

+14
-34
lines changed

tests/ui/consts/const_in_pattern/accept_corner_cases.rs

-34
This file was deleted.

tests/ui/consts/const_in_pattern/accept_structural.rs

+14
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,18 @@ fn main() {
6363

6464
const ADDR_OF: &OND = &None;
6565
match &None { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
66+
67+
// These ones are more subtle: the final value is fine, but statically analyzing the expression
68+
// that computes the value would likely (incorrectly) have us conclude that this may match on
69+
// values that do not have structural equality.
70+
const INDEX: Option<NoDerive> = [None, Some(NoDerive(10))][0];
71+
match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
72+
73+
const fn build() -> Option<NoDerive> { None }
74+
const CALL: Option<NoDerive> = build();
75+
match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), };
76+
77+
impl NoDerive { const fn none() -> Option<NoDerive> { None } }
78+
const METHOD_CALL: Option<NoDerive> = NoDerive::none();
79+
match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CALL), };
6680
}

0 commit comments

Comments
 (0)