impl IntTypeExt for attr::IntType {
fn to_ty<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
match *self {
- SignedInt(ast::IntTy::I8) => tcx.types.i8,
- SignedInt(ast::IntTy::I16) => tcx.types.i16,
- SignedInt(ast::IntTy::I32) => tcx.types.i32,
- SignedInt(ast::IntTy::I64) => tcx.types.i64,
+ SignedInt(ast::IntTy::I8) => tcx.types.i8,
+ SignedInt(ast::IntTy::I16) => tcx.types.i16,
+ SignedInt(ast::IntTy::I32) => tcx.types.i32,
+ SignedInt(ast::IntTy::I64) => tcx.types.i64,
SignedInt(ast::IntTy::I128) => tcx.types.i128,
- SignedInt(ast::IntTy::Isize) => tcx.types.isize,
+ SignedInt(ast::IntTy::Isize) => tcx.types.isize,
UnsignedInt(ast::UintTy::U8) => tcx.types.u8,
UnsignedInt(ast::UintTy::U16) => tcx.types.u16,
UnsignedInt(ast::UintTy::U32) => tcx.types.u32,
UnsignedInt(ast::UintTy::U64) => tcx.types.u64,
- UnsignedInt(ast::UintTy::U128) => tcx.types.u128,
+ UnsignedInt(ast::UintTy::U128) => tcx.types.u128,
UnsignedInt(ast::UintTy::Usize) => tcx.types.usize,
}
}
let mut infringing = Vec::new();
for variant in &adt.variants {
for field in &variant.fields {
- let span = tcx.def_span(field.did);
let ty = field.ty(tcx, substs);
if ty.references_error() {
continue;
}
+ let span = tcx.def_span(field.did);
let cause = ObligationCause { span, ..ObligationCause::dummy() };
let ctx = traits::FulfillmentContext::new();
match traits::fully_normalize(&infcx, ctx, cause, self, &ty) {
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
- match ty.sty {
- ty::Adt(def, substs) => {
- for field in def.all_fields() {
- let field_ty = field.ty(self, substs);
- if let Error = field_ty.sty {
- return true;
- }
+ if let ty::Adt(def, substs) = ty.sty {
+ for field in def.all_fields() {
+ let field_ty = field.ty(self, substs);
+ if let Error = field_ty.sty {
+ return true;
}
}
- _ => (),
}
false
}
let ty = self.type_of(adt_did);
self.for_each_relevant_impl(drop_trait, ty, |impl_did| {
if let Some(item) = self.associated_items(impl_did).next() {
- if let Ok(()) = validate(self, impl_did) {
+ if validate(self, impl_did).is_ok() {
dtor_did = Some(item.def_id);
}
}
false
}
}
- }).map(|(&item_param, _)| item_param).collect();
+ })
+ .map(|(&item_param, _)| item_param)
+ .collect();
debug!("destructor_constraint({:?}) = {:?}", def.did, result);
result
}
pub fn is_representable(&'tcx self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
sp: Span)
- -> Representability {
-
+ -> Representability
+ {
// Iterate until something non-representable is found
fn fold_repr<It: Iterator<Item=Representability>>(iter: It) -> Representability {
iter.fold(Representability::Representable, |r1, r2| {
let (param_env, ty) = query.into_parts();
let needs_drop = |ty: Ty<'tcx>| -> bool {
- match tcx.try_needs_drop_raw(DUMMY_SP, param_env.and(ty)) {
- Ok(v) => v,
- Err(mut bug) => {
- // Cycles should be reported as an error by `check_representable`.
- //
- // Consider the type as not needing drop in the meanwhile to
- // avoid further errors.
- //
- // In case we forgot to emit a bug elsewhere, delay our
- // diagnostic to get emitted as a compiler bug.
- bug.delay_as_bug();
- false
- }
- }
+ tcx.try_needs_drop_raw(DUMMY_SP, param_env.and(ty)).unwrap_or_else(|mut bug| {
+ // Cycles should be reported as an error by `check_representable`.
+ //
+ // Consider the type as not needing drop in the meanwhile to
+ // avoid further errors.
+ //
+ // In case we forgot to emit a bug elsewhere, delay our
+ // diagnostic to get emitted as a compiler bug.
+ bug.delay_as_bug();
+ false
+ })
};
assert!(!ty.needs_infer());