about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-06-09 15:34:23 -0400
committerAaron Hill <aa1ronham@gmail.com>2020-06-10 17:30:11 -0400
commit28946b3486d507418b8a4acb92d5e2baae193d65 (patch)
treecdbadae12d6f219305db1970a86feda27bf92c33 /src/rustllvm/RustWrapper.cpp
parentbb8674837a9cc5225020e07fc3f164762bb4c11c (diff)
downloadrust-28946b3486d507418b8a4acb92d5e2baae193d65.tar.gz
rust-28946b3486d507418b8a4acb92d5e2baae193d65.zip
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
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions