-
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
Improve spans for indexing expressions #114434
Conversation
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
| | ||
LL | let _ = z[0]; | ||
| ^^^^ help: to access tuple elements, use: `z.0` | ||
| ^^^ help: to access tuple elements, use: `.0` |
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.
maybe this got a little worse by not saying z.0
in the message anymore but mentioning the LHS could quickly get out of hand with larger lhs exprs so I don't think this is a problem.
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.
Ideally it would include the LHS if it is short, and if the LHS is longer (e.g. the criterion could be whether it's multiline or not), it would not include the LHS.
23d471b
to
c4e7a1e
Compare
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
c4e7a1e
to
5706be1
Compare
@bors r+ rollup |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#113945 (Fix wrong span for trait selection failure error reporting) - rust-lang#114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.) - rust-lang#114418 (bump parking_lot to 0.12) - rust-lang#114434 (Improve spans for indexing expressions) - rust-lang#114450 (Fix ICE failed to get layout for ReferencesError) - rust-lang#114461 (Fix unwrap on None) - rust-lang#114462 (interpret: add mplace_to_ref helper method) - rust-lang#114472 (Reword `confusable_idents` lint) - rust-lang#114477 (Account for `Rc` and `Arc` when suggesting to clone) r? `@ghost` `@rustbot` modify labels: rollup
Improve spans for indexing expressions fixes rust-lang#114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#113945 (Fix wrong span for trait selection failure error reporting) - rust-lang#114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.) - rust-lang#114418 (bump parking_lot to 0.12) - rust-lang#114434 (Improve spans for indexing expressions) - rust-lang#114450 (Fix ICE failed to get layout for ReferencesError) - rust-lang#114461 (Fix unwrap on None) - rust-lang#114462 (interpret: add mplace_to_ref helper method) - rust-lang#114472 (Reword `confusable_idents` lint) - rust-lang#114477 (Account for `Rc` and `Arc` when suggesting to clone) r? `@ghost` `@rustbot` modify labels: rollup
Improve spans for indexing expressions fixes rust-lang#114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#113945 (Fix wrong span for trait selection failure error reporting) - rust-lang#114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.) - rust-lang#114418 (bump parking_lot to 0.12) - rust-lang#114434 (Improve spans for indexing expressions) - rust-lang#114450 (Fix ICE failed to get layout for ReferencesError) - rust-lang#114461 (Fix unwrap on None) - rust-lang#114462 (interpret: add mplace_to_ref helper method) - rust-lang#114472 (Reword `confusable_idents` lint) - rust-lang#114477 (Account for `Rc` and `Arc` when suggesting to clone) r? `@ghost` `@rustbot` modify labels: rollup
Improve spans for indexing expressions fixes rust-lang#114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#113945 (Fix wrong span for trait selection failure error reporting) - rust-lang#114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.) - rust-lang#114418 (bump parking_lot to 0.12) - rust-lang#114434 (Improve spans for indexing expressions) - rust-lang#114450 (Fix ICE failed to get layout for ReferencesError) - rust-lang#114461 (Fix unwrap on None) - rust-lang#114462 (interpret: add mplace_to_ref helper method) - rust-lang#114472 (Reword `confusable_idents` lint) - rust-lang#114477 (Account for `Rc` and `Arc` when suggesting to clone) r? `@ghost` `@rustbot` modify labels: rollup
fixes #114388
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location.
This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the
fn_span
field in THIR.r? compiler-errors