1use core::intrinsics;
4use std::marker::PhantomData;
5use std::num::NonZero;
6use std::ptr::NonNull;
7
8use rustc_data_structures::intern::Interned;
9use rustc_errors::{DiagArgValue, IntoDiagArg};
10use rustc_hir::def_id::DefId;
11use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension};
12use rustc_serialize::{Decodable, Encodable};
13use rustc_type_ir::WithCachedTypeInfo;
14use rustc_type_ir::walk::TypeWalker;
15use smallvec::SmallVec;
16
17use crate::ty::codec::{TyDecoder, TyEncoder};
18use crate::ty::{
19 self, ClosureArgs, CoroutineArgs, CoroutineClosureArgs, FallibleTypeFolder, InlineConstArgs,
20 Lift, List, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeVisitable, TypeVisitor, VisitorResult,
21 walk_visitable_list,
22};
23
24pub type GenericArgKind<'tcx> = rustc_type_ir::GenericArgKind<TyCtxt<'tcx>>;
25pub type TermKind<'tcx> = rustc_type_ir::TermKind<TyCtxt<'tcx>>;
26
27#[derive(Copy, Clone, PartialEq, Eq, Hash)]
36pub struct GenericArg<'tcx> {
37 ptr: NonNull<()>,
38 marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>)>,
39}
40
41impl<'tcx> rustc_type_ir::inherent::GenericArg<TyCtxt<'tcx>> for GenericArg<'tcx> {}
42
43impl<'tcx> rustc_type_ir::inherent::GenericArgs<TyCtxt<'tcx>> for ty::GenericArgsRef<'tcx> {
44 fn rebase_onto(
45 self,
46 tcx: TyCtxt<'tcx>,
47 source_ancestor: DefId,
48 target_args: GenericArgsRef<'tcx>,
49 ) -> GenericArgsRef<'tcx> {
50 self.rebase_onto(tcx, source_ancestor, target_args)
51 }
52
53 fn type_at(self, i: usize) -> Ty<'tcx> {
54 self.type_at(i)
55 }
56
57 fn region_at(self, i: usize) -> ty::Region<'tcx> {
58 self.region_at(i)
59 }
60
61 fn const_at(self, i: usize) -> ty::Const<'tcx> {
62 self.const_at(i)
63 }
64
65 fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
66 GenericArgs::identity_for_item(tcx, def_id)
67 }
68
69 fn extend_with_error(
70 tcx: TyCtxt<'tcx>,
71 def_id: DefId,
72 original_args: &[ty::GenericArg<'tcx>],
73 ) -> ty::GenericArgsRef<'tcx> {
74 ty::GenericArgs::extend_with_error(tcx, def_id, original_args)
75 }
76
77 fn split_closure_args(self) -> ty::ClosureArgsParts<TyCtxt<'tcx>> {
78 match self[..] {
79 [ref parent_args @ .., closure_kind_ty, closure_sig_as_fn_ptr_ty, tupled_upvars_ty] => {
80 ty::ClosureArgsParts {
81 parent_args,
82 closure_kind_ty: closure_kind_ty.expect_ty(),
83 closure_sig_as_fn_ptr_ty: closure_sig_as_fn_ptr_ty.expect_ty(),
84 tupled_upvars_ty: tupled_upvars_ty.expect_ty(),
85 }
86 }
87 _ => bug!("closure args missing synthetics"),
88 }
89 }
90
91 fn split_coroutine_closure_args(self) -> ty::CoroutineClosureArgsParts<TyCtxt<'tcx>> {
92 match self[..] {
93 [
94 ref parent_args @ ..,
95 closure_kind_ty,
96 signature_parts_ty,
97 tupled_upvars_ty,
98 coroutine_captures_by_ref_ty,
99 ] => ty::CoroutineClosureArgsParts {
100 parent_args,
101 closure_kind_ty: closure_kind_ty.expect_ty(),
102 signature_parts_ty: signature_parts_ty.expect_ty(),
103 tupled_upvars_ty: tupled_upvars_ty.expect_ty(),
104 coroutine_captures_by_ref_ty: coroutine_captures_by_ref_ty.expect_ty(),
105 },
106 _ => bug!("closure args missing synthetics"),
107 }
108 }
109
110 fn split_coroutine_args(self) -> ty::CoroutineArgsParts<TyCtxt<'tcx>> {
111 match self[..] {
112 [ref parent_args @ .., kind_ty, resume_ty, yield_ty, return_ty, tupled_upvars_ty] => {
113 ty::CoroutineArgsParts {
114 parent_args,
115 kind_ty: kind_ty.expect_ty(),
116 resume_ty: resume_ty.expect_ty(),
117 yield_ty: yield_ty.expect_ty(),
118 return_ty: return_ty.expect_ty(),
119 tupled_upvars_ty: tupled_upvars_ty.expect_ty(),
120 }
121 }
122 _ => bug!("coroutine args missing synthetics"),
123 }
124 }
125}
126
127impl<'tcx> rustc_type_ir::inherent::IntoKind for GenericArg<'tcx> {
128 type Kind = GenericArgKind<'tcx>;
129
130 fn kind(self) -> Self::Kind {
131 self.kind()
132 }
133}
134
135unsafe impl<'tcx> rustc_data_structures::sync::DynSend for GenericArg<'tcx> where
136 &'tcx (Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>): rustc_data_structures::sync::DynSend
137{
138}
139unsafe impl<'tcx> rustc_data_structures::sync::DynSync for GenericArg<'tcx> where
140 &'tcx (Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>): rustc_data_structures::sync::DynSync
141{
142}
143unsafe impl<'tcx> Send for GenericArg<'tcx> where
144 &'tcx (Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>): Send
145{
146}
147unsafe impl<'tcx> Sync for GenericArg<'tcx> where
148 &'tcx (Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>): Sync
149{
150}
151
152impl<'tcx> IntoDiagArg for GenericArg<'tcx> {
153 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
154 self.to_string().into_diag_arg(&mut None)
155 }
156}
157
158const TAG_MASK: usize = 0b11;
159const TYPE_TAG: usize = 0b00;
160const REGION_TAG: usize = 0b01;
161const CONST_TAG: usize = 0b10;
162
163#[extension(trait GenericArgPackExt<'tcx>)]
164impl<'tcx> GenericArgKind<'tcx> {
165 #[inline]
166 fn pack(self) -> GenericArg<'tcx> {
167 let (tag, ptr) = match self {
168 GenericArgKind::Lifetime(lt) => {
169 assert_eq!(align_of_val(&*lt.0.0) & TAG_MASK, 0);
171 (REGION_TAG, NonNull::from(lt.0.0).cast())
172 }
173 GenericArgKind::Type(ty) => {
174 assert_eq!(align_of_val(&*ty.0.0) & TAG_MASK, 0);
176 (TYPE_TAG, NonNull::from(ty.0.0).cast())
177 }
178 GenericArgKind::Const(ct) => {
179 assert_eq!(align_of_val(&*ct.0.0) & TAG_MASK, 0);
181 (CONST_TAG, NonNull::from(ct.0.0).cast())
182 }
183 };
184
185 GenericArg { ptr: ptr.map_addr(|addr| addr | tag), marker: PhantomData }
186 }
187}
188
189impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> {
190 #[inline]
191 fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> {
192 GenericArgKind::Lifetime(r).pack()
193 }
194}
195
196impl<'tcx> From<Ty<'tcx>> for GenericArg<'tcx> {
197 #[inline]
198 fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> {
199 GenericArgKind::Type(ty).pack()
200 }
201}
202
203impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
204 #[inline]
205 fn from(c: ty::Const<'tcx>) -> GenericArg<'tcx> {
206 GenericArgKind::Const(c).pack()
207 }
208}
209
210impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
211 fn from(value: ty::Term<'tcx>) -> Self {
212 match value.kind() {
213 ty::TermKind::Ty(t) => t.into(),
214 ty::TermKind::Const(c) => c.into(),
215 }
216 }
217}
218
219impl<'tcx> GenericArg<'tcx> {
220 #[inline]
221 pub fn kind(self) -> GenericArgKind<'tcx> {
222 let ptr =
223 unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
224 unsafe {
228 match self.ptr.addr().get() & TAG_MASK {
229 REGION_TAG => GenericArgKind::Lifetime(ty::Region(Interned::new_unchecked(
230 ptr.cast::<ty::RegionKind<'tcx>>().as_ref(),
231 ))),
232 TYPE_TAG => GenericArgKind::Type(Ty(Interned::new_unchecked(
233 ptr.cast::<WithCachedTypeInfo<ty::TyKind<'tcx>>>().as_ref(),
234 ))),
235 CONST_TAG => GenericArgKind::Const(ty::Const(Interned::new_unchecked(
236 ptr.cast::<WithCachedTypeInfo<ty::ConstKind<'tcx>>>().as_ref(),
237 ))),
238 _ => intrinsics::unreachable(),
239 }
240 }
241 }
242
243 #[inline]
244 pub fn as_region(self) -> Option<ty::Region<'tcx>> {
245 match self.kind() {
246 GenericArgKind::Lifetime(re) => Some(re),
247 _ => None,
248 }
249 }
250
251 #[inline]
252 pub fn as_type(self) -> Option<Ty<'tcx>> {
253 match self.kind() {
254 GenericArgKind::Type(ty) => Some(ty),
255 _ => None,
256 }
257 }
258
259 #[inline]
260 pub fn as_const(self) -> Option<ty::Const<'tcx>> {
261 match self.kind() {
262 GenericArgKind::Const(ct) => Some(ct),
263 _ => None,
264 }
265 }
266
267 #[inline]
268 pub fn as_term(self) -> Option<ty::Term<'tcx>> {
269 match self.kind() {
270 GenericArgKind::Lifetime(_) => None,
271 GenericArgKind::Type(ty) => Some(ty.into()),
272 GenericArgKind::Const(ct) => Some(ct.into()),
273 }
274 }
275
276 pub fn expect_region(self) -> ty::Region<'tcx> {
278 self.as_region().unwrap_or_else(|| bug!("expected a region, but found another kind"))
279 }
280
281 pub fn expect_ty(self) -> Ty<'tcx> {
285 self.as_type().unwrap_or_else(|| bug!("expected a type, but found another kind"))
286 }
287
288 pub fn expect_const(self) -> ty::Const<'tcx> {
290 self.as_const().unwrap_or_else(|| bug!("expected a const, but found another kind"))
291 }
292
293 pub fn is_non_region_infer(self) -> bool {
294 match self.kind() {
295 GenericArgKind::Lifetime(_) => false,
296 GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(),
298 GenericArgKind::Const(ct) => ct.is_ct_infer(),
299 }
300 }
301
302 pub fn walk(self) -> TypeWalker<TyCtxt<'tcx>> {
313 TypeWalker::new(self)
314 }
315}
316
317impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
318 type Lifted = GenericArg<'tcx>;
319
320 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
321 match self.kind() {
322 GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
323 GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),
324 GenericArgKind::Const(ct) => tcx.lift(ct).map(|ct| ct.into()),
325 }
326 }
327}
328
329impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
330 fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
331 self,
332 folder: &mut F,
333 ) -> Result<Self, F::Error> {
334 match self.kind() {
335 GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into),
336 GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into),
337 GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
338 }
339 }
340
341 fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
342 match self.kind() {
343 GenericArgKind::Lifetime(lt) => lt.fold_with(folder).into(),
344 GenericArgKind::Type(ty) => ty.fold_with(folder).into(),
345 GenericArgKind::Const(ct) => ct.fold_with(folder).into(),
346 }
347 }
348}
349
350impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
351 fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
352 match self.kind() {
353 GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
354 GenericArgKind::Type(ty) => ty.visit_with(visitor),
355 GenericArgKind::Const(ct) => ct.visit_with(visitor),
356 }
357 }
358}
359
360impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for GenericArg<'tcx> {
361 fn encode(&self, e: &mut E) {
362 self.kind().encode(e)
363 }
364}
365
366impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for GenericArg<'tcx> {
367 fn decode(d: &mut D) -> GenericArg<'tcx> {
368 GenericArgKind::decode(d).pack()
369 }
370}
371
372pub type GenericArgs<'tcx> = List<GenericArg<'tcx>>;
374
375pub type GenericArgsRef<'tcx> = &'tcx GenericArgs<'tcx>;
376
377impl<'tcx> GenericArgs<'tcx> {
378 pub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>> {
384 tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.kind() {
385 GenericArgKind::Type(ty) => ty,
386 _ => bug!("`into_type_list` called on generic arg with non-types"),
387 }))
388 }
389
390 pub fn as_closure(&'tcx self) -> ClosureArgs<TyCtxt<'tcx>> {
395 ClosureArgs { args: self }
396 }
397
398 pub fn as_coroutine_closure(&'tcx self) -> CoroutineClosureArgs<TyCtxt<'tcx>> {
403 CoroutineClosureArgs { args: self }
404 }
405
406 pub fn as_coroutine(&'tcx self) -> CoroutineArgs<TyCtxt<'tcx>> {
411 CoroutineArgs { args: self }
412 }
413
414 pub fn as_inline_const(&'tcx self) -> InlineConstArgs<'tcx> {
419 InlineConstArgs { args: self }
420 }
421
422 pub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: impl Into<DefId>) -> GenericArgsRef<'tcx> {
424 Self::for_item(tcx, def_id.into(), |param, _| tcx.mk_param_from_def(param))
425 }
426
427 pub fn for_item<F>(tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> GenericArgsRef<'tcx>
433 where
434 F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
435 {
436 let defs = tcx.generics_of(def_id);
437 let count = defs.count();
438 let mut args = SmallVec::with_capacity(count);
439 Self::fill_item(&mut args, tcx, defs, &mut mk_kind);
440 tcx.mk_args(&args)
441 }
442
443 pub fn extend_to<F>(
444 &self,
445 tcx: TyCtxt<'tcx>,
446 def_id: DefId,
447 mut mk_kind: F,
448 ) -> GenericArgsRef<'tcx>
449 where
450 F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
451 {
452 Self::for_item(tcx, def_id, |param, args| {
453 self.get(param.index as usize).cloned().unwrap_or_else(|| mk_kind(param, args))
454 })
455 }
456
457 pub fn fill_item<F>(
458 args: &mut SmallVec<[GenericArg<'tcx>; 8]>,
459 tcx: TyCtxt<'tcx>,
460 defs: &ty::Generics,
461 mk_kind: &mut F,
462 ) where
463 F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
464 {
465 if let Some(def_id) = defs.parent {
466 let parent_defs = tcx.generics_of(def_id);
467 Self::fill_item(args, tcx, parent_defs, mk_kind);
468 }
469 Self::fill_single(args, defs, mk_kind)
470 }
471
472 pub fn fill_single<F>(
473 args: &mut SmallVec<[GenericArg<'tcx>; 8]>,
474 defs: &ty::Generics,
475 mk_kind: &mut F,
476 ) where
477 F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
478 {
479 args.reserve(defs.own_params.len());
480 for param in &defs.own_params {
481 let kind = mk_kind(param, args);
482 assert_eq!(param.index as usize, args.len(), "{args:#?}, {defs:#?}");
483 args.push(kind);
484 }
485 }
486
487 pub fn extend_with_error(
490 tcx: TyCtxt<'tcx>,
491 def_id: DefId,
492 original_args: &[GenericArg<'tcx>],
493 ) -> GenericArgsRef<'tcx> {
494 ty::GenericArgs::for_item(tcx, def_id, |def, _| {
495 if let Some(arg) = original_args.get(def.index as usize) {
496 *arg
497 } else {
498 def.to_error(tcx)
499 }
500 })
501 }
502
503 #[inline]
504 pub fn types(&self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> {
505 self.iter().filter_map(|k| k.as_type())
506 }
507
508 #[inline]
509 pub fn regions(&self) -> impl DoubleEndedIterator<Item = ty::Region<'tcx>> {
510 self.iter().filter_map(|k| k.as_region())
511 }
512
513 #[inline]
514 pub fn consts(&self) -> impl DoubleEndedIterator<Item = ty::Const<'tcx>> {
515 self.iter().filter_map(|k| k.as_const())
516 }
517
518 #[inline]
520 pub fn non_erasable_generics(&self) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> {
521 self.iter().filter_map(|arg| match arg.kind() {
522 ty::GenericArgKind::Lifetime(_) => None,
523 generic => Some(generic),
524 })
525 }
526
527 #[inline]
528 #[track_caller]
529 pub fn type_at(&self, i: usize) -> Ty<'tcx> {
530 self[i].as_type().unwrap_or_else(
531 #[track_caller]
532 || bug!("expected type for param #{} in {:?}", i, self),
533 )
534 }
535
536 #[inline]
537 #[track_caller]
538 pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
539 self[i].as_region().unwrap_or_else(
540 #[track_caller]
541 || bug!("expected region for param #{} in {:?}", i, self),
542 )
543 }
544
545 #[inline]
546 #[track_caller]
547 pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
548 self[i].as_const().unwrap_or_else(
549 #[track_caller]
550 || bug!("expected const for param #{} in {:?}", i, self),
551 )
552 }
553
554 #[inline]
555 #[track_caller]
556 pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> {
557 self.type_at(def.index as usize).into()
558 }
559
560 pub fn rebase_onto(
579 &self,
580 tcx: TyCtxt<'tcx>,
581 source_ancestor: DefId,
582 target_args: GenericArgsRef<'tcx>,
583 ) -> GenericArgsRef<'tcx> {
584 let defs = tcx.generics_of(source_ancestor);
585 tcx.mk_args_from_iter(target_args.iter().chain(self.iter().skip(defs.count())))
586 }
587
588 pub fn truncate_to(&self, tcx: TyCtxt<'tcx>, generics: &ty::Generics) -> GenericArgsRef<'tcx> {
592 tcx.mk_args(&self[..generics.count()])
593 }
594
595 pub fn print_as_list(&self) -> String {
596 let v = self.iter().map(|arg| arg.to_string()).collect::<Vec<_>>();
597 format!("[{}]", v.join(", "))
598 }
599}
600
601impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArgsRef<'tcx> {
602 fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
603 self,
604 folder: &mut F,
605 ) -> Result<Self, F::Error> {
606 match self.len() {
613 1 => {
614 let param0 = self[0].try_fold_with(folder)?;
615 if param0 == self[0] { Ok(self) } else { Ok(folder.cx().mk_args(&[param0])) }
616 }
617 2 => {
618 let param0 = self[0].try_fold_with(folder)?;
619 let param1 = self[1].try_fold_with(folder)?;
620 if param0 == self[0] && param1 == self[1] {
621 Ok(self)
622 } else {
623 Ok(folder.cx().mk_args(&[param0, param1]))
624 }
625 }
626 0 => Ok(self),
627 _ => ty::util::try_fold_list(self, folder, |tcx, v| tcx.mk_args(v)),
628 }
629 }
630
631 fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
632 match self.len() {
634 1 => {
635 let param0 = self[0].fold_with(folder);
636 if param0 == self[0] { self } else { folder.cx().mk_args(&[param0]) }
637 }
638 2 => {
639 let param0 = self[0].fold_with(folder);
640 let param1 = self[1].fold_with(folder);
641 if param0 == self[0] && param1 == self[1] {
642 self
643 } else {
644 folder.cx().mk_args(&[param0, param1])
645 }
646 }
647 0 => self,
648 _ => ty::util::fold_list(self, folder, |tcx, v| tcx.mk_args(v)),
649 }
650 }
651}
652
653impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
654 fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
655 self,
656 folder: &mut F,
657 ) -> Result<Self, F::Error> {
658 match self.len() {
674 2 => {
675 let param0 = self[0].try_fold_with(folder)?;
676 let param1 = self[1].try_fold_with(folder)?;
677 if param0 == self[0] && param1 == self[1] {
678 Ok(self)
679 } else {
680 Ok(folder.cx().mk_type_list(&[param0, param1]))
681 }
682 }
683 _ => ty::util::try_fold_list(self, folder, |tcx, v| tcx.mk_type_list(v)),
684 }
685 }
686
687 fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
688 match self.len() {
690 2 => {
691 let param0 = self[0].fold_with(folder);
692 let param1 = self[1].fold_with(folder);
693 if param0 == self[0] && param1 == self[1] {
694 self
695 } else {
696 folder.cx().mk_type_list(&[param0, param1])
697 }
698 }
699 _ => ty::util::fold_list(self, folder, |tcx, v| tcx.mk_type_list(v)),
700 }
701 }
702}
703
704impl<'tcx, T: TypeVisitable<TyCtxt<'tcx>>> TypeVisitable<TyCtxt<'tcx>> for &'tcx ty::List<T> {
705 #[inline]
706 fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
707 walk_visitable_list!(visitor, self.iter());
708 V::Result::output()
709 }
710}
711
712#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
715#[derive(HashStable, TypeFoldable, TypeVisitable)]
716pub struct UserArgs<'tcx> {
717 pub args: GenericArgsRef<'tcx>,
719
720 pub user_self_ty: Option<UserSelfTy<'tcx>>,
723}
724
725#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
742#[derive(HashStable, TypeFoldable, TypeVisitable)]
743pub struct UserSelfTy<'tcx> {
744 pub impl_def_id: DefId,
745 pub self_ty: Ty<'tcx>,
746}