@@ -44,10 +44,7 @@ use rustc_infer::infer::InferOk;
4444use rustc_infer:: traits:: query:: NoSolution ;
4545use rustc_infer:: traits:: ObligationCause ;
4646use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , AllowTwoPhase } ;
47- use rustc_middle:: ty:: error:: {
48- ExpectedFound ,
49- TypeError :: { FieldMisMatch , Sorts } ,
50- } ;
47+ use rustc_middle:: ty:: error:: { ExpectedFound , TypeError :: Sorts } ;
5148use rustc_middle:: ty:: GenericArgsRef ;
5249use rustc_middle:: ty:: { self , AdtKind , Ty , TypeVisitableExt } ;
5350use rustc_session:: errors:: ExprParenthesesNeeded ;
@@ -1811,24 +1808,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18111808 let target_ty = self . field_ty ( base_expr. span , f, args) ;
18121809 let cause = self . misc ( base_expr. span ) ;
18131810 match self . at ( & cause, self . param_env ) . sup (
1814- DefineOpaqueTypes :: No ,
1811+ // We're already using inference variables for any params, and don't allow converting
1812+ // between different structs, so there is no way this ever actually defines an opaque type.
1813+ // Thus choosing `Yes` is fine.
1814+ DefineOpaqueTypes :: Yes ,
18151815 target_ty,
18161816 fru_ty,
18171817 ) {
18181818 Ok ( InferOk { obligations, value : ( ) } ) => {
18191819 self . register_predicates ( obligations)
18201820 }
18211821 Err ( _) => {
1822- // This should never happen, since we're just subtyping the
1823- // remaining_fields, but it's fine to emit this, I guess.
1824- self . err_ctxt ( )
1825- . report_mismatched_types (
1826- & cause,
1827- target_ty,
1828- fru_ty,
1829- FieldMisMatch ( variant. name , ident. name ) ,
1830- )
1831- . emit ( ) ;
1822+ span_bug ! (
1823+ cause. span( ) ,
1824+ "subtyping remaining fields of type changing FRU failed: {target_ty} != {fru_ty}: {}::{}" ,
1825+ variant. name,
1826+ ident. name,
1827+ ) ;
18321828 }
18331829 }
18341830 }
0 commit comments