11802: fix: add stubs to make proc macros work that use the `SourceFile` API r=jonas-schievink a=jonas-schievink

Helps with the rocket 0.4 macros, at least on some Rust versions.

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11264

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
This commit is contained in:
bors[bot] 2022-03-23 20:58:45 +00:00 committed by GitHub
commit 15fdb95183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,9 +97,13 @@ impl Extend<TokenStream> for TokenStream {
} }
} }
#[derive(Clone)]
pub struct SourceFile {
// FIXME stub
}
type Level = super::proc_macro::Level; type Level = super::proc_macro::Level;
type LineColumn = super::proc_macro::LineColumn; type LineColumn = super::proc_macro::LineColumn;
type SourceFile = super::proc_macro::SourceFile;
/// A structure representing a diagnostic message and associated children /// A structure representing a diagnostic message and associated children
/// messages. /// messages.
@ -594,16 +598,15 @@ impl server::Literal for Rustc {
} }
impl server::SourceFile for Rustc { impl server::SourceFile for Rustc {
fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool { // FIXME these are all stubs
file1.eq(file2) fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool {
true
} }
fn path(&mut self, file: &Self::SourceFile) -> String { fn path(&mut self, _file: &Self::SourceFile) -> String {
String::from( String::new()
file.path().to_str().expect("non-UTF8 file path in `proc_macro::SourceFile::path`"),
)
} }
fn is_real(&mut self, file: &Self::SourceFile) -> bool { fn is_real(&mut self, _file: &Self::SourceFile) -> bool {
file.is_real() true
} }
} }
@ -646,8 +649,7 @@ impl server::Span for Rustc {
tt::TokenId::unspecified() tt::TokenId::unspecified()
} }
fn source_file(&mut self, _span: Self::Span) -> Self::SourceFile { fn source_file(&mut self, _span: Self::Span) -> Self::SourceFile {
// let MySpanData(span) = self.span_interner.get(span.0); SourceFile {}
unimplemented!()
} }
fn save_span(&mut self, _span: Self::Span) -> usize { fn save_span(&mut self, _span: Self::Span) -> usize {
// FIXME stub // FIXME stub