Skip to content

Commit f27c8ad

Browse files
committed
cool beans
1 parent 572b6e8 commit f27c8ad

146 files changed

Lines changed: 828 additions & 658 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_borrowck/src/diagnostics/opaque_types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
7676
"non-defining use of `{}` in the defining scope",
7777
Ty::new_opaque(
7878
infcx.tcx,
79+
ty::IsRigid::No,
7980
opaque_type_key.def_id.to_def_id(),
8081
opaque_type_key.args
8182
)
@@ -220,7 +221,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for FindOpaqueRegion<'_, 'tcx> {
220221
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
221222
// If we find an opaque in a local ty, then for each of its captured regions,
222223
// try to find a path between that captured regions and our borrow region...
223-
if let ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) = *ty.kind()
224+
if let ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) = *ty.kind()
224225
&& let hir::OpaqueTyOrigin::FnReturn { parent, in_trait_or_impl: None } =
225226
self.tcx.opaque_ty_origin(def_id)
226227
{
@@ -277,7 +278,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for CheckExplicitRegionMentionAndCollectGen
277278

278279
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
279280
match *ty.kind() {
280-
ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
281+
ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
281282
if self.seen_opaques.insert(def_id) {
282283
for (bound, _) in self
283284
.tcx

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
603603
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
604604

605605
let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
606-
if let ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, .. }) = *output_ty.kind() {
606+
if let ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, .. }) = *output_ty.kind() {
607607
output_ty = self.infcx.tcx.type_of(def_id).instantiate_identity().skip_norm_wip()
608608
};
609609

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
19281928
| ty::Never
19291929
| ty::Tuple(_)
19301930
| ty::UnsafeBinder(_)
1931-
| ty::Alias(_)
1931+
| ty::Alias(_, _)
19321932
| ty::Param(_)
19331933
| ty::Bound(_, _)
19341934
| ty::Infer(_)
@@ -1970,7 +1970,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
19701970
| ty::CoroutineWitness(..)
19711971
| ty::Never
19721972
| ty::UnsafeBinder(_)
1973-
| ty::Alias(_)
1973+
| ty::Alias(_, _)
19741974
| ty::Param(_)
19751975
| ty::Bound(_, _)
19761976
| ty::Infer(_)

compiler/rustc_borrowck/src/region_infer/opaque_types/member_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for CollectMemberConstraintsVisitor<'_, '_,
176176
| ty::CoroutineClosure(def_id, args)
177177
| ty::Coroutine(def_id, args) => self.visit_closure_args(def_id, args),
178178

179-
ty::Alias(ty::AliasTy { kind, args, .. })
179+
ty::Alias(_, ty::AliasTy { kind, args, .. })
180180
if let Some(variances) = self.cx().opt_alias_variances(kind) =>
181181
{
182182
// Skip lifetime parameters that are not captured, since they do

compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
367367
// usage of the opaque type and we can ignore it. This check is mirrored in typeck's
368368
// writeback.
369369
if !rcx.infcx.tcx.use_typing_mode_post_typeck_until_borrowck() {
370-
if let &ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) =
370+
if let &ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) =
371371
hidden_type.ty.skip_binder().kind()
372372
&& def_id == opaque_type_key.def_id.to_def_id()
373373
&& args == opaque_type_key.args
@@ -500,7 +500,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ToArgRegionsFolder<'_, 'tcx> {
500500
Ty::new_coroutine(tcx, def_id, self.fold_closure_args(def_id, args)?)
501501
}
502502

503-
ty::Alias(ty::AliasTy { kind, args, .. })
503+
ty::Alias(_, ty::AliasTy { kind, args, .. })
504504
if let Some(variances) = tcx.opt_alias_variances(kind) =>
505505
{
506506
let args = tcx.mk_args_from_iter(std::iter::zip(variances, args.iter()).map(
@@ -512,7 +512,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ToArgRegionsFolder<'_, 'tcx> {
512512
}
513513
},
514514
))?;
515-
ty::AliasTy::new_from_args(tcx, kind, args).to_ty(tcx)
515+
ty::AliasTy::new_from_args(tcx, kind, args).to_ty(tcx, ty::IsRigid::No)
516516
}
517517

518518
_ => ty.try_super_fold_with(self)?,
@@ -541,7 +541,7 @@ pub(crate) fn apply_definition_site_hidden_types<'tcx>(
541541
for &(key, hidden_type) in opaque_types {
542542
let Some(expected) = hidden_types.get(&key.def_id) else {
543543
if !tcx.use_typing_mode_post_typeck_until_borrowck() {
544-
if let &ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) =
544+
if let &ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) =
545545
hidden_type.ty.kind()
546546
&& def_id == key.def_id.to_def_id()
547547
&& args == key.args

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
469469
// Necessary for non-trivial patterns whose user-type annotation is an opaque type,
470470
// e.g. `let (_a,): Tait = whatever`, see #105897
471471
if !self.infcx.next_trait_solver()
472-
&& let ty::Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. }) =
472+
&& let ty::Alias(_, ty::AliasTy { kind: ty::Opaque { .. }, .. }) =
473473
curr_projected_ty.ty.kind()
474474
{
475475
// There is nothing that we can compare here if we go through an opaque type.
@@ -1760,7 +1760,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
17601760
let tcx = self.tcx();
17611761
let maybe_uneval = match constant.const_ {
17621762
Const::Ty(_, ct) => match ct.kind() {
1763-
ty::ConstKind::Unevaluated(uv) => match uv.kind {
1763+
ty::ConstKind::Unevaluated(_, uv) => match uv.kind {
17641764
ty::UnevaluatedConstKind::Projection { def_id }
17651765
| ty::UnevaluatedConstKind::Inherent { def_id }
17661766
| ty::UnevaluatedConstKind::Free { def_id }

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
150150
};
151151

152152
let (a, b) = match (a.kind(), b.kind()) {
153-
(&ty::Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. }), _) => {
153+
(&ty::Alias(_, ty::AliasTy { kind: ty::Opaque { .. }, .. }), _) => {
154154
(a, enable_subtyping(b, true)?)
155155
}
156-
(_, &ty::Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. })) => {
156+
(_, &ty::Alias(_, ty::AliasTy { kind: ty::Opaque { .. }, .. })) => {
157157
(enable_subtyping(a, false)?, b)
158158
}
159159
_ => unreachable!(
@@ -386,8 +386,8 @@ impl<'b, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'b, 'tcx> {
386386
}
387387

388388
(
389-
&ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id: a_def_id }, .. }),
390-
&ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id: b_def_id }, .. }),
389+
&ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id: a_def_id }, .. }),
390+
&ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id: b_def_id }, .. }),
391391
) if a_def_id == b_def_id || infcx.next_trait_solver() => {
392392
super_combine_tys(&infcx.infcx, self, a, b).map(|_| ()).or_else(|err| {
393393
// This behavior is only there for the old solver, the new solver
@@ -401,8 +401,8 @@ impl<'b, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'b, 'tcx> {
401401
if a_def_id.is_local() { self.relate_opaques(a, b) } else { Err(err) }
402402
})?;
403403
}
404-
(&ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, .. }), _)
405-
| (_, &ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, .. }))
404+
(&ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, .. }), _)
405+
| (_, &ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, .. }))
406406
if def_id.is_local() && !self.type_checker.infcx.next_trait_solver() =>
407407
{
408408
self.relate_opaques(a, b)?;

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ where
345345
Const::Ty(_, ct) => match ct.kind() {
346346
ty::ConstKind::Param(_) | ty::ConstKind::Error(_) => None,
347347
// Unevaluated consts in MIR bodies don't have associated MIR (e.g. `type const`).
348-
ty::ConstKind::Unevaluated(_) => None,
348+
ty::ConstKind::Unevaluated(_, _) => None,
349349
// FIXME(mgca): Investigate whether using `None` for `ConstKind::Value` is overly
350350
// strict, and if instead we should be doing some kind of value-based analysis.
351351
ty::ConstKind::Value(_) => None,

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,21 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
5353
// Types with identity (print the module path).
5454
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
5555
| ty::FnDef(def_id, args)
56-
| ty::Alias(ty::AliasTy {
57-
kind: ty::Projection { def_id } | ty::Opaque { def_id },
58-
args,
59-
..
60-
})
56+
| ty::Alias(
57+
_,
58+
ty::AliasTy {
59+
kind: ty::Projection { def_id } | ty::Opaque { def_id }, args, ..
60+
},
61+
)
6162
| ty::Closure(def_id, args)
6263
| ty::CoroutineClosure(def_id, args)
6364
| ty::Coroutine(def_id, args) => self.print_def_path(def_id, args),
6465
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
6566

66-
ty::Alias(ty::AliasTy { kind: ty::Free { .. }, .. }) => {
67+
ty::Alias(_, ty::AliasTy { kind: ty::Free { .. }, .. }) => {
6768
bug!("type_name: unexpected free alias")
6869
}
69-
ty::Alias(ty::AliasTy { kind: ty::Inherent { .. }, .. }) => {
70+
ty::Alias(_, ty::AliasTy { kind: ty::Inherent { .. }, .. }) => {
7071
bug!("type_name: unexpected inherent projection")
7172
}
7273
ty::CoroutineWitness(..) => bug!("type_name: unexpected `CoroutineWitness`"),

compiler/rustc_hir_analysis/src/autoderef.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
165165
return None;
166166
}
167167

168-
let (normalized_ty, obligations) = self
169-
.normalize_ty(Unnormalized::new(Ty::new_projection(tcx, trait_target_def_id, [ty])))?;
168+
let (normalized_ty, obligations) = self.normalize_ty(Unnormalized::new(
169+
Ty::new_projection(tcx, ty::IsRigid::No, trait_target_def_id, [ty]),
170+
))?;
170171
debug!("overloaded_deref_ty({:?}) = ({:?}, {:?})", ty, normalized_ty, obligations);
171172
self.state.obligations.extend(obligations);
172173

0 commit comments

Comments
 (0)