diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-10-25 15:33:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-25 15:33:41 +0000 |
| commit | e4ca952be655b5b5c3426ac47d9f3cac66b0a642 (patch) | |
| tree | 1a8d181e20c25134d5b660dd0f5a6aa161c1fe90 | |
| parent | aa04d3eb4fbde4eb21b1d921b3075c932e6930d4 (diff) | |
| parent | d2b8ca9b521af2f947fd2a7d5e803b9045b2e6c0 (diff) | |
| download | rust-e4ca952be655b5b5c3426ac47d9f3cac66b0a642.tar.gz rust-e4ca952be655b5b5c3426ac47d9f3cac66b0a642.zip | |
Merge #10633
10633: fix: Implement most proc_macro span handling for other ABIs r=Veykril a=Veykril Follow up to #10378 bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
| -rw-r--r-- | crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs | 41 | ||||
| -rw-r--r-- | crates/proc_macro_srv/src/abis/abi_1_55/rustc_server.rs | 41 |
2 files changed, 40 insertions, 42 deletions
diff --git a/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs index a77433a5512..d3d021d808f 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs @@ -423,19 +423,20 @@ impl server::Group for Rustc { group.delimiter.map(|it| it.id).unwrap_or_else(tt::TokenId::unspecified) } - fn set_span(&mut self, _group: &mut Self::Group, _span: Self::Span) { - // FIXME handle span + fn set_span(&mut self, group: &mut Self::Group, span: Self::Span) { + if let Some(delim) = &mut group.delimiter { + delim.id = span; + } } - fn span_open(&mut self, _group: &Self::Group) -> Self::Span { - // FIXME handle span - // MySpan(self.span_interner.intern(&MySpanData(group.span_open()))) - tt::TokenId::unspecified() + fn span_open(&mut self, group: &Self::Group) -> Self::Span { + // FIXME we only store one `TokenId` for the delimiters + group.delimiter.map(|it| it.id).unwrap_or_else(tt::TokenId::unspecified) } - fn span_close(&mut self, _group: &Self::Group) -> Self::Span { - // FIXME handle span - tt::TokenId::unspecified() + fn span_close(&mut self, group: &Self::Group) -> Self::Span { + // FIXME we only store one `TokenId` for the delimiters + group.delimiter.map(|it| it.id).unwrap_or_else(tt::TokenId::unspecified) } } @@ -453,13 +454,11 @@ impl server::Punct for Rustc { fn spacing(&mut self, punct: Self::Punct) -> bridge::Spacing { spacing_to_external(punct.spacing) } - fn span(&mut self, _punct: Self::Punct) -> Self::Span { - // FIXME handle span - tt::TokenId::unspecified() + fn span(&mut self, punct: Self::Punct) -> Self::Span { + punct.id } - fn with_span(&mut self, punct: Self::Punct, _span: Self::Span) -> Self::Punct { - // FIXME handle span - punct + fn with_span(&mut self, punct: Self::Punct, span: Self::Span) -> Self::Punct { + tt::Punct { id: span, ..punct } } } @@ -473,13 +472,13 @@ impl server::Ident for Rustc { ) } - fn span(&mut self, _ident: Self::Ident) -> Self::Span { - // FIXME handle span - tt::TokenId::unspecified() + fn span(&mut self, ident: Self::Ident) -> Self::Span { + self.ident_interner.get(ident.0).0.id } - fn with_span(&mut self, ident: Self::Ident, _span: Self::Span) -> Self::Ident { - // FIXME handle span - ident + fn with_span(&mut self, ident: Self::Ident, span: Self::Span) -> Self::Ident { + let data = self.ident_interner.get(ident.0); + let new = IdentData(tt::Ident { id: span, ..data.0.clone() }); + IdentId(self.ident_interner.intern(&new)) } } diff --git a/crates/proc_macro_srv/src/abis/abi_1_55/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_55/rustc_server.rs index 498fa7ea2dc..f8626c5f62f 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_55/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_55/rustc_server.rs @@ -423,19 +423,20 @@ impl server::Group for Rustc { group.delimiter.map(|it| it.id).unwrap_or_else(tt::TokenId::unspecified) } - fn set_span(&mut self, _group: &mut Self::Group, _span: Self::Span) { - // FIXME handle span + fn set_span(&mut self, group: &mut Self::Group, span: Self::Span) { + if let Some(delim) = &mut group.delimiter { + delim.id = span; + } } - fn span_open(&mut self, _group: &Self::Group) -> Self::Span { - // FIXME handle span - // MySpan(self.span_interner.intern(&MySpanData(group.span_open()))) - tt::TokenId::unspecified() + fn span_open(&mut self, group: &Self::Group) -> Self::Span { + // FIXME we only store one `TokenId` for the delimiters + group.delimiter.map(|it| it.id).unwrap_or_else(tt::TokenId::unspecified) } - fn span_close(&mut self, _group: &Self::Group) -> Self::Span { - // FIXME handle span - tt::TokenId::unspecified() + fn span_close(&mut self, group: &Self::Group) -> Self::Span { + // FIXME we only store one `TokenId` for the delimiters + group.delimiter.map(|it| it.id).unwrap_or_else(tt::TokenId::unspecified) } } @@ -453,13 +454,11 @@ impl server::Punct for Rustc { fn spacing(&mut self, punct: Self::Punct) -> bridge::Spacing { spacing_to_external(punct.spacing) } - fn span(&mut self, _punct: Self::Punct) -> Self::Span { - // FIXME handle span - tt::TokenId::unspecified() + fn span(&mut self, punct: Self::Punct) -> Self::Span { + punct.id } - fn with_span(&mut self, punct: Self::Punct, _span: Self::Span) -> Self::Punct { - // FIXME handle span - punct + fn with_span(&mut self, punct: Self::Punct, span: Self::Span) -> Self::Punct { + tt::Punct { id: span, ..punct } } } @@ -473,13 +472,13 @@ impl server::Ident for Rustc { ) } - fn span(&mut self, _ident: Self::Ident) -> Self::Span { - // FIXME handle span - tt::TokenId::unspecified() + fn span(&mut self, ident: Self::Ident) -> Self::Span { + self.ident_interner.get(ident.0).0.id } - fn with_span(&mut self, ident: Self::Ident, _span: Self::Span) -> Self::Ident { - // FIXME handle span - ident + fn with_span(&mut self, ident: Self::Ident, span: Self::Span) -> Self::Ident { + let data = self.ident_interner.get(ident.0); + let new = IdentData(tt::Ident { id: span, ..data.0.clone() }); + IdentId(self.ident_interner.intern(&new)) } } |
