-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
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) |
There was a problem hiding this comment.
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)?; |
There was a problem hiding this comment.
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).
ff54c35
to
1a18158
Compare
Thanks. |
…cjgillot Don't crash when reporting nice region errors for generic const items Fixes rust-lang#114714.
☀️ Test successful - checks-actions |
Finished benchmarking commit (2b26bf5): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 634.281s -> 633.947s (-0.05%) |
Fixes #114714.