diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2021-12-15 08:32:21 +1100 | 
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2021-12-15 13:30:26 +1100 | 
| commit | 8cddcd39ba2189da859a5164804556190906ee2a (patch) | |
| tree | 80c9ffaa12dad22abec107679298920b1f07509a /compiler/rustc_monomorphize | |
| parent | 22f8bde876f2fa9c5c4e95be1bce29cc271f2b51 (diff) | |
| download | rust-8cddcd39ba2189da859a5164804556190906ee2a.tar.gz rust-8cddcd39ba2189da859a5164804556190906ee2a.zip  | |
Remove `SymbolStr`.
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
Diffstat (limited to 'compiler/rustc_monomorphize')
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning/merging.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning/mod.rs | 2 | 
2 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning/merging.rs b/compiler/rustc_monomorphize/src/partitioning/merging.rs index 229468b47ff..09cadc907b1 100644 --- a/compiler/rustc_monomorphize/src/partitioning/merging.rs +++ b/compiler/rustc_monomorphize/src/partitioning/merging.rs @@ -3,7 +3,7 @@ use std::cmp; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder}; -use rustc_span::symbol::{Symbol, SymbolStr}; +use rustc_span::symbol::Symbol; use super::PartitioningCx; use crate::partitioning::PreInliningPartitioning; @@ -24,11 +24,11 @@ pub fn merge_codegen_units<'tcx>( // smallest into each other) we're sure to start off with a deterministic // order (sorted by name). This'll mean that if two cgus have the same size // the stable sort below will keep everything nice and deterministic. - codegen_units.sort_by_cached_key(|cgu| cgu.name().as_str()); + codegen_units.sort_by(|a, b| a.name().as_str().partial_cmp(b.name().as_str()).unwrap()); // This map keeps track of what got merged into what. - let mut cgu_contents: FxHashMap<Symbol, Vec<SymbolStr>> = - codegen_units.iter().map(|cgu| (cgu.name(), vec![cgu.name().as_str()])).collect(); + let mut cgu_contents: FxHashMap<Symbol, Vec<Symbol>> = + codegen_units.iter().map(|cgu| (cgu.name(), vec![cgu.name()])).collect(); // Merge the two smallest codegen units until the target size is reached. while codegen_units.len() > cx.target_cgu_count { @@ -69,7 +69,7 @@ pub fn merge_codegen_units<'tcx>( // were actually modified by merging. .filter(|(_, cgu_contents)| cgu_contents.len() > 1) .map(|(current_cgu_name, cgu_contents)| { - let mut cgu_contents: Vec<&str> = cgu_contents.iter().map(|s| &s[..]).collect(); + let mut cgu_contents: Vec<&str> = cgu_contents.iter().map(|s| s.as_str()).collect(); // Sort the names, so things are deterministic and easy to // predict. diff --git a/compiler/rustc_monomorphize/src/partitioning/mod.rs b/compiler/rustc_monomorphize/src/partitioning/mod.rs index 658c9028ca1..cc60e7a1033 100644 --- a/compiler/rustc_monomorphize/src/partitioning/mod.rs +++ b/compiler/rustc_monomorphize/src/partitioning/mod.rs @@ -208,7 +208,7 @@ pub fn partition<'tcx>( internalization_candidates: _, } = post_inlining; - result.sort_by_cached_key(|cgu| cgu.name().as_str()); + result.sort_by(|a, b| a.name().as_str().partial_cmp(b.name().as_str()).unwrap()); result }  | 
