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

thir::pattern: update some comments and error type names #115887

Merged
merged 2 commits into from
Sep 27, 2023

Conversation

RalfJung
Copy link
Member

Follow-up to these comments. Please carefully fact-check, I'm new to this area of the compiler!

@rustbot
Copy link
Collaborator

rustbot commented Sep 16, 2023

r? @jackh726

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 16, 2023
@rustbot
Copy link
Collaborator

rustbot commented Sep 16, 2023

Some changes might have occurred in exhaustiveness checking

cc @Nadrieril

@rust-log-analyzer

This comment has been minimized.

PatKind::Wild
}
ty::Adt(adt_def, _) if !self.type_marked_structural(ty) => {
debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty,);
self.saw_const_match_error.set(true);
let err = TypeNotStructural { span, non_sm_ty: ty };
tcx.sess.emit_err(err);
// We errored, so the pattern we generate is irrelevant.
Copy link
Member

Choose a reason for hiding this comment

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

That comment was much needed. This always bothered me because if we forgot to error this would cause unsoundness (non exhaustive match considered exhaustive)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'd much prefer something that ICEs later... in particular in that one case where we don't actually emit the error, we check that the flag says that we emitted an error earlier.

In fact, let me add a delay_span_bug in that case just to be sure.

@@ -423,6 +425,7 @@ impl<'tcx> ConstToPat<'tcx> {
tcx.sess.emit_err(err);

// FIXME: introduce PatKind::Error to silence follow up diagnostics due to unreachable patterns.
// We errored, so the pattern we generate is irrelevant.
PatKind::Wild
Copy link
Member

Choose a reason for hiding this comment

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

Should this one set saw_const_match_error too?

Copy link
Member Author

@RalfJung RalfJung Sep 17, 2023

Choose a reason for hiding this comment

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

Hm, it doesn't check for saw_const_match_error either. But I guess yes? Not sure. This PR was not meant to have any behavior changes in it, just comments and clarifications.

Copy link
Member

Choose a reason for hiding this comment

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

Ah fair; I was just thinking that should also trigger a delay_span_bug

Copy link
Member Author

Choose a reason for hiding this comment

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

The emit_err is directly above here so theres'a definitely a hard error. In the other case where I added a delay_span_bug, the emit_err is conditional on something, so it becomes a non-local property, and I felt it was worth simplifying the reasoning, so that the failure mode for if saw_const_match_error gets set incorrectly is an ICE rather than a weird miscompilation.

@RalfJung
Copy link
Member Author

r? @oli-obk
AFAIK you wrote (most of) this code so this probably makes sense.

@rustbot rustbot assigned oli-obk and unassigned jackh726 Sep 18, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Sep 27, 2023

Marking as blocked on #115937 (as some of the comments don't apply anymore afterwards)

@oli-obk oli-obk added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 27, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Sep 27, 2023

r=me after that

@RalfJung
Copy link
Member Author

Hm, I was thinking to land this first to document the status quo, and then #115937 would update the comments. But in the end I don't care strongly, I mostly wanted to get confirmation that the comments here are correct, in particular around FallbackToConstRef being completely outdated (its use has nothing to do with references any more: we use it even without references, and we don't use it with all references).

@oli-obk
Copy link
Contributor

oli-obk commented Sep 27, 2023

@bors r+ rollup

wfm

I mostly wanted to get confirmation that the comments here are correct, in particular around FallbackToConstRef being completely outdated (its use has nothing to do with references any more: we use it even without references, and we don't use it with all references).

Yea, I just started reusing it without adjusting the name

@bors
Copy link
Contributor

bors commented Sep 27, 2023

📌 Commit 12a1b55 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Sep 27, 2023
@bors
Copy link
Contributor

bors commented Sep 27, 2023

⌛ Testing commit 12a1b55 with merge c4ce33c...

@bors
Copy link
Contributor

bors commented Sep 27, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing c4ce33c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 27, 2023
@bors bors merged commit c4ce33c into rust-lang:master Sep 27, 2023
12 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 27, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c4ce33c): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.3%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.3% [1.3%, 1.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-4.7%, -4.7%] 1
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.5%] 2
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.9% [-0.9%, -0.9%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 632.158s -> 632.345s (0.03%)
Artifact size: 317.25 MiB -> 317.20 MiB (-0.02%)

@RalfJung RalfJung deleted the pat branch September 30, 2023 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants