Skip to content

Commit d7e8200

Browse files
Clean up Config::libdir_relative
1 parent a174d0e commit d7e8200

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/bootstrap/builder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ impl<'a> Builder<'a> {
541541
fn run(self, builder: &Builder) -> Interned<PathBuf> {
542542
let compiler = self.compiler;
543543
let config = &builder.build.config;
544-
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
545-
config.libdir_relative().unwrap()
544+
let lib = if compiler.stage >= 1 {
545+
config.libdir_relative()
546546
} else {
547547
Path::new("lib")
548548
};
@@ -736,7 +736,7 @@ impl<'a> Builder<'a> {
736736
.env("CFG_VERSION", self.rust_version())
737737
.env("CFG_PREFIX", &self.config.install.prefix);
738738

739-
let libdir_relative = self.config.libdir_relative().unwrap_or(Path::new("lib"));
739+
let libdir_relative = self.config.libdir_relative();
740740
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
741741

742742
// If we're not building a compiler with debugging information then remove

src/bootstrap/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,13 @@ impl Config {
572572
}
573573

574574
/// Try to find the relative path of `libdir`.
575-
pub fn libdir_relative(&self) -> Option<&Path> {
576-
let libdir = self.install.libdir.as_ref()?;
575+
pub fn libdir_relative(&self) -> &Path {
576+
let libdir = &self.install.libdir;
577577
if libdir.is_relative() {
578-
Some(libdir)
578+
libdir
579579
} else {
580580
// Try to make it relative to the prefix.
581-
libdir.strip_prefix(self.prefix.as_ref()?).ok()
581+
libdir.strip_prefix(&self.install.prefix).unwrap_or(Path::new("lib"))
582582
}
583583
}
584584

0 commit comments

Comments
 (0)