Skip to content

Commit 910be1b

Browse files
committed
Auto merge of rust-lang#113573 - lcnr:typeck-results, r=compiler-errors
remove unnecessary `Rc` the typeck results are already in a `RefCell`, so we don't need to wrap its fields in an `Rc`
2 parents 6732922 + e386d41 commit 910be1b

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

compiler/rustc_hir_typeck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn has_typeck_results(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
141141
}
142142

143143
fn used_trait_imports(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &UnordSet<LocalDefId> {
144-
&*tcx.typeck(def_id).used_trait_imports
144+
&tcx.typeck(def_id).used_trait_imports
145145
}
146146

147147
fn typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> {

compiler/rustc_hir_typeck/src/method/mod.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub use self::MethodError::*;
1212

1313
use crate::errors::OpMethodGenericParams;
1414
use crate::FnCtxt;
15-
use rustc_data_structures::sync::Lrc;
1615
use rustc_errors::{Applicability, Diagnostic, SubdiagnosticMessage};
1716
use rustc_hir as hir;
1817
use rustc_hir::def::{CtorOf, DefKind, Namespace};
@@ -190,11 +189,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
190189

191190
self.lint_dot_call_from_2018(self_ty, segment, span, call_expr, self_expr, &pick, args);
192191

193-
for import_id in &pick.import_ids {
192+
for &import_id in &pick.import_ids {
194193
debug!("used_trait_import: {:?}", import_id);
195-
Lrc::get_mut(&mut self.typeck_results.borrow_mut().used_trait_imports)
196-
.unwrap()
197-
.insert(*import_id);
194+
self.typeck_results.borrow_mut().used_trait_imports.insert(import_id);
198195
}
199196

200197
self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span, None);
@@ -567,10 +564,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
567564
debug!(?pick);
568565
{
569566
let mut typeck_results = self.typeck_results.borrow_mut();
570-
let used_trait_imports = Lrc::get_mut(&mut typeck_results.used_trait_imports).unwrap();
571567
for import_id in pick.import_ids {
572568
debug!(used_trait_import=?import_id);
573-
used_trait_imports.insert(import_id);
569+
typeck_results.used_trait_imports.insert(import_id);
574570
}
575571
}
576572

compiler/rustc_middle/src/ty/typeck_results.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ use crate::{
77
GenericArgKind, InternalSubsts, SubstsRef, Ty, UserSubsts,
88
},
99
};
10-
use rustc_data_structures::{
11-
fx::{FxHashMap, FxIndexMap},
12-
sync::Lrc,
13-
unord::{UnordItems, UnordSet},
14-
};
10+
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
11+
use rustc_data_structures::unord::{UnordItems, UnordSet};
1512
use rustc_errors::ErrorGuaranteed;
1613
use rustc_hir as hir;
1714
use rustc_hir::{
@@ -145,7 +142,7 @@ pub struct TypeckResults<'tcx> {
145142
/// This is used for warning unused imports. During type
146143
/// checking, this `Lrc` should not be cloned: it must have a ref-count
147144
/// of 1 so that we can insert things into the set mutably.
148-
pub used_trait_imports: Lrc<UnordSet<LocalDefId>>,
145+
pub used_trait_imports: UnordSet<LocalDefId>,
149146

150147
/// If any errors occurred while type-checking this body,
151148
/// this field will be set to `Some(ErrorGuaranteed)`.
@@ -273,7 +270,7 @@ impl<'tcx> TypeckResults<'tcx> {
273270
liberated_fn_sigs: Default::default(),
274271
fru_field_types: Default::default(),
275272
coercion_casts: Default::default(),
276-
used_trait_imports: Lrc::new(Default::default()),
273+
used_trait_imports: Default::default(),
277274
tainted_by_errors: None,
278275
concrete_opaque_types: Default::default(),
279276
closure_min_captures: Default::default(),

0 commit comments

Comments
 (0)