|
6 | 6 | use std::fmt::{self, Debug};
|
7 | 7 |
|
8 | 8 | use rustc_abi::TyAndLayout;
|
| 9 | +use rustc_ast::InlineAsmTemplatePiece; |
9 | 10 | use rustc_ast_ir::try_visit;
|
10 | 11 | use rustc_ast_ir::visit::VisitorResult;
|
11 | 12 | use rustc_hir::def::Namespace;
|
| 13 | +use rustc_hir::def_id::LocalDefId; |
| 14 | +use rustc_span::Span; |
12 | 15 | use rustc_span::source_map::Spanned;
|
13 | 16 | use rustc_type_ir::ConstKind;
|
14 | 17 |
|
15 | 18 | use super::print::PrettyPrinter;
|
16 | 19 | use super::{GenericArg, GenericArgKind, Pattern, Region};
|
17 |
| -use crate::mir::interpret; |
| 20 | +use crate::mir::PlaceElem; |
18 | 21 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
|
19 | 22 | use crate::ty::print::{FmtPrinter, Printer, with_no_trimmed_paths};
|
20 | 23 | use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
@@ -221,76 +224,83 @@ impl<'tcx> fmt::Debug for Region<'tcx> {
|
221 | 224 | // copy...), just add them to one of these lists as appropriate.
|
222 | 225 |
|
223 | 226 | // For things for which the type library provides traversal implementations
|
224 |
| -// for all Interners, we only need to provide a Lift implementation: |
| 227 | +// for all Interners, we only need to provide a Lift implementation. |
225 | 228 | TrivialLiftImpls! {
|
226 |
| - (), |
227 |
| - bool, |
228 |
| - usize, |
229 |
| - u64, |
| 229 | + (), |
| 230 | + bool, |
| 231 | + usize, |
| 232 | + u64, |
| 233 | + crate::mir::Promoted, |
| 234 | + crate::mir::interpret::AllocId, |
| 235 | + crate::mir::interpret::Scalar, |
| 236 | + rustc_abi::ExternAbi, |
| 237 | + rustc_abi::Size, |
| 238 | + rustc_hir::Safety, |
| 239 | + rustc_type_ir::BoundConstness, |
| 240 | + rustc_type_ir::PredicatePolarity, |
230 | 241 | }
|
231 | 242 |
|
232 | 243 | // For some things about which the type library does not know, or does not
|
233 | 244 | // provide any traversal implementations, we need to provide a traversal
|
234 | 245 | // implementation (only for TyCtxt<'_> interners).
|
235 | 246 | TrivialTypeTraversalImpls! {
|
236 |
| - ::rustc_abi::FieldIdx, |
237 |
| - ::rustc_abi::VariantIdx, |
238 |
| - crate::middle::region::Scope, |
239 |
| - ::rustc_ast::InlineAsmOptions, |
240 |
| - ::rustc_ast::InlineAsmTemplatePiece, |
241 |
| - ::rustc_ast::NodeId, |
242 |
| - ::rustc_hir::def::Res, |
243 |
| - ::rustc_hir::def_id::LocalDefId, |
244 |
| - ::rustc_hir::ByRef, |
245 |
| - ::rustc_hir::HirId, |
246 |
| - ::rustc_hir::MatchSource, |
247 |
| - ::rustc_target::asm::InlineAsmRegOrRegClass, |
248 |
| - crate::mir::coverage::BlockMarkerId, |
249 |
| - crate::mir::coverage::CounterId, |
250 |
| - crate::mir::coverage::ExpressionId, |
251 |
| - crate::mir::coverage::ConditionId, |
| 247 | + crate::infer::canonical::Certainty, |
| 248 | + crate::mir::BasicBlock, |
| 249 | + crate::mir::BindingForm<'tcx>, |
| 250 | + crate::mir::BlockTailInfo, |
| 251 | + crate::mir::BorrowKind, |
| 252 | + crate::mir::CastKind, |
| 253 | + crate::mir::ConstValue<'tcx>, |
| 254 | + crate::mir::CoroutineSavedLocal, |
| 255 | + crate::mir::FakeReadCause, |
252 | 256 | crate::mir::Local,
|
| 257 | + crate::mir::MirPhase, |
| 258 | + crate::mir::NullOp<'tcx>, |
253 | 259 | crate::mir::Promoted,
|
254 |
| - crate::ty::adjustment::AutoBorrowMutability, |
| 260 | + crate::mir::RawPtrKind, |
| 261 | + crate::mir::RetagKind, |
| 262 | + crate::mir::SourceInfo, |
| 263 | + crate::mir::SourceScope, |
| 264 | + crate::mir::SourceScopeLocalData, |
| 265 | + crate::mir::SwitchTargets, |
| 266 | + crate::traits::IsConstable, |
| 267 | + crate::traits::OverflowError, |
255 | 268 | crate::ty::AdtKind,
|
256 |
| - crate::ty::BoundRegion, |
257 |
| - // Including `BoundRegionKind` is a *bit* dubious, but direct |
258 |
| - // references to bound region appear in `ty::Error`, and aren't |
259 |
| - // really meant to be folded. In general, we can only fold a fully |
260 |
| - // general `Region`. |
261 |
| - crate::ty::BoundRegionKind, |
262 | 269 | crate::ty::AssocItem,
|
263 | 270 | crate::ty::AssocKind,
|
| 271 | + crate::ty::BoundRegion, |
| 272 | + crate::ty::BoundVar, |
264 | 273 | crate::ty::Placeholder<crate::ty::BoundRegion>,
|
265 | 274 | crate::ty::Placeholder<crate::ty::BoundTy>,
|
266 | 275 | crate::ty::Placeholder<ty::BoundVar>,
|
267 |
| - crate::ty::LateParamRegion, |
| 276 | + crate::ty::UserTypeAnnotationIndex, |
| 277 | + crate::ty::ValTree<'tcx>, |
| 278 | + crate::ty::abstract_const::NotConstEvaluatable, |
| 279 | + crate::ty::adjustment::AutoBorrowMutability, |
268 | 280 | crate::ty::adjustment::PointerCoercion,
|
269 |
| - ::rustc_span::Ident, |
270 |
| - ::rustc_span::Span, |
271 |
| - ::rustc_span::Symbol, |
272 |
| - ty::BoundVar, |
273 |
| - ty::ValTree<'tcx>, |
| 281 | + rustc_abi::FieldIdx, |
| 282 | + rustc_abi::VariantIdx, |
| 283 | + rustc_ast::InlineAsmOptions, |
| 284 | + rustc_ast::InlineAsmTemplatePiece, |
| 285 | + rustc_hir::CoroutineKind, |
| 286 | + rustc_hir::HirId, |
| 287 | + rustc_hir::MatchSource, |
| 288 | + rustc_hir::def_id::LocalDefId, |
| 289 | + rustc_span::Ident, |
| 290 | + rustc_span::Span, |
| 291 | + rustc_span::Symbol, |
| 292 | + rustc_target::asm::InlineAsmRegOrRegClass, |
274 | 293 | }
|
| 294 | + |
275 | 295 | // For some things about which the type library does not know, or does not
|
276 | 296 | // provide any traversal implementations, we need to provide a traversal
|
277 | 297 | // implementation and a lift implementation (the former only for TyCtxt<'_>
|
278 | 298 | // interners).
|
279 | 299 | TrivialTypeTraversalAndLiftImpls! {
|
280 |
| - ::rustc_hir::def_id::DefId, |
281 |
| - crate::ty::ClosureKind, |
282 | 300 | crate::ty::ParamConst,
|
283 | 301 | crate::ty::ParamTy,
|
284 | 302 | crate::ty::instance::ReifyReason,
|
285 |
| - interpret::AllocId, |
286 |
| - interpret::CtfeProvenance, |
287 |
| - interpret::Scalar, |
288 |
| - rustc_abi::Size, |
289 |
| -} |
290 |
| - |
291 |
| -TrivialLiftImpls! { |
292 |
| - ::rustc_hir::Safety, |
293 |
| - ::rustc_abi::ExternAbi, |
| 303 | + rustc_hir::def_id::DefId, |
294 | 304 | }
|
295 | 305 |
|
296 | 306 | ///////////////////////////////////////////////////////////////////////////
|
@@ -672,3 +682,39 @@ impl<'tcx, T: TypeFoldable<TyCtxt<'tcx>> + Debug + Clone> TypeFoldable<TyCtxt<'t
|
672 | 682 | })
|
673 | 683 | }
|
674 | 684 | }
|
| 685 | + |
| 686 | +impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [InlineAsmTemplatePiece] { |
| 687 | + fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( |
| 688 | + self, |
| 689 | + _folder: &mut F, |
| 690 | + ) -> Result<Self, F::Error> { |
| 691 | + Ok(self) |
| 692 | + } |
| 693 | +} |
| 694 | + |
| 695 | +impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [Span] { |
| 696 | + fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( |
| 697 | + self, |
| 698 | + _folder: &mut F, |
| 699 | + ) -> Result<Self, F::Error> { |
| 700 | + Ok(self) |
| 701 | + } |
| 702 | +} |
| 703 | + |
| 704 | +impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<LocalDefId> { |
| 705 | + fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( |
| 706 | + self, |
| 707 | + _folder: &mut F, |
| 708 | + ) -> Result<Self, F::Error> { |
| 709 | + Ok(self) |
| 710 | + } |
| 711 | +} |
| 712 | + |
| 713 | +impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<PlaceElem<'tcx>> { |
| 714 | + fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( |
| 715 | + self, |
| 716 | + folder: &mut F, |
| 717 | + ) -> Result<Self, F::Error> { |
| 718 | + ty::util::fold_list(self, folder, |tcx, v| tcx.mk_place_elems(v)) |
| 719 | + } |
| 720 | +} |
0 commit comments