Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with rustc_span changes #4829

Merged
merged 4 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-05-04"
channel = "nightly-2021-05-13"
components = ["rustc-dev"]
2 changes: 1 addition & 1 deletion src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum FileName {
impl From<rustc_span::FileName> for FileName {
fn from(name: rustc_span::FileName) -> FileName {
match name {
rustc_span::FileName::Real(p) => FileName::Real(p.into_local_path()),
rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(p)) => FileName::Real(p),
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
_ => unreachable!(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
fn from(filename: &FileName) -> rustc_span::FileName {
match filename {
FileName::Real(path) => {
rustc_span::FileName::Real(rustc_span::RealFileName::Named(path.to_owned()))
rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(path.to_owned()))
}
FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()),
}
Expand Down
19 changes: 10 additions & 9 deletions src/syntux/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
}
if let Some(primary_span) = &db.span.primary_span() {
let file_name = self.source_map.span_to_filename(*primary_span);
if let rustc_span::FileName::Real(rustc_span::RealFileName::Named(ref path)) = file_name
if let rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(ref path)) =
file_name
{
if self
.ignore_path_set
Expand Down Expand Up @@ -157,7 +158,7 @@ impl ParseSess {
self.parse_sess
.source_map()
.get_source_file(&rustc_span::FileName::Real(
rustc_span::RealFileName::Named(path.to_path_buf()),
rustc_span::RealFileName::LocalPath(path.to_path_buf()),
))
.is_some()
}
Expand Down Expand Up @@ -191,7 +192,7 @@ impl ParseSess {
}

pub(crate) fn span_to_debug_info(&self, span: Span) -> String {
self.parse_sess.source_map().span_to_string(span)
self.parse_sess.source_map().span_to_diagnostic_string(span)
}

pub(crate) fn inner(&self) -> &RawParseSess {
Expand Down Expand Up @@ -347,7 +348,7 @@ mod tests {
let source =
String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
SourceMapFileName::Real(RealFileName::LocalPath(PathBuf::from("foo.rs"))),
source,
);
let mut emitter = build_emitter(
Expand All @@ -374,7 +375,7 @@ mod tests {
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let source = String::from(r#"pub fn bar() { 1x; }"#);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
SourceMapFileName::Real(RealFileName::LocalPath(PathBuf::from("foo.rs"))),
source,
);
let mut emitter = build_emitter(
Expand All @@ -400,7 +401,7 @@ mod tests {
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let source = String::from(r#"pub fn bar() { 1x; }"#);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
SourceMapFileName::Real(RealFileName::LocalPath(PathBuf::from("foo.rs"))),
source,
);
let mut emitter = build_emitter(
Expand Down Expand Up @@ -430,15 +431,15 @@ mod tests {
let fatal_source =
String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("bar.rs"))),
SourceMapFileName::Real(RealFileName::LocalPath(PathBuf::from("bar.rs"))),
bar_source,
);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
SourceMapFileName::Real(RealFileName::LocalPath(PathBuf::from("foo.rs"))),
foo_source,
);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("fatal.rs"))),
SourceMapFileName::Real(RealFileName::LocalPath(PathBuf::from("fatal.rs"))),
fatal_source,
);
let mut emitter = build_emitter(
Expand Down