diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2025-04-11 13:47:52 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2025-04-11 14:02:06 +0200 |
| commit | 6788ce76c9f66b836a3b6a72d8b6df32627edecc (patch) | |
| tree | 59e3d8545883fb579414a038c1393b775377ae71 | |
| parent | 81d8c747fbdb17775dc4e107ad7e430e61a4e751 (diff) | |
| download | rust-6788ce76c9f66b836a3b6a72d8b6df32627edecc.tar.gz rust-6788ce76c9f66b836a3b6a72d8b6df32627edecc.zip | |
Remove proc_macro::SourceFile::is_real().
| -rw-r--r-- | compiler/rustc_expand/src/proc_macro_server.rs | 4 | ||||
| -rw-r--r-- | library/proc_macro/src/bridge/mod.rs | 1 | ||||
| -rw-r--r-- | library/proc_macro/src/lib.rs | 21 | ||||
| -rw-r--r-- | tests/ui/proc-macro/auxiliary/span-api-tests.rs | 12 | ||||
| -rw-r--r-- | tests/ui/proc-macro/span-api-tests.rs | 2 |
5 files changed, 3 insertions, 37 deletions
diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index ee6306e3961..cd4ea8edd6f 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -689,10 +689,6 @@ impl server::SourceFile for Rustc<'_, '_> { _ => file.name.prefer_local().to_string(), } } - - fn is_real(&mut self, file: &Self::SourceFile) -> bool { - file.is_real_file() - } } impl server::Span for Rustc<'_, '_> { diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs index 1b5c221425e..d76e6652131 100644 --- a/library/proc_macro/src/bridge/mod.rs +++ b/library/proc_macro/src/bridge/mod.rs @@ -86,7 +86,6 @@ macro_rules! with_api { fn clone($self: &$S::SourceFile) -> $S::SourceFile; fn eq($self: &$S::SourceFile, other: &$S::SourceFile) -> bool; fn path($self: &$S::SourceFile) -> String; - fn is_real($self: &$S::SourceFile) -> bool; }, Span { fn debug($self: $S::Span) -> String; diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index f1cf0c5a2db..17beef2d470 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -623,36 +623,19 @@ impl SourceFile { /// Gets the path to this source file. /// /// ### Note - /// If the code span associated with this `SourceFile` was generated by an external macro, this - /// macro, this might not be an actual path on the filesystem. Use [`is_real`] to check. /// - /// Also note that even if `is_real` returns `true`, if `--remap-path-prefix` was passed on + /// If `--remap-path-prefix` was passed on /// the command line, the path as given might not actually be valid. - /// - /// [`is_real`]: Self::is_real #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn path(&self) -> PathBuf { PathBuf::from(self.0.path()) } - - /// Returns `true` if this source file is a real source file, and not generated by an external - /// macro's expansion. - #[unstable(feature = "proc_macro_span", issue = "54725")] - pub fn is_real(&self) -> bool { - // This is a hack until intercrate spans are implemented and we can have real source files - // for spans generated in external macros. - // https://github.com/rust-lang/rust/pull/43604#issuecomment-333334368 - self.0.is_real() - } } #[unstable(feature = "proc_macro_span", issue = "54725")] impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("SourceFile") - .field("path", &self.path()) - .field("is_real", &self.is_real()) - .finish() + f.debug_struct("SourceFile").field("path", &self.path()).finish() } } diff --git a/tests/ui/proc-macro/auxiliary/span-api-tests.rs b/tests/ui/proc-macro/auxiliary/span-api-tests.rs index 99db66ed6a9..8853d793943 100644 --- a/tests/ui/proc-macro/auxiliary/span-api-tests.rs +++ b/tests/ui/proc-macro/auxiliary/span-api-tests.rs @@ -11,20 +11,10 @@ pub fn reemit(input: TokenStream) -> TokenStream { } #[proc_macro] -pub fn assert_fake_source_file(input: TokenStream) -> TokenStream { - for tk in input { - let source_file = tk.span().source_file(); - assert!(!source_file.is_real(), "Source file is real: {:?}", source_file); - } - - "".parse().unwrap() -} - -#[proc_macro] pub fn assert_source_file(input: TokenStream) -> TokenStream { for tk in input { let source_file = tk.span().source_file(); - assert!(source_file.is_real(), "Source file is not real: {:?}", source_file); + assert!(!source_file.as_os_str().is_empty(), "No source file for span: {:?}", tk.span()); } "".parse().unwrap() diff --git a/tests/ui/proc-macro/span-api-tests.rs b/tests/ui/proc-macro/span-api-tests.rs index ac42a7ea611..dd8589735b2 100644 --- a/tests/ui/proc-macro/span-api-tests.rs +++ b/tests/ui/proc-macro/span-api-tests.rs @@ -8,8 +8,6 @@ extern crate span_test_macros; extern crate span_api_tests; -// FIXME(69775): Investigate `assert_fake_source_file`. - use span_api_tests::{reemit, assert_source_file, macro_stringify}; macro_rules! say_hello { |
