@@ -1284,22 +1284,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12841284 candidates. ambiguous = true ;
12851285 }
12861286 _ => {
1287- if self . constituent_types_for_ty ( self_ty) . is_some ( ) {
1288- candidates. vec . push ( DefaultImplCandidate ( def_id. clone ( ) ) )
1289- } else {
1290- // We don't yet know what the constituent
1291- // types are. So call it ambiguous for now,
1292- // though this is a bit stronger than
1293- // necessary: that is, we know that the
1294- // defaulted impl applies, but we can't
1295- // process the confirmation step without
1296- // knowing the constituent types. (Anyway, in
1297- // the particular case of defaulted impls, it
1298- // doesn't really matter much either way,
1299- // since we won't be aiding inference by
1300- // processing the confirmation step.)
1301- candidates. ambiguous = true ;
1302- }
1287+ candidates. vec . push ( DefaultImplCandidate ( def_id. clone ( ) ) )
13031288 }
13041289 }
13051290 }
@@ -1729,14 +1714,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17291714 return ok_if ( Vec :: new ( ) ) ;
17301715 }
17311716
1732- // TODO
1733- match self . infcx . closure_upvars ( def_id, substs) {
1734- Some ( upvars) => ok_if ( upvars. iter ( ) . map ( |c| c. ty ) . collect ( ) ) ,
1735- None => {
1736- debug ! ( "assemble_builtin_bound_candidates: no upvar types available yet" ) ;
1737- Ok ( AmbiguousBuiltin )
1738- }
1739- }
1717+ ok_if ( substs. upvar_tys . clone ( ) )
17401718 }
17411719
17421720 ty:: TyStruct ( def_id, substs) => {
@@ -1819,7 +1797,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18191797 /// Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32]
18201798 /// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
18211799 /// ```
1822- fn constituent_types_for_ty ( & self , t : Ty < ' tcx > ) -> Option < Vec < Ty < ' tcx > > > {
1800+ fn constituent_types_for_ty ( & self , t : Ty < ' tcx > ) -> Vec < Ty < ' tcx > > {
18231801 match t. sty {
18241802 ty:: TyUint ( _) |
18251803 ty:: TyInt ( _) |
@@ -1831,7 +1809,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18311809 ty:: TyInfer ( ty:: IntVar ( _) ) |
18321810 ty:: TyInfer ( ty:: FloatVar ( _) ) |
18331811 ty:: TyChar => {
1834- Some ( Vec :: new ( ) )
1812+ Vec :: new ( )
18351813 }
18361814
18371815 ty:: TyTrait ( ..) |
@@ -1848,56 +1826,56 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18481826 }
18491827
18501828 ty:: TyBox ( referent_ty) => { // Box<T>
1851- Some ( vec ! [ referent_ty] )
1829+ vec ! [ referent_ty]
18521830 }
18531831
18541832 ty:: TyRawPtr ( ty:: TypeAndMut { ty : element_ty, ..} ) |
18551833 ty:: TyRef ( _, ty:: TypeAndMut { ty : element_ty, ..} ) => {
1856- Some ( vec ! [ element_ty] )
1834+ vec ! [ element_ty]
18571835 } ,
18581836
18591837 ty:: TyArray ( element_ty, _) | ty:: TySlice ( element_ty) => {
1860- Some ( vec ! [ element_ty] )
1838+ vec ! [ element_ty]
18611839 }
18621840
18631841 ty:: TyTuple ( ref tys) => {
18641842 // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
1865- Some ( tys. clone ( ) )
1843+ tys. clone ( )
18661844 }
18671845
18681846 ty:: TyClosure ( def_id, ref substs) => {
1847+ // FIXME(#27086). We are invariant w/r/t our
1848+ // substs.func_substs, but we don't see them as
1849+ // constituent types; this seems RIGHT but also like
1850+ // something that a normal type couldn't simulate. Is
1851+ // this just a gap with the way that PhantomData and
1852+ // OIBIT interact? That is, there is no way to say
1853+ // "make me invariant with respect to this TYPE, but
1854+ // do not act as though I can reach it"
18691855 assert_eq ! ( def_id. krate, ast:: LOCAL_CRATE ) ;
1870-
1871- // TODO
1872- match self . infcx . closure_upvars ( def_id, substs) {
1873- Some ( upvars) => {
1874- Some ( upvars. iter ( ) . map ( |c| c. ty ) . collect ( ) )
1875- }
1876- None => {
1877- None
1878- }
1879- }
1856+ substs. upvar_tys . clone ( )
18801857 }
18811858
18821859 // for `PhantomData<T>`, we pass `T`
18831860 ty:: TyStruct ( def_id, substs)
18841861 if Some ( def_id) == self . tcx ( ) . lang_items . phantom_data ( ) =>
18851862 {
1886- Some ( substs. types . get_slice ( TypeSpace ) . to_vec ( ) )
1863+ substs. types . get_slice ( TypeSpace ) . to_vec ( )
18871864 }
18881865
18891866 ty:: TyStruct ( def_id, substs) => {
1890- Some ( self . tcx ( ) . struct_fields ( def_id, substs) . iter ( )
1891- . map ( |f| f. mt . ty )
1892- . collect ( ) )
1867+ self . tcx ( ) . struct_fields ( def_id, substs)
1868+ . iter ( )
1869+ . map ( |f| f. mt . ty )
1870+ . collect ( )
18931871 }
18941872
18951873 ty:: TyEnum ( def_id, substs) => {
1896- Some ( self . tcx ( ) . substd_enum_variants ( def_id, substs)
1897- . iter ( )
1898- . flat_map ( |variant| & variant. args )
1899- . map ( |& ty| ty)
1900- . collect ( ) )
1874+ self . tcx ( ) . substd_enum_variants ( def_id, substs)
1875+ . iter ( )
1876+ . flat_map ( |variant| & variant. args )
1877+ . map ( |& ty| ty)
1878+ . collect ( )
19011879 }
19021880 }
19031881 }
@@ -2147,15 +2125,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21472125
21482126 // binder is moved below
21492127 let self_ty = self . infcx . shallow_resolve ( obligation. predicate . skip_binder ( ) . self_ty ( ) ) ;
2150- match self . constituent_types_for_ty ( self_ty) {
2151- Some ( types) => self . vtable_default_impl ( obligation, trait_def_id, ty:: Binder ( types) ) ,
2152- None => {
2153- self . tcx ( ) . sess . bug (
2154- & format ! (
2155- "asked to confirm default implementation for ambiguous type: {:?}" ,
2156- self_ty) ) ;
2157- }
2158- }
2128+ let types = self . constituent_types_for_ty ( self_ty) ;
2129+ self . vtable_default_impl ( obligation, trait_def_id, ty:: Binder ( types) )
21592130 }
21602131
21612132 fn confirm_default_impl_object_candidate ( & mut self ,
0 commit comments