Skip to content

Commit

Permalink
pacify the mercilous tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Jun 1, 2017
1 parent c7a2e32 commit af223fa
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 29 deletions.
12 changes: 9 additions & 3 deletions src/librustc/traits/fulfill.rs
Expand Up @@ -420,7 +420,9 @@ fn process_predicate<'a, 'gcx, 'tcx>(
}

ty::Predicate::Equate(ref binder) => {
match selcx.infcx().equality_predicate(&obligation.cause, obligation.param_env, binder) {
match selcx.infcx().equality_predicate(&obligation.cause,
obligation.param_env,
binder) {
Ok(InferOk { obligations, value: () }) => {
Ok(Some(obligations))
},
Expand Down Expand Up @@ -508,7 +510,9 @@ fn process_predicate<'a, 'gcx, 'tcx>(
}

ty::Predicate::WellFormed(ty) => {
match ty::wf::obligations(selcx.infcx(), obligation.param_env, obligation.cause.body_id,
match ty::wf::obligations(selcx.infcx(),
obligation.param_env,
obligation.cause.body_id,
ty, obligation.cause.span) {
None => {
pending_obligation.stalled_on = vec![ty];
Expand All @@ -519,7 +523,9 @@ fn process_predicate<'a, 'gcx, 'tcx>(
}

ty::Predicate::Subtype(ref subtype) => {
match selcx.infcx().subtype_predicate(&obligation.cause, obligation.param_env, subtype) {
match selcx.infcx().subtype_predicate(&obligation.cause,
obligation.param_env,
subtype) {
None => {
// none means that both are unresolved
pending_obligation.stalled_on = vec![subtype.skip_binder().a,
Expand Down
5 changes: 4 additions & 1 deletion src/librustc/traits/project.rs
Expand Up @@ -500,7 +500,10 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
cacheable);

let result = if projected_ty.has_projection_types() {
let mut normalizer = AssociatedTypeNormalizer::new(selcx, param_env, cause, depth+1);
let mut normalizer = AssociatedTypeNormalizer::new(selcx,
param_env,
cause,
depth+1);
let normalized_ty = normalizer.fold(&projected_ty);

debug!("opt_normalize_projection_type: \
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/traits/select.rs
Expand Up @@ -553,7 +553,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
}

ty::Predicate::WellFormed(ty) => {
match ty::wf::obligations(self.infcx, obligation.param_env, obligation.cause.body_id,
match ty::wf::obligations(self.infcx,
obligation.param_env,
obligation.cause.body_id,
ty, obligation.cause.span) {
Some(obligations) =>
self.evaluate_predicates_recursively(previous_stack, obligations.iter()),
Expand Down
48 changes: 27 additions & 21 deletions src/librustc/ty/layout.rs
Expand Up @@ -1788,10 +1788,11 @@ impl<'a, 'tcx> Layout {
Fields::WithDiscrim(s) => (s, &s.offsets[1..]),
Fields::NoDiscrim(s) => (s, &s.offsets[0..]),
};
let field_info: Vec<_> = flds.iter()
.zip(field_offsets.iter())
.map(|(&field_name_ty, offset)| build_field_info(field_name_ty, offset))
.collect();
let field_info: Vec<_> =
flds.iter()
.zip(field_offsets.iter())
.map(|(&field_name_ty, offset)| build_field_info(field_name_ty, offset))
.collect();

session::VariantInfo {
name: n.map(|n|n.to_string()),
Expand All @@ -1814,9 +1815,10 @@ impl<'a, 'tcx> Layout {
debug!("print-type-size t: `{:?}` adt struct-wrapped nullable nndiscr {} is {:?}",
ty, nndiscr, variant_layout);
let variant_def = &adt_def.variants[nndiscr as usize];
let fields: Vec<_> = variant_def.fields.iter()
.map(|field_def| (field_def.name, field_def.ty(tcx, substs)))
.collect();
let fields: Vec<_> =
variant_def.fields.iter()
.map(|field_def| (field_def.name, field_def.ty(tcx, substs)))
.collect();
record(adt_kind.into(),
None,
vec![build_variant_info(Some(variant_def.name),
Expand All @@ -1840,9 +1842,10 @@ impl<'a, 'tcx> Layout {
"univariant with variants {:?}", variant_names());
if adt_def.variants.len() == 1 {
let variant_def = &adt_def.variants[0];
let fields: Vec<_> = variant_def.fields.iter()
.map(|field_def| (field_def.name, field_def.ty(tcx, substs)))
.collect();
let fields: Vec<_> =
variant_def.fields.iter()
.map(|f| (f.name, f.ty(tcx, substs)))
.collect();
record(adt_kind.into(),
None,
vec![build_variant_info(Some(variant_def.name),
Expand All @@ -1858,17 +1861,20 @@ impl<'a, 'tcx> Layout {
Layout::General { ref variants, discr, .. } => {
debug!("print-type-size t: `{:?}` adt general variants def {} layouts {} {:?}",
ty, adt_def.variants.len(), variants.len(), variants);
let variant_infos: Vec<_> = adt_def.variants.iter()
.zip(variants.iter())
.map(|(variant_def, variant_layout)| {
let fields: Vec<_> = variant_def.fields.iter()
.map(|field_def| (field_def.name, field_def.ty(tcx, substs)))
.collect();
build_variant_info(Some(variant_def.name),
&fields,
Fields::WithDiscrim(variant_layout))
})
.collect();
let variant_infos: Vec<_> =
adt_def.variants.iter()
.zip(variants.iter())
.map(|(variant_def, variant_layout)| {
let fields: Vec<_> =
variant_def.fields
.iter()
.map(|f| (f.name, f.ty(tcx, substs)))
.collect();
build_variant_info(Some(variant_def.name),
&fields,
Fields::WithDiscrim(variant_layout))
})
.collect();
record(adt_kind.into(), Some(discr.size()), variant_infos);
}

Expand Down
4 changes: 3 additions & 1 deletion src/librustc_typeck/check/method/probe.rs
Expand Up @@ -1183,7 +1183,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
traits::normalize(selcx, self.param_env, cause.clone(), &impl_bounds);

// Convert the bounds into obligations.
let obligations = traits::predicates_for_generics(cause.clone(), self.param_env, &impl_bounds);
let obligations = traits::predicates_for_generics(cause.clone(),
self.param_env,
&impl_bounds);
debug!("impl_obligations={:?}", obligations);

// Evaluate those obligations to see if they might possibly hold.
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_typeck/check/mod.rs
Expand Up @@ -1908,7 +1908,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
-> InferOk<'tcx, T>
where T : TypeFoldable<'tcx>
{
self.inh.normalize_associated_types_in_as_infer_ok(span, self.body_id, self.param_env, value)
self.inh.normalize_associated_types_in_as_infer_ok(span,
self.body_id,
self.param_env,
value)
}

pub fn write_nil(&self, node_id: ast::NodeId) {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/regionck.rs
Expand Up @@ -386,7 +386,8 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
for &ty in fn_sig_tys {
let ty = self.resolve_type(ty);
debug!("relate_free_regions(t={:?})", ty);
let implied_bounds = ty::wf::implied_bounds(self, self.fcx.param_env, body_id, ty, span);
let implied_bounds =
ty::wf::implied_bounds(self, self.fcx.param_env, body_id, ty, span);

// Record any relations between free regions that we observe into the free-region-map.
self.free_region_map.relate_free_regions_from_implied_bounds(&implied_bounds);
Expand Down

0 comments on commit af223fa

Please sign in to comment.