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

Don't crash when reporting nice region errors for generic const items #114758

Merged
merged 1 commit into from
Aug 13, 2023

Conversation

fmease
Copy link
Member

@fmease fmease commented Aug 12, 2023

Fixes #114714.

@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2023

r? @compiler-errors

(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 Aug 12, 2023
Comment on lines 31 to +40
let (named, anon, anon_param_info, region_info) = if sub.has_name()
&& self.tcx().is_suitable_region(sup).is_some()
&& self.find_param_with_region(sup, sub).is_some()
&& let Some(region_info) = self.tcx().is_suitable_region(sup)
&& let Some(anon_param_info) = self.find_param_with_region(sup, sub)
{
(
sub,
sup,
self.find_param_with_region(sup, sub).unwrap(),
self.tcx().is_suitable_region(sup).unwrap(),
)
(sub, sup, anon_param_info, region_info)
} else if sup.has_name()
&& self.tcx().is_suitable_region(sub).is_some()
&& self.find_param_with_region(sub, sup).is_some()
&& let Some(region_info) = self.tcx().is_suitable_region(sub)
&& let Some(anon_param_info) = self.find_param_with_region(sub, sup)
{
(
sup,
sub,
self.find_param_with_region(sub, sup).unwrap(),
self.tcx().is_suitable_region(sub).unwrap(),
)
(sup, sub, anon_param_info, region_info)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a refactoring to get rid of the .unwrap()s. Let-chains <3

@@ -64,7 +64,7 @@ pub fn find_param_with_region<'tcx>(
let body_id = hir.maybe_body_owned_by(def_id)?;

let owner_id = hir.body_owner(body_id);
let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap();
let fn_decl = hir.fn_decl_by_hir_id(owner_id)?;
Copy link
Member Author

@fmease fmease Aug 12, 2023

Choose a reason for hiding this comment

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

At this point we may also have parametrized const items, not only function items. Thus, don't unwrap but just bail out (find_param_with_region is only applicable to functions).

@fmease fmease force-pushed the fix-nice-re-err-ice-gci branch from ff54c35 to 1a18158 Compare August 12, 2023 13:35
@cjgillot
Copy link
Contributor

Thanks.
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 12, 2023

📌 Commit 1a18158 has been approved by cjgillot

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-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 12, 2023
…cjgillot

Don't crash when reporting nice region errors for generic const items

Fixes rust-lang#114714.
@bors
Copy link
Contributor

bors commented Aug 13, 2023

⌛ Testing commit 1a18158 with merge 2b26bf5...

@bors
Copy link
Contributor

bors commented Aug 13, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 2b26bf5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 13, 2023
@bors bors merged commit 2b26bf5 into rust-lang:master Aug 13, 2023
@rustbot rustbot added this to the 1.73.0 milestone Aug 13, 2023
@fmease fmease deleted the fix-nice-re-err-ice-gci branch August 13, 2023 16:33
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2b26bf5): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

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)
3.7% [3.7%, 3.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-3.3%, -3.0%] 2
All ❌✅ (primary) 3.7% [3.7%, 3.7%] 1

Cycles

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

Binary size

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

Bootstrap: 634.281s -> 633.947s (-0.05%)

@fmease fmease added the F-generic_const_items `#![feature(generic_const_items)]` label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-generic_const_items `#![feature(generic_const_items)]` 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.

ICE: generic_const_items: error_reporting/nice_region_error/util.rs: called Option::unwrap() on a None value
6 participants