Skip to content

Commit 49b06a2

Browse files
committed
Directly call relate_types function instead of having a method wrapper
1 parent 597090e commit 49b06a2

File tree

2 files changed

+26
-37
lines changed

2 files changed

+26
-37
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -1153,19 +1153,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11531153
.convert_all(data);
11541154
}
11551155

1156-
/// Convenient wrapper around `relate_tys::relate_types` -- see
1157-
/// that fn for docs.
1158-
fn relate_types(
1159-
&mut self,
1160-
a: Ty<'tcx>,
1161-
v: ty::Variance,
1162-
b: Ty<'tcx>,
1163-
locations: Locations,
1164-
category: ConstraintCategory,
1165-
) -> Fallible<()> {
1166-
relate_tys::relate_types(self, a, v, b, locations, category)
1167-
}
1168-
11691156
/// Try to relate `sub <: sup`
11701157
fn sub_types(
11711158
&mut self,

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+26-24
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,32 @@ use crate::constraints::OutlivesConstraint;
99
use crate::diagnostics::UniverseInfo;
1010
use crate::type_check::{Locations, TypeChecker};
1111

12-
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
13-
///
14-
/// - "Covariant" `a <: b`
15-
/// - "Invariant" `a == b`
16-
/// - "Contravariant" `a :> b`
17-
///
18-
/// N.B., the type `a` is permitted to have unresolved inference
19-
/// variables, but not the type `b`.
20-
#[instrument(skip(type_checker), level = "debug")]
21-
pub(super) fn relate_types<'tcx>(
22-
type_checker: &mut TypeChecker<'_, 'tcx>,
23-
a: Ty<'tcx>,
24-
v: ty::Variance,
25-
b: Ty<'tcx>,
26-
locations: Locations,
27-
category: ConstraintCategory,
28-
) -> Fallible<()> {
29-
TypeRelating::new(
30-
type_checker.infcx,
31-
NllTypeRelatingDelegate::new(type_checker, locations, category, UniverseInfo::relate(a, b)),
32-
v,
33-
)
34-
.relate(a, b)?;
35-
Ok(())
12+
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13+
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
14+
///
15+
/// - "Covariant" `a <: b`
16+
/// - "Invariant" `a == b`
17+
/// - "Contravariant" `a :> b`
18+
///
19+
/// N.B., the type `a` is permitted to have unresolved inference
20+
/// variables, but not the type `b`.
21+
#[instrument(skip(self), level = "debug")]
22+
pub(super) fn relate_types(
23+
&mut self,
24+
a: Ty<'tcx>,
25+
v: ty::Variance,
26+
b: Ty<'tcx>,
27+
locations: Locations,
28+
category: ConstraintCategory,
29+
) -> Fallible<()> {
30+
TypeRelating::new(
31+
self.infcx,
32+
NllTypeRelatingDelegate::new(self, locations, category, UniverseInfo::relate(a, b)),
33+
v,
34+
)
35+
.relate(a, b)?;
36+
Ok(())
37+
}
3638
}
3739

3840
struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {

0 commit comments

Comments
 (0)