Skip to content

Commit e56f0d7

Browse files
committed
FRU remaining fields does not actually define opaque types
1 parent 53d3fce commit e56f0d7

File tree

1 file changed

+11
-15
lines changed
  • compiler/rustc_hir_typeck/src

1 file changed

+11
-15
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ use rustc_infer::infer::InferOk;
4444
use rustc_infer::traits::query::NoSolution;
4545
use rustc_infer::traits::ObligationCause;
4646
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};
5148
use rustc_middle::ty::GenericArgsRef;
5249
use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitableExt};
5350
use 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

Comments
 (0)