Skip to content

Check discriminant types before span_mirbug #100498

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 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
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
19 changes: 11 additions & 8 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,14 +1270,17 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
if let Err(terr) =
self.sub_types(rv_ty, place_ty, location.to_locations(), category)
{
span_mirbug!(
self,
stmt,
"bad assignment ({:?} = {:?}): {:?}",
place_ty,
rv_ty,
terr
);
// HACK(ouz-a): Bypasses ICE for #91633
if rv_ty.discriminant_ty(self.tcx()) != place_ty.discriminant_ty(self.tcx()) {
span_mirbug!(
self,
stmt,
"bad assignment ({:?} = {:?}): {:?}",
place_ty,
rv_ty,
terr
);
}
}

if let Some(annotation_index) = self.rvalue_user_ty(rv) {
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/typeck/issue-91633.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// check-pass
fn f<T> (it: &[T])
where
[T] : std::ops::Index<usize>,
{
let _ = &it[0];
}
fn main(){}