Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan-DPC committed Aug 25, 2020
1 parent dd1cd67 commit b1c2b98
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/type_check/mod.rs
Expand Up @@ -649,7 +649,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
PlaceTy::from_ty(match base_ty.kind {
ty::Array(inner, _) => {
assert!(!from_end, "array subslices should not use from_end");
tcx.mk_array(inner, (to - from) as u64)
tcx.mk_array(inner, to - from)
}
ty::Slice(..) => {
assert!(from_end, "slice subslices should use from_end");
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/interpret/place.rs
Expand Up @@ -549,17 +549,17 @@ where

ConstantIndex { offset, min_length, from_end } => {
let n = base.len(self)?;
if n < u64::from(min_length) {
if n < min_length {
// This can only be reached in ConstProp and non-rustc-MIR.
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
}

let index = if from_end {
assert!(0 < offset && offset <= min_length);
n.checked_sub(u64::from(offset)).unwrap()
n.checked_sub(offset).unwrap()
} else {
assert!(offset < min_length);
u64::from(offset)
offset
};

self.mplace_index(base, index)?
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/util/aggregate.rs
Expand Up @@ -4,6 +4,7 @@ use rustc_middle::ty::{Ty, TyCtxt};
use rustc_target::abi::VariantIdx;

use std::iter::TrustedLen;
use std::convert::TryFrom;

/// Expand `lhs = Rvalue::Aggregate(kind, operands)` into assignments to the fields.
///
Expand Down
5 changes: 0 additions & 5 deletions src/librustc_mir/util/elaborate_drops.rs
Expand Up @@ -10,8 +10,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_target::abi::VariantIdx;
use std::fmt;

use std::convert::TryInto;

/// The value of an inserted drop flag.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum DropFlagState {
Expand Down Expand Up @@ -744,9 +742,6 @@ where
let tcx = self.tcx();

if let Some(size) = opt_size {
let size: u64 = size.try_into().unwrap_or_else(|_| {
bug!("move out check isn't implemented for array sizes bigger than u64::MAX");
});
let fields: Vec<(Place<'tcx>, Option<D::Path>)> = (0..size)
.map(|i| {
(
Expand Down

0 comments on commit b1c2b98

Please sign in to comment.