You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid (unstable, ill-formed, ...) const code is evaluated even after emitting error #76064
Nightly-only ICEs are exposed on stable because array lengths are evaluated even when they are invalid:
structBug([u8;panic!(1)]);
This first emits an error that a feature flag is missing, but then const-evaluates the array length anyway and later leads to an ICE. This is not a stability hole (there's an error, the code will not compile), but it's an ICE on stable, so it's a bug.
While the ICE should also be fixed, the underlying problem is that we should not const-evaluate code that failed stability checking (and there are possibly other kinds of checks to which this applies as well)
Putting this on ConstQualifs seems reasonable. It seems better than adding more cruft to mir::Body at first glance. Currently each field of ConstQualifs is tied to an implementer of the Qualif trait but this isn't a hard requirement.
Once this is fixed, we can hopefully also get rid of the TransmuteSizeDiff hack. I am not sure if we carry any other similar hacks that we still carry around.
@oli-obk the solution at #78809, if I understand correctly, does not fix TransmuteSizeDiff... should that become a separate issue once this one is closed, or is there some reason that TransmuteSizeDiff cannot be fixed by adding a similar ErrorReported to the transmute size check?
It does indeed not fix TransmuteSizeDiff. We'll need to investigate what actually causes a transmute size check failure to not affect tainted_by_errors. We can likely fix this in a similar manner. Though we also have other bugs like { let x; &x } getting all the way to interning when it fails due to a dangling pointer. We'll be collecting more and more error flags to keep track of. I'm not sure how to address this properly. Maybe we'll need more Result<T, ErrorReported> on queries that don't return an enum which has an error variant (like ty::Err or ConstKind::Err)
Activity
ecstatic-morse commentedon Aug 30, 2020
Putting this on
ConstQualifsseems reasonable. It seems better than adding more cruft tomir::Bodyat first glance. Currently each field ofConstQualifsis tied to an implementer of theQualiftrait but this isn't a hard requirement.RalfJung commentedon Nov 2, 2020
Once this is fixed, we can hopefully also get rid of the
TransmuteSizeDiffhack. I am not sure if we carry any other similar hacks that we still carry around.RalfJung commentedon Nov 7, 2020
@oli-obk the solution at #78809, if I understand correctly, does not fix
TransmuteSizeDiff... should that become a separate issue once this one is closed, or is there some reason thatTransmuteSizeDiffcannot be fixed by adding a similarErrorReportedto the transmute size check?oli-obk commentedon Nov 9, 2020
It does indeed not fix
TransmuteSizeDiff. We'll need to investigate what actually causes a transmute size check failure to not affecttainted_by_errors. We can likely fix this in a similar manner. Though we also have other bugs like{ let x; &x }getting all the way to interning when it fails due to a dangling pointer. We'll be collecting more and more error flags to keep track of. I'm not sure how to address this properly. Maybe we'll need moreResult<T, ErrorReported>on queries that don't return an enum which has an error variant (likety::ErrorConstKind::Err)add error_occured field to ConstQualifs, fix rust-lang#76064
add error_occured field to ConstQualifs, fix rust-lang#76064
RalfJung commentedon Nov 14, 2020
I opened a new issue for the
transmuteproblem: #79047.Auto merge of rust-lang#78809 - vn-ki:fix-issue-76064, r=oli-obk
Auto merge of rust-lang#78809 - vn-ki:fix-issue-76064, r=oli-obk