@@ -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 ;
@@ -1819,24 +1816,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18191816 let target_ty = self . field_ty ( base_expr. span , f, args) ;
18201817 let cause = self . misc ( base_expr. span ) ;
18211818 match self . at ( & cause, self . param_env ) . sup (
1822- DefineOpaqueTypes :: No ,
1819+ // We're already using inference variables for any params, and don't allow converting
1820+ // between different structs, so there is no way this ever actually defines an opaque type.
1821+ // Thus choosing `Yes` is fine.
1822+ DefineOpaqueTypes :: Yes ,
18231823 target_ty,
18241824 fru_ty,
18251825 ) {
18261826 Ok ( InferOk { obligations, value : ( ) } ) => {
18271827 self . register_predicates ( obligations)
18281828 }
18291829 Err ( _) => {
1830- // This should never happen, since we're just subtyping the
1831- // remaining_fields, but it's fine to emit this, I guess.
1832- self . err_ctxt ( )
1833- . report_mismatched_types (
1834- & cause,
1835- target_ty,
1836- fru_ty,
1837- FieldMisMatch ( variant. name , ident. name ) ,
1838- )
1839- . emit ( ) ;
1830+ span_bug ! (
1831+ cause. span( ) ,
1832+ "subtyping remaining fields of type changing FRU failed: {target_ty} != {fru_ty}: {}::{}" ,
1833+ variant. name,
1834+ ident. name,
1835+ ) ;
18401836 }
18411837 }
18421838 }
0 commit comments