-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix save-analysis generation crash with invalid tuple access #48778
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
r? @nrc |
@@ -1675,7 +1675,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc | |||
} | |||
} | |||
ty::TyTuple(..) => {} | |||
_ => span_bug!(ex.span, "Expected struct or tuple type, found {:?}", 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.
When you're using the invalid tuple constructor is this ty:err or something similarly specific? Could we explicitly catch that case and return, and still span_bug
ICE if it's something else? If we silently fail and cope then it's really hard to notice the omission until somebody reports a hard to discover bug against the RLS.
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.
It seems that almost all type variants (all but TyInfer
?) can be crafted.
fn foo<T>(x: T) {
bar.0; // TyError
(0).0; // TyError
x.0; // TyParam
static S: i32 = 0;
(S).0; // TyInt
[].0; // TyArray
extern { type Externed; }
(|| -> Externed { panic!() })().0; // TyForeign
(|| -> ! { panic!() })().0; // TyNever
...
}
fc1f766
to
f5a3efe
Compare
OK, makes sense. Second commit looks fine. @bors: r+ |
📌 Commit f5a3efe has been approved by |
Fix save-analysis generation crash with invalid tuple access Reproduction: ```rust fn invalid_tuple_struct_accessing() { bar.0; } ``` ``` error[E0425]: cannot find value `bar` in this scope --> test.rs:2:5 | 2 | bar.0; | ^^^ not found in this scope error[E0601]: main function not found error: internal compiler error: librustc_save_analysis/dump_visitor.rs:1678: Expected struct or tuple type, found TyError --> test.rs:2:5 | 2 | bar.0; | ^^^^^ thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:482:9 note: Run with `RUST_BACKTRACE=1` for a backtrace. ``` This should fix a crash in RLS when editing such code. cc @nrc
Fix save-analysis generation crash with invalid tuple access Reproduction: ```rust fn invalid_tuple_struct_accessing() { bar.0; } ``` ``` error[E0425]: cannot find value `bar` in this scope --> test.rs:2:5 | 2 | bar.0; | ^^^ not found in this scope error[E0601]: main function not found error: internal compiler error: librustc_save_analysis/dump_visitor.rs:1678: Expected struct or tuple type, found TyError --> test.rs:2:5 | 2 | bar.0; | ^^^^^ thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:482:9 note: Run with `RUST_BACKTRACE=1` for a backtrace. ``` This should fix a crash in RLS when editing such code. cc @nrc
Reproduction:
This should fix a crash in RLS when editing such code. cc @nrc