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

feat: min_exhaustive_patterns #17853

Merged
merged 3 commits into from
Aug 13, 2024
Merged

Conversation

ShoyuVanilla
Copy link
Member

Resolves #17851

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 11, 2024
@@ -328,7 +325,7 @@ impl<'db> PatCx for MatchCheckCtx<'db> {
self.exhaustive_patterns
}
fn is_min_exhaustive_patterns_feature_on(&self) -> bool {
self.min_exhaustive_patterns
true
Copy link
Member Author

Choose a reason for hiding this comment

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

Should I bump up ra-ap-rustc_pattern_analysis to latest instead?

Copy link
Member

Choose a reason for hiding this comment

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

There is a PR upstream enabling the in-tree pattern analysis in the rust repo (to prevent us from going out of sync), so these two PRs will likely collide. Might be best if either PR waits on the other (and if we pick this one here first then yes we should bump the dependency here), cc @Nadrieril

Copy link
Member Author

@ShoyuVanilla ShoyuVanilla Aug 11, 2024

Choose a reason for hiding this comment

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

Since the rust-lang/rust#128922 is in homu queue, maybe I should wait for it?

_ => true,
}
}

Copy link
Member Author

@ShoyuVanilla ShoyuVanilla Aug 11, 2024

Choose a reason for hiding this comment

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

@@ -95,8 +93,7 @@ impl<'db> MatchCheckCtx<'db> {
}
}

// FIXME: Determine place validity correctly. For now, err on the safe side.
let place_validity = PlaceValidity::MaybeInvalid;
let place_validity = PlaceValidity::from_bool(known_valid_scrutinee.unwrap_or(true));
Copy link
Member Author

Choose a reason for hiding this comment

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

let Ok(_y) = x;
}
"#,
);
Copy link
Member Author

@ShoyuVanilla ShoyuVanilla Aug 11, 2024

Choose a reason for hiding this comment

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

The reason that this test doesn't have a pointer deref case is because the following code;

fn test(ptr: *const Result<i32, !>) {
    unsafe {
        let Ok(_x) = *ptr;
    }
}

is getting a block with no stmts but tail one in here(thus, no diagnostic error),

fn validate_block(&mut self, db: &dyn HirDatabase, expr: &Expr) {
let Expr::Block { statements, .. } = expr else { return };

while the following is getting a block with a single stmt without tail 🤔

fn test(x: Result<i32, &'static !>) {
    let Ok(_y) = x;
}

I'll make a more deep inspection and file this as a new issue

Copy link
Member

Choose a reason for hiding this comment

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

is getting a block with no stmts but tail one in here(thus, no diagnostic error),

oh no that sounds very wrong

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it looks very wrong 🤔 I'll check the entire lowering process from AST to hir once I get back home

Copy link
Member Author

@ShoyuVanilla ShoyuVanilla Aug 12, 2024

Choose a reason for hiding this comment

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

This is because of #17865

Copy link
Member Author

Choose a reason for hiding this comment

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

I got into this 😂 rust-lang/rust#129009

@Veykril
Copy link
Member

Veykril commented Aug 11, 2024 via email

@ShoyuVanilla
Copy link
Member Author

In either case, I'll continue on this about 20 hours later when I get back from work because it's midnight here 😅

@Veykril
Copy link
Member

Veykril commented Aug 11, 2024

No rush

@ShoyuVanilla
Copy link
Member Author

Well, the latest ra-ap-rustc_pattern_analysis, 0.62.0 does not pointing at 853255e, which is quite strange that the roll-up merge had been completed about two hours before scheduled rustc-auto-publish's publish action 🤔
Actually, the publish workflow wasn't triggered last sunday

@Veykril
Copy link
Member

Veykril commented Aug 12, 2024

Eh, the autopublish action got frozen by github again due to repo inactivity

bors added a commit that referenced this pull request Aug 12, 2024
fix: Missing non-exhaustive let diagnostics inside async or unsafe block

The reason that this test doesn't have a pointer deref case is because the following code;
```rust
fn test(ptr: *const Result<i32, !>) {
    unsafe {
        let Ok(_x) = *ptr;
    }
}
```
is getting a block with no stmts but tail one in here(thus, no diagnostic error),
https://github.com/rust-lang/rust-analyzer/blob/0daeb5c0b05cfdf2101b0f078c27539099bf38e6/crates/hir-ty/src/diagnostics/expr.rs#L256-L257
while the following is getting a block with a single stmt without tail 🤔
```rust
fn test(x: Result<i32, &'static !>) {
    let Ok(_y) = x;
}
```
I'll make a more deep inspection and file this as a new issue

_Originally posted by `@ShoyuVanilla` in #17853 (comment)
@Veykril
Copy link
Member

Veykril commented Aug 12, 2024

Kicked off a new one https://github.com/rust-analyzer/rustc-auto-publish/actions/workflows/main.yml

@bors
Copy link
Contributor

bors commented Aug 12, 2024

☔ The latest upstream changes (presumably #17865) made this pull request unmergeable. Please resolve the merge conflicts.

Cargo.toml Outdated
Comment on lines 88 to 90
ra-ap-rustc_parse_format = { version = "0.53.0", default-features = false }
ra-ap-rustc_index = { version = "0.53.0", default-features = false }
ra-ap-rustc_abi = { version = "0.53.0", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

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

Do bump the other three as well otherwise we get some duplicate transitive dependencies

@Veykril
Copy link
Member

Veykril commented Aug 13, 2024

@bors delegate+

@bors
Copy link
Contributor

bors commented Aug 13, 2024

✌️ @ShoyuVanilla, you can now approve this pull request!

If @Veykril told you to "r=me" after making some further change, please make that change, then do @bors r=@Veykril

@ShoyuVanilla
Copy link
Member Author

@bors r+

@bors
Copy link
Contributor

bors commented Aug 13, 2024

📌 Commit 588fa2c has been approved by ShoyuVanilla

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 13, 2024

⌛ Testing commit 588fa2c with merge e25abba...

@bors
Copy link
Contributor

bors commented Aug 13, 2024

☀️ Test successful - checks-actions
Approved by: ShoyuVanilla
Pushing e25abba to master...

@bors bors merged commit e25abba into rust-lang:master Aug 13, 2024
11 checks passed
@ShoyuVanilla ShoyuVanilla deleted the min-exhaustive-pat branch August 13, 2024 14:38
lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 13, 2024
fix: Missing non-exhaustive let diagnostics inside async or unsafe block

The reason that this test doesn't have a pointer deref case is because the following code;
```rust
fn test(ptr: *const Result<i32, !>) {
    unsafe {
        let Ok(_x) = *ptr;
    }
}
```
is getting a block with no stmts but tail one in here(thus, no diagnostic error),
https://github.com/rust-lang/rust-analyzer/blob/0daeb5c0b05cfdf2101b0f078c27539099bf38e6/crates/hir-ty/src/diagnostics/expr.rs#L256-L257
while the following is getting a block with a single stmt without tail 🤔
```rust
fn test(x: Result<i32, &'static !>) {
    let Ok(_y) = x;
}
```
I'll make a more deep inspection and file this as a new issue

_Originally posted by `@ShoyuVanilla` in rust-lang/rust-analyzer#17853 (comment)
@Nadrieril
Copy link
Member

Just had time to take a look, looks good to me! Thx for taking the time to do this

@lnicola lnicola changed the title feat: min-exhaustive-patterns feat: min_exhaustive_patterns Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support min_exhaustive_patterns
5 participants