Skip to content

Commit 1351328

Browse files
committed
Simplify and fix some diagnostics around arrays
1 parent 88df3a2 commit 1351328

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/librustc/traits/error_reporting.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -418,20 +418,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
418418
Some(format!("[{}]", self.tcx.type_of(def.did).to_string())),
419419
));
420420
let tcx = self.tcx;
421-
if let ty::LazyConst::Evaluated(len) = len {
422-
if let Some(len) = len.val.try_to_scalar().and_then(|scalar| {
423-
scalar.to_usize(&tcx).ok()
424-
}) {
425-
flags.push((
426-
"_Self".to_owned(),
427-
Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)),
428-
));
429-
} else {
430-
flags.push((
431-
"_Self".to_owned(),
432-
Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())),
433-
));
434-
}
421+
if let Some(len) = len.assert_usize(tcx) {
422+
flags.push((
423+
"_Self".to_owned(),
424+
Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)),
425+
));
426+
} else {
427+
flags.push((
428+
"_Self".to_owned(),
429+
Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())),
430+
));
435431
}
436432
}
437433
}

0 commit comments

Comments
 (0)