Skip to content

Commit c85ed04

Browse files
alexcrichtonehuss
authored andcommitted
Remove lifetime from Unit
1 parent 45d4957 commit c85ed04

File tree

16 files changed

+307
-378
lines changed

16 files changed

+307
-378
lines changed

src/cargo/core/compiler/build_context/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ pub struct BuildContext<'a, 'cfg> {
2626
pub profiles: Profiles,
2727
pub build_config: &'a BuildConfig,
2828
/// Extra compiler args for either `rustc` or `rustdoc`.
29-
pub extra_compiler_args: HashMap<Unit<'a>, Vec<String>>,
29+
pub extra_compiler_args: HashMap<Unit, Vec<String>>,
3030
/// Package downloader.
3131
///
3232
/// This holds ownership of the `Package` objects.
3333
pub packages: PackageSet<'cfg>,
3434
/// Information about rustc and the target platform.
3535
pub target_data: RustcTargetData,
3636
/// The root units of `unit_graph` (units requested on the command-line).
37-
pub roots: Vec<Unit<'a>>,
37+
pub roots: Vec<Unit>,
3838
/// The dependency graph of units to compile.
39-
pub unit_graph: UnitGraph<'a>,
39+
pub unit_graph: UnitGraph,
4040
}
4141

4242
impl<'a, 'cfg> BuildContext<'a, 'cfg> {
@@ -45,10 +45,10 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
4545
packages: PackageSet<'cfg>,
4646
build_config: &'a BuildConfig,
4747
profiles: Profiles,
48-
extra_compiler_args: HashMap<Unit<'a>, Vec<String>>,
48+
extra_compiler_args: HashMap<Unit, Vec<String>>,
4949
target_data: RustcTargetData,
50-
roots: Vec<Unit<'a>>,
51-
unit_graph: UnitGraph<'a>,
50+
roots: Vec<Unit>,
51+
unit_graph: UnitGraph,
5252
) -> CargoResult<BuildContext<'a, 'cfg>> {
5353
Ok(BuildContext {
5454
ws,
@@ -91,19 +91,19 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
9191
self.build_config.jobs
9292
}
9393

94-
pub fn rustflags_args(&self, unit: &Unit<'_>) -> &[String] {
94+
pub fn rustflags_args(&self, unit: &Unit) -> &[String] {
9595
&self.target_data.info(unit.kind).rustflags
9696
}
9797

98-
pub fn rustdocflags_args(&self, unit: &Unit<'_>) -> &[String] {
98+
pub fn rustdocflags_args(&self, unit: &Unit) -> &[String] {
9999
&self.target_data.info(unit.kind).rustdocflags
100100
}
101101

102102
pub fn show_warnings(&self, pkg: PackageId) -> bool {
103103
pkg.source_id().is_path() || self.config.extra_verbose()
104104
}
105105

106-
pub fn extra_args_for(&self, unit: &Unit<'a>) -> Option<&Vec<String>> {
106+
pub fn extra_args_for(&self, unit: &Unit) -> Option<&Vec<String>> {
107107
self.extra_compiler_args.get(unit)
108108
}
109109
}

src/cargo/core/compiler/build_plan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct SerializedBuildPlan {
4545
}
4646

4747
impl Invocation {
48-
pub fn new(unit: &Unit<'_>, deps: Vec<usize>) -> Invocation {
48+
pub fn new(unit: &Unit, deps: Vec<usize>) -> Invocation {
4949
let id = unit.pkg.package_id();
5050
Invocation {
5151
package_name: id.name().to_string(),
@@ -109,7 +109,7 @@ impl BuildPlan {
109109
}
110110
}
111111

112-
pub fn add<'a>(&mut self, cx: &Context<'a, '_>, unit: &Unit<'a>) -> CargoResult<()> {
112+
pub fn add(&mut self, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> {
113113
let id = self.plan.invocations.len();
114114
self.invocation_map.insert(unit.buildkey(), id);
115115
let deps = cx

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ pub struct CompilationFiles<'a, 'cfg> {
8282
export_dir: Option<PathBuf>,
8383
/// The root targets requested by the user on the command line (does not
8484
/// include dependencies).
85-
roots: Vec<Unit<'a>>,
85+
roots: Vec<Unit>,
8686
ws: &'a Workspace<'cfg>,
8787
/// Metadata hash to use for each unit.
8888
///
8989
/// `None` if the unit should not use a metadata data hash (like rustdoc,
9090
/// or some dylibs).
91-
metas: HashMap<Unit<'a>, Option<Metadata>>,
91+
metas: HashMap<Unit, Option<Metadata>>,
9292
/// For each Unit, a list all files produced.
93-
outputs: HashMap<Unit<'a>, LazyCell<Arc<Vec<OutputFile>>>>,
93+
outputs: HashMap<Unit, LazyCell<Arc<Vec<OutputFile>>>>,
9494
}
9595

9696
/// Info about a single file emitted by the compiler.
@@ -158,20 +158,20 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
158158
///
159159
/// Returns `None` if the unit should not use a metadata data hash (like
160160
/// rustdoc, or some dylibs).
161-
pub fn metadata(&self, unit: &Unit<'a>) -> Option<Metadata> {
161+
pub fn metadata(&self, unit: &Unit) -> Option<Metadata> {
162162
self.metas[unit]
163163
}
164164

165165
/// Gets the short hash based only on the `PackageId`.
166166
/// Used for the metadata when `metadata` returns `None`.
167-
pub fn target_short_hash(&self, unit: &Unit<'_>) -> String {
167+
pub fn target_short_hash(&self, unit: &Unit) -> String {
168168
let hashable = unit.pkg.package_id().stable_hash(self.ws.root());
169169
util::short_hash(&hashable)
170170
}
171171

172172
/// Returns the appropriate output directory for the specified package and
173173
/// target.
174-
pub fn out_dir(&self, unit: &Unit<'a>) -> PathBuf {
174+
pub fn out_dir(&self, unit: &Unit) -> PathBuf {
175175
if unit.mode.is_doc() {
176176
self.layout(unit.kind).doc().to_path_buf()
177177
} else if unit.mode.is_doc_test() {
@@ -191,7 +191,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
191191
}
192192

193193
/// Directory name to use for a package in the form `NAME-HASH`.
194-
pub fn pkg_dir(&self, unit: &Unit<'a>) -> String {
194+
pub fn pkg_dir(&self, unit: &Unit) -> String {
195195
let name = unit.pkg.package_id().name();
196196
match self.metas[unit] {
197197
Some(ref meta) => format!("{}-{}", name, meta),
@@ -211,24 +211,24 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
211211

212212
/// Returns the directories where Rust crate dependencies are found for the
213213
/// specified unit.
214-
pub fn deps_dir(&self, unit: &Unit<'_>) -> &Path {
214+
pub fn deps_dir(&self, unit: &Unit) -> &Path {
215215
self.layout(unit.kind).deps()
216216
}
217217

218218
/// Directory where the fingerprint for the given unit should go.
219-
pub fn fingerprint_dir(&self, unit: &Unit<'a>) -> PathBuf {
219+
pub fn fingerprint_dir(&self, unit: &Unit) -> PathBuf {
220220
let dir = self.pkg_dir(unit);
221221
self.layout(unit.kind).fingerprint().join(dir)
222222
}
223223

224224
/// Path where compiler output is cached.
225-
pub fn message_cache_path(&self, unit: &Unit<'a>) -> PathBuf {
225+
pub fn message_cache_path(&self, unit: &Unit) -> PathBuf {
226226
self.fingerprint_dir(unit).join("output")
227227
}
228228

229229
/// Returns the directory where a compiled build script is stored.
230230
/// `/path/to/target/{debug,release}/build/PKG-HASH`
231-
pub fn build_script_dir(&self, unit: &Unit<'a>) -> PathBuf {
231+
pub fn build_script_dir(&self, unit: &Unit) -> PathBuf {
232232
assert!(unit.target.is_custom_build());
233233
assert!(!unit.mode.is_run_custom_build());
234234
assert!(self.metas.contains_key(unit));
@@ -239,7 +239,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
239239
/// Returns the directory where information about running a build script
240240
/// is stored.
241241
/// `/path/to/target/{debug,release}/build/PKG-HASH`
242-
pub fn build_script_run_dir(&self, unit: &Unit<'a>) -> PathBuf {
242+
pub fn build_script_run_dir(&self, unit: &Unit) -> PathBuf {
243243
assert!(unit.target.is_custom_build());
244244
assert!(unit.mode.is_run_custom_build());
245245
let dir = self.pkg_dir(unit);
@@ -248,12 +248,12 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
248248

249249
/// Returns the "OUT_DIR" directory for running a build script.
250250
/// `/path/to/target/{debug,release}/build/PKG-HASH/out`
251-
pub fn build_script_out_dir(&self, unit: &Unit<'a>) -> PathBuf {
251+
pub fn build_script_out_dir(&self, unit: &Unit) -> PathBuf {
252252
self.build_script_run_dir(unit).join("out")
253253
}
254254

255255
/// Returns the file stem for a given target/profile combo (with metadata).
256-
pub fn file_stem(&self, unit: &Unit<'a>) -> String {
256+
pub fn file_stem(&self, unit: &Unit) -> String {
257257
match self.metas[unit] {
258258
Some(ref metadata) => format!("{}-{}", unit.target.crate_name(), metadata),
259259
None => self.bin_stem(unit),
@@ -292,7 +292,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
292292
/// Returns the filenames that the given unit will generate.
293293
pub(super) fn outputs(
294294
&self,
295-
unit: &Unit<'a>,
295+
unit: &Unit,
296296
bcx: &BuildContext<'a, 'cfg>,
297297
) -> CargoResult<Arc<Vec<OutputFile>>> {
298298
self.outputs[unit]
@@ -301,7 +301,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
301301
}
302302

303303
/// Returns the bin filename for a given target, without extension and metadata.
304-
fn bin_stem(&self, unit: &Unit<'_>) -> String {
304+
fn bin_stem(&self, unit: &Unit) -> String {
305305
if unit.target.allows_dashes() {
306306
unit.target.name().to_string()
307307
} else {
@@ -322,7 +322,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
322322
///
323323
/// Returns an `Option` because in some cases we don't want to link
324324
/// (eg a dependent lib).
325-
fn link_stem(&self, unit: &Unit<'a>) -> Option<(PathBuf, String)> {
325+
fn link_stem(&self, unit: &Unit) -> Option<(PathBuf, String)> {
326326
let out_dir = self.out_dir(unit);
327327
let bin_stem = self.bin_stem(unit); // Stem without metadata.
328328
let file_stem = self.file_stem(unit); // Stem with metadata.
@@ -355,7 +355,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
355355

356356
fn calc_outputs(
357357
&self,
358-
unit: &Unit<'a>,
358+
unit: &Unit,
359359
bcx: &BuildContext<'a, 'cfg>,
360360
) -> CargoResult<Arc<Vec<OutputFile>>> {
361361
let ret = match unit.mode {
@@ -405,7 +405,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
405405

406406
fn calc_outputs_rustc(
407407
&self,
408-
unit: &Unit<'a>,
408+
unit: &Unit,
409409
bcx: &BuildContext<'a, 'cfg>,
410410
) -> CargoResult<Vec<OutputFile>> {
411411
let mut ret = Vec::new();
@@ -519,10 +519,10 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
519519
}
520520
}
521521

522-
fn metadata_of<'a, 'cfg>(
523-
unit: &Unit<'a>,
524-
cx: &Context<'a, 'cfg>,
525-
metas: &mut HashMap<Unit<'a>, Option<Metadata>>,
522+
fn metadata_of(
523+
unit: &Unit,
524+
cx: &Context<'_, '_>,
525+
metas: &mut HashMap<Unit, Option<Metadata>>,
526526
) -> Option<Metadata> {
527527
if !metas.contains_key(unit) {
528528
let meta = compute_metadata(unit, cx, metas);
@@ -534,10 +534,10 @@ fn metadata_of<'a, 'cfg>(
534534
metas[unit]
535535
}
536536

537-
fn compute_metadata<'a, 'cfg>(
538-
unit: &Unit<'a>,
539-
cx: &Context<'a, 'cfg>,
540-
metas: &mut HashMap<Unit<'a>, Option<Metadata>>,
537+
fn compute_metadata(
538+
unit: &Unit,
539+
cx: &Context<'_, '_>,
540+
metas: &mut HashMap<Unit, Option<Metadata>>,
541541
) -> Option<Metadata> {
542542
if unit.mode.is_doc_test() {
543543
// Doc tests do not have metadata.

0 commit comments

Comments
 (0)