remove unreachable error code E0476#106840
Conversation
|
Some changes occurred in diagnostic error codes |
|
Looks good to me but since it's changing compiler's code, we'll need someone from their team. r? @estebank |
| }; | ||
| let (source, target, trait_def_id, kind) = match (source.kind(), target.kind()) { | ||
| (&ty::Ref(r_a, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => { | ||
| infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a); |
There was a problem hiding this comment.
Why is this line removed? This has side-effects.
There was a problem hiding this comment.
You could give it a different subregion origin, but this is required for soundness 😓
There was a problem hiding this comment.
This code reproduces this error:
#![feature(coerce_unsized)]
#![feature(unsize)]
use core::marker::Unsize;
use core::ops::CoerceUnsized;
struct Wrapper<T>(T);
impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}Although it has a coherence error as well. Presumably if you made https://doc.rust-lang.org/src/core/ops/unsize.rs.html#55 this implementation unsound by removing 'b: 'a, then it would also trigger there.
There was a problem hiding this comment.
Ahh, my mistake, I assumed that this error code was no longer used. I'll close this PR and document/test it instead.
There was a problem hiding this comment.
It's alright -- in general, I would never remove side-effect-ful logic just because you think it's dead code. Sometimes people just forget to add a UI test for an error code.
Replace it with a delay_span_bug or bug!() if necessary, but unless you can statically prove that something is unreachable, you're very likely to introduce unsoundness or other subtle bugs into the compiler.
There was a problem hiding this comment.
Hmm, I was kind of naive. I assumed that untested error codes (basically all of them are like this) were from old Rust versions and had never been formally removed.
Remove
E0476unreachable/undocumented/untested error code.r? @GuillaumeGomez (I don't think you've noticed my other PRs for #61137 so I'll do more than just ping)