rust/src/librustc_lint
Aaron Hill 28946b3486
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-10 17:30:11 -04:00
..
nonstandard_style
array_into_iter.rs Track span of function in method calls, and use this in #[track_caller] 2020-06-10 17:30:11 -04:00
builtin.rs Track span of function in method calls, and use this in #[track_caller] 2020-06-10 17:30:11 -04:00
Cargo.toml Implement confusable_idents lint. 2020-05-03 02:30:50 +08:00
context.rs Clarify unused_doc_comments note on macro invocations 2020-04-21 21:16:50 -07:00
early.rs Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
internal.rs Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
late.rs Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
levels.rs properly handle feature gated lints 2020-06-05 13:52:34 -07:00
lib.rs rustc_lint: Remove unused_crate_dependencies from the unused group 2020-05-28 20:03:36 +03:00
non_ascii_idents.rs Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
nonstandard_style.rs rustc -> rustc_middle part 3 (rustfmt) 2020-03-30 07:19:55 +02:00
passes.rs Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
redundant_semicolon.rs encode ; stmt w/o expr as StmtKind::Empty 2020-03-01 23:02:17 +01:00
types.rs Remove ty::UnnormalizedProjection 2020-05-12 01:56:29 -04:00
unused.rs Track span of function in method calls, and use this in #[track_caller] 2020-06-10 17:30:11 -04:00