-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Avoid "no field" error and ICE on recovered ADT variant #127575
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
Avoid "no field" error and ICE on recovered ADT variant #127575
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…ice, r=<try> Avoid no field error and ice no recovered struct variant Fixes rust-lang#126744 Fixes rust-lang#126344, a more general fix compared with rust-lang#127426 r? `@oli-obk` From `@compiler-errors` 's comment rust-lang#127502 (comment) Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
If we changed the |
lol we could make https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html#method.new_adt return an error type if the |
I really don't think we should do this unless there's a compelling reason to do so. These constructor functions shouldn't be lying about their output. It's one thing to change the |
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.
You also need to delete a test from the crashes directory I think
@@ -2547,6 +2544,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |||
"ban_nonexisting_field: field={:?}, base={:?}, expr={:?}, base_ty={:?}", | |||
ident, base, expr, base_ty | |||
); | |||
|
|||
for (ty, _) in self.autoderef(expr.span, base_ty) { |
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.
I'd kinda rather you handle this in the autoderef loop in check_field
.
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.
You mean like this?
20cc0e1
I also thought about it, I was afraid to add extra perf since we need to track whether it's tainted in normal path.
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.
or even we return Ty::new_error(self.tcx(), guar)
when there is an error.
This comment has been minimized.
This comment has been minimized.
if let Err(guard) = adt_def.non_enum_variant().has_errors() { | ||
recovered_variant = Some(guard); | ||
break; | ||
} |
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.
if let Err(guard) = adt_def.non_enum_variant().has_errors() { | |
recovered_variant = Some(guard); | |
break; | |
} | |
if let Err(guar) = adt_def.non_enum_variant().has_errors() { | |
return Ty::new_error(self.tcx, guar); | |
} |
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.
also side note: s/guard/guar, since "guar" is short for "guarantee"
Also can you squash this PR lol |
3d09cfa
to
c5afe4d
Compare
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.
One last thing -- can you leave a short comment next to all of these error-shortcuts you added saying something along the lines of "we don't care to report errors for a struct if the struct itself is tainted" or something
r=me after |
c5afe4d
to
3341966
Compare
3341966
to
07e6dd9
Compare
@bors r=compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (8c39ac9): 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)Results (secondary -3.0%)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.
CyclesResults (secondary -1.2%)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.
Binary sizeResults (primary 0.1%, secondary 0.1%)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.
Bootstrap: 705.402s -> 703.504s (-0.27%) |
Fixes #126744
Fixes #126344, a more general fix compared with #127426
r? @oli-obk
From @compiler-errors 's comment #127502 (comment)
Seems most of the ADTs don't have taint, so maybe it's not proper to change
TyCtxt::type_of
query.