@@ -426,7 +426,10 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
426
426
}
427
427
428
428
impl < ' tcx > Instance < ' tcx > {
429
- pub fn new ( def_id : DefId , args : GenericArgsRef < ' tcx > ) -> Instance < ' tcx > {
429
+ /// Creates a new [`InstanceKind::Item`] from the `def_id` and `args`. Note that this
430
+ /// does not resolve trait items to their corresponding impl items -- to do that, use
431
+ /// [`Instance::expect_resolve`] instead.
432
+ pub fn new_raw ( def_id : DefId , args : GenericArgsRef < ' tcx > ) -> Instance < ' tcx > {
430
433
assert ! (
431
434
!args. has_escaping_bound_vars( ) ,
432
435
"args of instance {def_id:?} has escaping bound vars: {args:?}"
@@ -445,7 +448,7 @@ impl<'tcx> Instance<'tcx> {
445
448
}
446
449
} ) ;
447
450
448
- Instance :: new ( def_id, args)
451
+ Instance :: new_raw ( def_id, args)
449
452
}
450
453
451
454
#[ inline]
@@ -538,7 +541,7 @@ impl<'tcx> Instance<'tcx> {
538
541
let type_length = type_length ( args) ;
539
542
if !tcx. type_length_limit ( ) . value_within_limit ( type_length) {
540
543
let ( shrunk, written_to_path) =
541
- shrunk_instance_name ( tcx, Instance :: new ( def_id, args) ) ;
544
+ shrunk_instance_name ( tcx, Instance :: new_raw ( def_id, args) ) ;
542
545
let mut path = PathBuf :: new ( ) ;
543
546
let was_written = if let Some ( path2) = written_to_path {
544
547
path = path2;
@@ -708,7 +711,7 @@ impl<'tcx> Instance<'tcx> {
708
711
709
712
match needs_fn_once_adapter_shim ( actual_kind, requested_kind) {
710
713
Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, args) ,
711
- _ => Instance :: new ( def_id, args) ,
714
+ _ => Instance :: new_raw ( def_id, args) ,
712
715
}
713
716
}
714
717
@@ -822,7 +825,7 @@ impl<'tcx> Instance<'tcx> {
822
825
// This is important for `Iterator`'s combinators, but also useful for
823
826
// adding future default methods to `Future`, for instance.
824
827
debug_assert ! ( tcx. defaultness( trait_item_id) . has_value( ) ) ;
825
- Some ( Instance :: new ( trait_item_id, rcvr_args) )
828
+ Some ( Instance :: new_raw ( trait_item_id, rcvr_args) )
826
829
}
827
830
}
828
831
0 commit comments