Skip to content

Commit

Permalink
merge the accepted-structural-match tests into one
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 5, 2024
1 parent 45d01b8 commit e00df17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
34 changes: 0 additions & 34 deletions tests/ui/consts/const_in_pattern/accept_corner_cases.rs

This file was deleted.

14 changes: 14 additions & 0 deletions tests/ui/consts/const_in_pattern/accept_structural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ fn main() {

const ADDR_OF: &OND = &None;
match &None { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };

// These ones are more subtle: the final value is fine, but statically analyzing the expression
// that computes the value would likely (incorrectly) have us conclude that this may match on
// values that do not have structural equality.
const INDEX: Option<NoDerive> = [None, Some(NoDerive(10))][0];
match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };

const fn build() -> Option<NoDerive> { None }
const CALL: Option<NoDerive> = build();
match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), };

impl NoDerive { const fn none() -> Option<NoDerive> { None } }
const METHOD_CALL: Option<NoDerive> = NoDerive::none();
match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CALL), };
}

0 comments on commit e00df17

Please sign in to comment.