@@ -44,10 +44,7 @@ use rustc_infer::infer::InferOk;
44
44
use rustc_infer:: traits:: query:: NoSolution ;
45
45
use rustc_infer:: traits:: ObligationCause ;
46
46
use 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 } ;
51
48
use rustc_middle:: ty:: GenericArgsRef ;
52
49
use rustc_middle:: ty:: { self , AdtKind , Ty , TypeVisitableExt } ;
53
50
use rustc_session:: errors:: ExprParenthesesNeeded ;
@@ -1811,24 +1808,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1811
1808
let target_ty = self . field_ty ( base_expr. span , f, args) ;
1812
1809
let cause = self . misc ( base_expr. span ) ;
1813
1810
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 ,
1815
1815
target_ty,
1816
1816
fru_ty,
1817
1817
) {
1818
1818
Ok ( InferOk { obligations, value : ( ) } ) => {
1819
1819
self . register_predicates ( obligations)
1820
1820
}
1821
1821
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
+ ) ;
1832
1828
}
1833
1829
}
1834
1830
}
0 commit comments