diff options
| author | Urgau <urgau@numericable.fr> | 2024-03-19 13:51:22 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2024-03-28 18:47:26 +0100 |
| commit | 106146fd958c3c0d3428cfc7be1f75c5bc81698f (patch) | |
| tree | 97123f1a2ac2f788d59981dfc5856e2c71de2f2a /compiler/rustc_session/src | |
| parent | 777c6b46cc804a3bae345f9133d2e0a900026bdc (diff) | |
Replace `RemapFileNameExt::for_codegen` with explicit calls
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index ec1b70fa41e..48b00c3f5a5 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -252,7 +252,8 @@ impl Session { pub fn local_crate_source_file(&self) -> Option<PathBuf> { let path = self.io.input.opt_path()?; - if self.should_prefer_remapped_for_codegen() { + // FIXME: The remap path scope should probably not be hardcoded. + if self.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO) { Some(self.opts.file_path_mapping().map_prefix(path).0.into_owned()) } else { Some(path.to_path_buf()) @@ -886,8 +887,8 @@ impl Session { self.opts.cg.link_dead_code.unwrap_or(false) } - pub fn should_prefer_remapped_for_codegen(&self) -> bool { - self.opts.unstable_opts.remap_path_scope.contains(RemapPathScopeComponents::DEBUGINFO) + pub fn should_prefer_remapped(&self, scope: RemapPathScopeComponents) -> bool { + self.opts.unstable_opts.remap_path_scope.contains(scope) } } @@ -1439,12 +1440,8 @@ pub trait RemapFileNameExt { /// Returns a possibly remapped filename based on the passed scope and remap cli options. /// - /// One and only one scope should be passed to this method. For anything related to - /// "codegen" see the [`RemapFileNameExt::for_codegen`] method. + /// One and only one scope should be passed to this method, it will panic otherwise. fn for_scope(&self, sess: &Session, scope: RemapPathScopeComponents) -> Self::Output<'_>; - - /// Return a possibly remapped filename, to be used in "codegen" related parts. - fn for_codegen(&self, sess: &Session) -> Self::Output<'_>; } impl RemapFileNameExt for rustc_span::FileName { @@ -1461,14 +1458,6 @@ impl RemapFileNameExt for rustc_span::FileName { self.prefer_local() } } - - fn for_codegen(&self, sess: &Session) -> Self::Output<'_> { - if sess.should_prefer_remapped_for_codegen() { - self.prefer_remapped_unconditionaly() - } else { - self.prefer_local() - } - } } impl RemapFileNameExt for rustc_span::RealFileName { @@ -1485,12 +1474,4 @@ impl RemapFileNameExt for rustc_span::RealFileName { self.local_path_if_available() } } - - fn for_codegen(&self, sess: &Session) -> Self::Output<'_> { - if sess.should_prefer_remapped_for_codegen() { - self.remapped_path_if_available() - } else { - self.local_path_if_available() - } - } } |
