Skip to content

Fix MemCategorization and ExprUse visitors for new solver #124859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion compiler/rustc_hir_typeck/src/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
match ty {
Some(ty) => {
let ty = self.resolve_vars_if_possible(ty);
if ty.references_error() || ty.is_ty_var() {
if ty.references_error() {
debug!("resolve_type_vars_or_error: error from {:?}", ty);
Err(())
} else if ty.is_ty_var() {
debug!("resolve_type_vars_or_error: infer var from {:?}", ty);
self.tcx()
.dcx()
.span_delayed_bug(self.tcx().hir().span(id), "encountered type variable");
Err(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we ever return Err(()) in places which should successfully compile? If not, please change McResult to Result<T, ErrorGuaranteed>

} else {
Ok(ty)
}
Expand Down Expand Up @@ -210,6 +216,9 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
Some(t) => Ok(t.ty),
None => {
debug!("By-ref binding of non-derefable type");
self.tcx()
.dcx()
.span_delayed_bug(pat.span, "by-ref binding of non-derefable type");
Err(())
}
}
Expand Down Expand Up @@ -488,6 +497,10 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
Some(mt) => mt.ty,
None => {
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
self.tcx().dcx().span_delayed_bug(
self.tcx().hir().span(node.hir_id()),
"explicit deref of non-derefable type",
);
return Err(());
}
};
Expand Down Expand Up @@ -732,6 +745,9 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
PatKind::Slice(before, ref slice, after) => {
let Some(element_ty) = place_with_id.place.ty().builtin_index() else {
debug!("explicit index of non-indexable type {:?}", place_with_id);
self.tcx()
.dcx()
.span_delayed_bug(pat.span, "explicit index of non-indexable type");
return Err(());
};
let elt_place = self.cat_projection(
Expand Down