diff options
| author | bors <bors@rust-lang.org> | 2021-01-10 23:36:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-10 23:36:33 +0000 |
| commit | 26d451f4b3bcbea68eb80856aeddf37af52991ac (patch) | |
| tree | 1fef6a7c8b363237f3aac07822458f9f045a247b /compiler/rustc_span/src | |
| parent | c97f11af7bc4a6d3578f6a953be04ab2449a5728 (diff) | |
| parent | 3ff866ed7c814add27d32a31caaf29fa44cb53f5 (diff) | |
Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasper
resolve: Scope visiting doesn't need an `Ident` Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part. The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow. I think it's clearer to pass only the necessary part. Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case. r? `@matthewjasper`
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/hygiene.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 27dc9e9ecea..1fb5642912f 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -622,6 +622,10 @@ impl SyntaxContext { pub fn dollar_crate_name(self) -> Symbol { HygieneData::with(|data| data.syntax_context_data[self.0 as usize].dollar_crate_name) } + + pub fn edition(self) -> Edition { + self.outer_expn_data().edition + } } impl fmt::Debug for SyntaxContext { diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 99f01062545..62ca7b066d9 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -301,6 +301,10 @@ pub struct SpanData { impl SpanData { #[inline] + pub fn span(&self) -> Span { + Span::new(self.lo, self.hi, self.ctxt) + } + #[inline] pub fn with_lo(&self, lo: BytePos) -> Span { Span::new(lo, self.hi, self.ctxt) } @@ -468,7 +472,7 @@ impl Span { /// Edition of the crate from which this span came. pub fn edition(self) -> edition::Edition { - self.ctxt().outer_expn_data().edition + self.ctxt().edition() } #[inline] |
