Fix save-analysis generation crash with invalid tuple access#48778
Merged
alexcrichton merged 2 commits intorust-lang:masterfrom Mar 8, 2018
Merged
Fix save-analysis generation crash with invalid tuple access#48778alexcrichton merged 2 commits intorust-lang:masterfrom
alexcrichton merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
|
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
Member
|
r? @nrc |
nrc
reviewed
Mar 6, 2018
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
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
Member
|
OK, makes sense. Second commit looks fine. @bors: r+ |
Collaborator
|
📌 Commit f5a3efe has been approved by |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Mar 7, 2018
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
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Mar 7, 2018
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reproduction:
This should fix a crash in RLS when editing such code. cc @nrc