rust/src/librustc_ast
Dylan DPC 84b9145076
Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasper
Track span of function in method calls, and use this in #[track_caller]

Fixes #69977

When we parse a chain of method calls like `foo.a().b().c()`, each
`MethodCallExpr` gets assigned a span that starts at the beginning of
the call chain (`foo`). While this is useful for diagnostics, it means
that `Location::caller` will return the same location for every call
in a call chain.

This PR makes us separately record the span of the function name and
arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This
`Span` is passed through HIR lowering and MIR building to
`TerminatorKind::Call`, where it is used in preference to
`Terminator.source_info.span` when determining `Location::caller`.

This new span is also useful for diagnostics where we want to emphasize
a particular method call - for an example, see
https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-11 19:04:16 +02:00
..
ast Move directory libsyntax -> librustc_ast 2020-02-29 20:47:10 +03:00
attr Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
expand rustc -> rustc_middle part 1 2020-03-30 07:02:56 +02:00
util Track span of function in method calls, and use this in #[track_caller] 2020-06-10 17:30:11 -04:00
ast.rs Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasper 2020-06-11 19:04:16 +02:00
build.rs Move directory libsyntax -> librustc_ast 2020-02-29 20:47:10 +03:00
Cargo.toml Make things build again 2020-06-02 20:38:24 +03:00
crate_disambiguator.rs move CrateDisambiguator -> rustc_ast 2020-03-21 22:18:57 +01:00
entry.rs rustc -> rustc_middle part 1 2020-03-30 07:02:56 +02:00
lib.rs Work around ICEs during cross-compilation 2020-05-08 09:38:18 -06:00
mut_visit.rs Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasper 2020-06-11 19:04:16 +02:00
node_id.rs Rename from_u32_const -> from_u32 2020-03-17 11:15:40 -07:00
ptr.rs Move directory libsyntax -> librustc_ast 2020-02-29 20:47:10 +03:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
token.rs Revert "Move functions to librustc_parse" 2020-05-29 00:19:11 -04:00
tokenstream.rs Fix more clippy warnings 2020-06-09 18:51:08 +02:00
visit.rs Track span of function in method calls, and use this in #[track_caller] 2020-06-10 17:30:11 -04:00

The rustc_ast crate contains those things concerned purely with syntax that is, the AST ("abstract syntax tree"), parser, pretty-printer, lexer, macro expander, and utilities for traversing ASTs.

For more information about how these things work in rustc, see the rustc dev guide: