diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2020-06-09 15:34:23 -0400 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2020-06-10 17:30:11 -0400 |
| commit | 28946b3486d507418b8a4acb92d5e2baae193d65 (patch) | |
| tree | cdbadae12d6f219305db1970a86feda27bf92c33 /src/librustc_save_analysis | |
| parent | bb8674837a9cc5225020e07fc3f164762bb4c11c (diff) | |
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/librustc_save_analysis')
| -rw-r--r-- | src/librustc_save_analysis/dump_visitor.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 489d38b00df..39cb39ba619 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -1375,7 +1375,9 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> { let res = self.save_ctxt.get_path_res(hir_expr.hir_id); self.process_struct_lit(ex, path, fields, adt.variant_of_res(res), *base) } - hir::ExprKind::MethodCall(ref seg, _, args) => self.process_method_call(ex, seg, args), + hir::ExprKind::MethodCall(ref seg, _, args, _) => { + self.process_method_call(ex, seg, args) + } hir::ExprKind::Field(ref sub_ex, _) => { self.visit_expr(&sub_ex); |
