Skip to content

Commit fed357e

Browse files
Add a IsIdentity extension trait for CanonicalUserType
1 parent 154fc09 commit fed357e

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

Diff for: Cargo.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
370370

371371
[[package]]
372372
name = "bytecount"
373-
version = "0.6.4"
373+
version = "0.6.5"
374374
source = "registry+https://github.com/rust-lang/crates.io-index"
375-
checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7"
375+
checksum = "d1a12477b7237a01c11a80a51278165f9ba0edd28fa6db00a65ab230320dc58c"
376376
dependencies = [
377377
"packed_simd",
378378
]
@@ -1673,9 +1673,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
16731673

16741674
[[package]]
16751675
name = "hashbrown"
1676-
version = "0.14.2"
1676+
version = "0.14.0"
16771677
source = "registry+https://github.com/rust-lang/crates.io-index"
1678-
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
1678+
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
16791679
dependencies = [
16801680
"ahash",
16811681
"allocator-api2",
@@ -1992,7 +1992,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
19921992
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
19931993
dependencies = [
19941994
"equivalent",
1995-
"hashbrown 0.14.2",
1995+
"hashbrown 0.14.0",
19961996
"rustc-rayon",
19971997
"serde",
19981998
]
@@ -2626,7 +2626,7 @@ dependencies = [
26262626
"compiler_builtins",
26272627
"crc32fast",
26282628
"flate2",
2629-
"hashbrown 0.14.2",
2629+
"hashbrown 0.14.0",
26302630
"indexmap 2.0.0",
26312631
"memchr",
26322632
"rustc-std-workspace-alloc",
@@ -5101,7 +5101,7 @@ dependencies = [
51015101
"core",
51025102
"dlmalloc",
51035103
"fortanix-sgx-abi",
5104-
"hashbrown 0.14.2",
5104+
"hashbrown 0.14.0",
51055105
"hermit-abi 0.3.2",
51065106
"libc",
51075107
"miniz_oxide",
@@ -5421,7 +5421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
54215421
checksum = "4db52ee8fec06e119b692ef3dd2c4cf621a99204c1b8c47407870ed050305b9b"
54225422
dependencies = [
54235423
"gimli",
5424-
"hashbrown 0.14.2",
5424+
"hashbrown 0.14.0",
54255425
"object",
54265426
"tracing",
54275427
]

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_middle::ty::error::TypeError;
2626
use rustc_middle::ty::fold::TypeFoldable;
2727
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
2828
use rustc_middle::ty::{
29-
self, AdtKind, CanonicalUserType, GenericParamDefKind, Ty, TyCtxt, UserType,
29+
self, AdtKind, CanonicalUserType, GenericParamDefKind, IsIdentity, Ty, TyCtxt, UserType,
3030
};
3131
use rustc_middle::ty::{GenericArgKind, GenericArgsRef, UserArgs, UserSelfTy};
3232
use rustc_session::lint;
@@ -208,7 +208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
208208
debug!("fcx {}", self.tag());
209209

210210
// FIXME: is_identity being on `UserType` and not `Canonical<UserType>` is awkward
211-
if !canonical_user_type_annotation.value.is_identity() {
211+
if !canonical_user_type_annotation.is_identity() {
212212
self.typeck_results
213213
.borrow_mut()
214214
.user_provided_types_mut()

Diff for: compiler/rustc_middle/src/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ pub use self::sty::{
106106
};
107107
pub use self::trait_def::TraitDef;
108108
pub use self::typeck_results::{
109-
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, TypeckResults,
110-
UserType, UserTypeAnnotationIndex,
109+
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
110+
TypeckResults, UserType, UserTypeAnnotationIndex,
111111
};
112112

113113
pub mod _match;

Diff for: compiler/rustc_middle/src/ty/typeck_results.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,15 @@ pub enum UserType<'tcx> {
607607
TypeOf(DefId, UserArgs<'tcx>),
608608
}
609609

610-
impl<'tcx> UserType<'tcx> {
610+
pub trait IsIdentity {
611+
fn is_identity(&self) -> bool;
612+
}
613+
614+
impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
611615
/// Returns `true` if this represents a substitution of the form `[?0, ?1, ?2]`,
612616
/// i.e., each thing is mapped to a canonical variable with the same index.
613-
pub fn is_identity(&self) -> bool {
614-
match self {
617+
fn is_identity(&self) -> bool {
618+
match self.value {
615619
UserType::Ty(_) => false,
616620
UserType::TypeOf(_, user_args) => {
617621
if user_args.user_self_ty.is_some() {

0 commit comments

Comments
 (0)