Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillot
compiler: apply clippy::clone_on_ref_ptr for CI Apply lint https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_ref_ptr for compiler, also see https://github.com/rust-lang/rust/pull/131225#discussion_r1790109443. Some Arc's can be misplaced with Lrc's, sorry. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29
This commit is contained in:
commit
5d0f52efa4
34 changed files with 100 additions and 92 deletions
|
@ -32,7 +32,7 @@ impl DebuggerVisualizerFile {
|
|||
|
||||
pub fn path_erased(&self) -> Self {
|
||||
DebuggerVisualizerFile {
|
||||
src: self.src.clone(),
|
||||
src: Lrc::clone(&self.src),
|
||||
visualizer_type: self.visualizer_type,
|
||||
path: None,
|
||||
}
|
||||
|
|
|
@ -472,32 +472,27 @@ impl<'a, 'tcx> CacheDecoder<'a, 'tcx> {
|
|||
let CacheDecoder { tcx, file_index_to_file, file_index_to_stable_id, source_map, .. } =
|
||||
*self;
|
||||
|
||||
file_index_to_file
|
||||
.borrow_mut()
|
||||
.entry(index)
|
||||
.or_insert_with(|| {
|
||||
let source_file_id = &file_index_to_stable_id[&index];
|
||||
let source_file_cnum =
|
||||
tcx.stable_crate_id_to_crate_num(source_file_id.stable_crate_id);
|
||||
Lrc::clone(file_index_to_file.borrow_mut().entry(index).or_insert_with(|| {
|
||||
let source_file_id = &file_index_to_stable_id[&index];
|
||||
let source_file_cnum = tcx.stable_crate_id_to_crate_num(source_file_id.stable_crate_id);
|
||||
|
||||
// If this `SourceFile` is from a foreign crate, then make sure
|
||||
// that we've imported all of the source files from that crate.
|
||||
// This has usually already been done during macro invocation.
|
||||
// However, when encoding query results like `TypeckResults`,
|
||||
// we might encode an `AdtDef` for a foreign type (because it
|
||||
// was referenced in the body of the function). There is no guarantee
|
||||
// that we will load the source files from that crate during macro
|
||||
// expansion, so we use `import_source_files` to ensure that the foreign
|
||||
// source files are actually imported before we call `source_file_by_stable_id`.
|
||||
if source_file_cnum != LOCAL_CRATE {
|
||||
self.tcx.import_source_files(source_file_cnum);
|
||||
}
|
||||
// If this `SourceFile` is from a foreign crate, then make sure
|
||||
// that we've imported all of the source files from that crate.
|
||||
// This has usually already been done during macro invocation.
|
||||
// However, when encoding query results like `TypeckResults`,
|
||||
// we might encode an `AdtDef` for a foreign type (because it
|
||||
// was referenced in the body of the function). There is no guarantee
|
||||
// that we will load the source files from that crate during macro
|
||||
// expansion, so we use `import_source_files` to ensure that the foreign
|
||||
// source files are actually imported before we call `source_file_by_stable_id`.
|
||||
if source_file_cnum != LOCAL_CRATE {
|
||||
self.tcx.import_source_files(source_file_cnum);
|
||||
}
|
||||
|
||||
source_map
|
||||
.source_file_by_stable_id(source_file_id.stable_source_file_id)
|
||||
.expect("failed to lookup `SourceFile` in new context")
|
||||
})
|
||||
.clone()
|
||||
source_map
|
||||
.source_file_by_stable_id(source_file_id.stable_source_file_id)
|
||||
.expect("failed to lookup `SourceFile` in new context")
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue