diff options
| author | Yuki Okushi <huyuumi.dev+love@gmail.com> | 2023-01-14 12:04:37 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-14 12:04:37 +0900 |
| commit | 7d02116832e4eca70ef5fb08edb8d224f360e3a6 (patch) | |
| tree | 7600a611140282b03f76a5344b4104148f26c0a3 /compiler | |
| parent | a05d06f7c589525116dbc566bc5382d75ca03098 (diff) | |
| parent | 496edf97c5c150967217f886e14d355c4f9890d0 (diff) | |
| download | rust-7d02116832e4eca70ef5fb08edb8d224f360e3a6.tar.gz rust-7d02116832e4eca70ef5fb08edb8d224f360e3a6.zip | |
Rollup merge of #106816 - TimNN:rental-remap, r=oli-obj
Update `rental` hack to work with remapped paths.
This PR simply switches to an already-existing helper instead of hard-coding a specific enum variant. The new revision of the test fails without the other changes in this PR.
Context: I'm exploring running UI tests with remapped paths by default in #105924 and the rental test was one of the ones that failed.
This may also be useful in the context of https://github.com/rust-lang/rfcs/pull/3127 ("New rustc and Cargo options to allow path sanitisation by default").
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 00453f78287..ffde8480c02 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -31,11 +31,11 @@ use rustc_span::edition::Edition; use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId}; use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{BytePos, FileName, RealFileName, Span, DUMMY_SP}; +use rustc_span::{BytePos, FileName, Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; use std::iter; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::rc::Rc; pub(crate) use rustc_span::hygiene::MacroKind; @@ -1423,8 +1423,10 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool { if let [variant] = &*enum_def.variants { if variant.ident.name == sym::Input { let filename = sess.source_map().span_to_filename(item.ident.span); - if let FileName::Real(RealFileName::LocalPath(path)) = filename { - if let Some(c) = path + if let FileName::Real(real) = filename { + if let Some(c) = real + .local_path() + .unwrap_or(Path::new("")) .components() .flat_map(|c| c.as_os_str().to_str()) .find(|c| c.starts_with("rental") || c.starts_with("allsorts-rental")) |
