Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update indirect_structural_match and pointer_structural_match lints to match RFC and to show up for dependencies #120423

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
merge the accepted-structural-match tests into one
  • Loading branch information
RalfJung committed Feb 5, 2024
commit e00df17abd6eabfead30dce439592b1902fd0acd
34 changes: 0 additions & 34 deletions tests/ui/consts/const_in_pattern/accept_corner_cases.rs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting these patterns is the key change here -- we no longer plan to reject these in the future so we don't have to lint against them.

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), };
}
Loading