Skip to content

Commit 6788ce7

Browse files
committed
Remove proc_macro::SourceFile::is_real().
1 parent 81d8c74 commit 6788ce7

File tree

5 files changed

+3
-37
lines changed

5 files changed

+3
-37
lines changed

Diff for: compiler/rustc_expand/src/proc_macro_server.rs

-4
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,6 @@ impl server::SourceFile for Rustc<'_, '_> {
689689
_ => file.name.prefer_local().to_string(),
690690
}
691691
}
692-
693-
fn is_real(&mut self, file: &Self::SourceFile) -> bool {
694-
file.is_real_file()
695-
}
696692
}
697693

698694
impl server::Span for Rustc<'_, '_> {

Diff for: library/proc_macro/src/bridge/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ macro_rules! with_api {
8686
fn clone($self: &$S::SourceFile) -> $S::SourceFile;
8787
fn eq($self: &$S::SourceFile, other: &$S::SourceFile) -> bool;
8888
fn path($self: &$S::SourceFile) -> String;
89-
fn is_real($self: &$S::SourceFile) -> bool;
9089
},
9190
Span {
9291
fn debug($self: $S::Span) -> String;

Diff for: library/proc_macro/src/lib.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -623,36 +623,19 @@ impl SourceFile {
623623
/// Gets the path to this source file.
624624
///
625625
/// ### Note
626-
/// If the code span associated with this `SourceFile` was generated by an external macro, this
627-
/// macro, this might not be an actual path on the filesystem. Use [`is_real`] to check.
628626
///
629-
/// Also note that even if `is_real` returns `true`, if `--remap-path-prefix` was passed on
627+
/// If `--remap-path-prefix` was passed on
630628
/// the command line, the path as given might not actually be valid.
631-
///
632-
/// [`is_real`]: Self::is_real
633629
#[unstable(feature = "proc_macro_span", issue = "54725")]
634630
pub fn path(&self) -> PathBuf {
635631
PathBuf::from(self.0.path())
636632
}
637-
638-
/// Returns `true` if this source file is a real source file, and not generated by an external
639-
/// macro's expansion.
640-
#[unstable(feature = "proc_macro_span", issue = "54725")]
641-
pub fn is_real(&self) -> bool {
642-
// This is a hack until intercrate spans are implemented and we can have real source files
643-
// for spans generated in external macros.
644-
// https://github.com/rust-lang/rust/pull/43604#issuecomment-333334368
645-
self.0.is_real()
646-
}
647633
}
648634

649635
#[unstable(feature = "proc_macro_span", issue = "54725")]
650636
impl fmt::Debug for SourceFile {
651637
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
652-
f.debug_struct("SourceFile")
653-
.field("path", &self.path())
654-
.field("is_real", &self.is_real())
655-
.finish()
638+
f.debug_struct("SourceFile").field("path", &self.path()).finish()
656639
}
657640
}
658641

Diff for: tests/ui/proc-macro/auxiliary/span-api-tests.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@ pub fn reemit(input: TokenStream) -> TokenStream {
1010
input.to_string().parse().unwrap()
1111
}
1212

13-
#[proc_macro]
14-
pub fn assert_fake_source_file(input: TokenStream) -> TokenStream {
15-
for tk in input {
16-
let source_file = tk.span().source_file();
17-
assert!(!source_file.is_real(), "Source file is real: {:?}", source_file);
18-
}
19-
20-
"".parse().unwrap()
21-
}
22-
2313
#[proc_macro]
2414
pub fn assert_source_file(input: TokenStream) -> TokenStream {
2515
for tk in input {
2616
let source_file = tk.span().source_file();
27-
assert!(source_file.is_real(), "Source file is not real: {:?}", source_file);
17+
assert!(!source_file.as_os_str().is_empty(), "No source file for span: {:?}", tk.span());
2818
}
2919

3020
"".parse().unwrap()

Diff for: tests/ui/proc-macro/span-api-tests.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ extern crate span_test_macros;
88

99
extern crate span_api_tests;
1010

11-
// FIXME(69775): Investigate `assert_fake_source_file`.
12-
1311
use span_api_tests::{reemit, assert_source_file, macro_stringify};
1412

1513
macro_rules! say_hello {

0 commit comments

Comments
 (0)