diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-11-06 07:03:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-06 07:03:03 +0100 |
| commit | 24af0c94b30271198d6101cdd14c78182f76fd07 (patch) | |
| tree | 3d3a3a48a2eb026852412562d7b038a01b65ae8b /src/libsyntax_expand | |
| parent | a0b4b4dafaef944df28f2d9d5e94d6ce190a0504 (diff) | |
| parent | 49f9626a553c0ff191aa96912f4880f99d0a8716 (diff) | |
| download | rust-24af0c94b30271198d6101cdd14c78182f76fd07.tar.gz rust-24af0c94b30271198d6101cdd14c78182f76fd07.zip | |
Rollup merge of #65973 - eddyb:caller-location-panic, r=petrochenkov
caller_location: point to macro invocation sites, like file!/line!, and use in core::panic!. The main change here is to `core::panic!`, trying to fix this remaining regression: https://github.com/rust-lang/rust/pull/65927#issuecomment-547625147 However, in order for `caller_location` to be usable from macros the same way `file!()`/`line!()` are, it needs to have the same behavior (of extracting the macro invocation site `Span` and using that). Arguably we would've had to do this at some point anyway, if we want to use `#[track_caller]` to replace the `file!()`/`line!()` uses from macros, but I'm not sure the RFC mentions this at all. r? @petrochenkov cc @anp @nnethercote
Diffstat (limited to 'src/libsyntax_expand')
| -rw-r--r-- | src/libsyntax_expand/base.rs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/libsyntax_expand/base.rs b/src/libsyntax_expand/base.rs index 6cc7b7da53b..d02251eb746 100644 --- a/src/libsyntax_expand/base.rs +++ b/src/libsyntax_expand/base.rs @@ -953,18 +953,7 @@ impl<'a> ExtCtxt<'a> { /// /// Stops backtracing at include! boundary. pub fn expansion_cause(&self) -> Option<Span> { - let mut expn_id = self.current_expansion.id; - let mut last_macro = None; - loop { - let expn_data = expn_id.expn_data(); - // Stop going up the backtrace once include! is encountered - if expn_data.is_root() || expn_data.kind.descr() == sym::include { - break; - } - expn_id = expn_data.call_site.ctxt().outer_expn(); - last_macro = Some(expn_data.call_site); - } - last_macro + self.current_expansion.id.expansion_cause() } pub fn struct_span_warn<S: Into<MultiSpan>>(&self, |
