Skip to content

Commit d35d1ef

Browse files
committed
Remove unnecessary field
1 parent 5b49b8e commit d35d1ef

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ use super::InferResult;
2626
/// appear in the return type).
2727
#[derive(Clone, Debug)]
2828
pub struct OpaqueTypeDecl<'tcx> {
29-
/// The opaque type (`ty::Opaque`) for this declaration.
30-
pub opaque_type: Ty<'tcx>,
31-
3229
/// The hidden types that have been inferred for this opaque type.
3330
/// There can be multiple, but they are all `lub`ed together at the end
3431
/// to obtain the canonical hidden type.
@@ -82,11 +79,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
8279
return Ok(InferOk { value: (), obligations: vec![] });
8380
}
8481
if self.defining_use_anchor.is_some() {
85-
let process = |a: Ty<'tcx>, b: Ty<'tcx>| {
86-
if !matches!(a.kind(), ty::Opaque(..)) {
87-
return None;
88-
}
89-
self.fold_opaque_ty_new(a, cause.clone(), param_env, b)
82+
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
83+
ty::Opaque(def_id, substs) => self.fold_opaque_ty_new(
84+
OpaqueTypeKey { def_id, substs },
85+
cause.clone(),
86+
param_env,
87+
b,
88+
),
89+
_ => None,
9090
};
9191
if let Some(res) = process(a, b) {
9292
res
@@ -118,7 +118,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
118118
let origin = self.opaque_ty_origin_unchecked(key.def_id, cause.span);
119119
let prev = self.inner.borrow_mut().opaque_types().register(
120120
key,
121-
opaque_type,
122121
OpaqueHiddenType { ty: hidden_ty, span: cause.span },
123122
origin,
124123
);
@@ -482,7 +481,7 @@ impl UseKind {
482481
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
483482
fn fold_opaque_ty_new(
484483
&self,
485-
opaque_type: Ty<'tcx>,
484+
opaque_type_key: OpaqueTypeKey<'tcx>,
486485
cause: ObligationCause<'tcx>,
487486
param_env: ty::ParamEnv<'tcx>,
488487
hidden_ty: Ty<'tcx>,
@@ -521,26 +520,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
521520
// let x = || foo(); // returns the Opaque assoc with `foo`
522521
// }
523522
// ```
524-
let opaque_type_key = opaque_type.expect_opaque_type();
525523
if let Some(origin) = self.opaque_type_origin(opaque_type_key.def_id, cause.span) {
526-
return Some(self.fold_opaque_ty(
527-
opaque_type,
528-
cause,
529-
param_env,
530-
opaque_type_key,
531-
origin,
532-
hidden_ty,
533-
));
524+
return Some(self.fold_opaque_ty(cause, param_env, opaque_type_key, origin, hidden_ty));
534525
}
535526

536-
debug!(?opaque_type, "encountered opaque outside its definition scope",);
527+
debug!(?opaque_type_key, "encountered opaque outside its definition scope",);
537528
None
538529
}
539530

540531
#[instrument(skip(self), level = "debug")]
541532
fn fold_opaque_ty(
542533
&self,
543-
opaque_type: Ty<'tcx>,
544534
cause: ObligationCause<'tcx>,
545535
param_env: ty::ParamEnv<'tcx>,
546536
opaque_type_key: OpaqueTypeKey<'tcx>,
@@ -560,7 +550,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
560550
let mut obligations = vec![];
561551
let prev = self.inner.borrow_mut().opaque_types().register(
562552
OpaqueTypeKey { def_id, substs },
563-
opaque_type,
564553
OpaqueHiddenType { ty: hidden_ty, span },
565554
origin,
566555
);

compiler/rustc_infer/src/infer/opaque_types/table.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ impl<'a, 'tcx> OpaqueTypeTable<'a, 'tcx> {
7272
pub fn register(
7373
&mut self,
7474
key: OpaqueTypeKey<'tcx>,
75-
opaque_type: Ty<'tcx>,
7675
hidden_type: OpaqueHiddenType<'tcx>,
7776
origin: OpaqueTyOrigin,
7877
) -> Option<Ty<'tcx>> {
@@ -81,7 +80,7 @@ impl<'a, 'tcx> OpaqueTypeTable<'a, 'tcx> {
8180
self.undo_log.push(UndoLog::OpaqueTypes(key, Some(prev)));
8281
return Some(prev.ty);
8382
}
84-
let decl = OpaqueTypeDecl { opaque_type, hidden_type, origin };
83+
let decl = OpaqueTypeDecl { hidden_type, origin };
8584
self.storage.opaque_types.insert(key, decl);
8685
self.undo_log.push(UndoLog::OpaqueTypes(key, None));
8786
None

0 commit comments

Comments
 (0)