Skip to content

Commit

Permalink
Remove unused fields
Browse files Browse the repository at this point in the history
Related to rust-lang#46753
  • Loading branch information
wesleywiser committed Mar 11, 2018
1 parent 6c70cd1 commit c192523
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ use rustc::hir;

pub struct CheckTypeWellFormedVisitor<'a, 'tcx:'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
code: ObligationCauseCode<'tcx>,
}

/// Helper type of a temporary returned by .for_item(...).
/// Necessary because we can't write the following bound:
/// F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(FnCtxt<'b, 'gcx, 'tcx>).
struct CheckWfFcxBuilder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
inherited: super::InheritedBuilder<'a, 'gcx, 'tcx>,
code: ObligationCauseCode<'gcx>,
id: ast::NodeId,
span: Span,
param_env: ty::ParamEnv<'tcx>,
Expand All @@ -47,15 +45,13 @@ impl<'a, 'gcx, 'tcx> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
F: for<'b> FnOnce(&FnCtxt<'b, 'gcx, 'tcx>,
&mut CheckTypeWellFormedVisitor<'b, 'gcx>) -> Vec<Ty<'tcx>>
{
let code = self.code.clone();
let id = self.id;
let span = self.span;
let param_env = self.param_env;
self.inherited.enter(|inh| {
let fcx = FnCtxt::new(&inh, param_env, id);
let wf_tys = f(&fcx, &mut CheckTypeWellFormedVisitor {
tcx: fcx.tcx.global_tcx(),
code,
});
fcx.select_all_obligations_or_error();
fcx.regionck_item(id, span, &wf_tys);
Expand All @@ -68,7 +64,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
-> CheckTypeWellFormedVisitor<'a, 'gcx> {
CheckTypeWellFormedVisitor {
tcx,
code: ObligationCauseCode::MiscObligation
}
}

Expand Down Expand Up @@ -165,7 +160,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
item_id: ast::NodeId,
span: Span,
sig_if_method: Option<&hir::MethodSig>) {
let code = self.code.clone();
let code = ObligationCauseCode::MiscObligation;
self.for_id(item_id, span).with_fcx(|fcx, this| {
let item = fcx.tcx.associated_item(fcx.tcx.hir.local_def_id(item_id));

Expand Down Expand Up @@ -213,7 +208,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
let def_id = self.tcx.hir.local_def_id(id);
CheckWfFcxBuilder {
inherited: Inherited::build(self.tcx, def_id),
code: self.code.clone(),
id,
span,
param_env: self.tcx.param_env(def_id),
Expand Down Expand Up @@ -265,7 +259,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {

// All field types must be well-formed.
for field in &variant.fields {
fcx.register_wf_obligation(field.ty, field.span, this.code.clone())
fcx.register_wf_obligation(field.ty, field.span, ObligationCauseCode::MiscObligation)
}
}

Expand Down Expand Up @@ -300,11 +294,11 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
{
debug!("check_item_type: {:?}", item);

self.for_item(item).with_fcx(|fcx, this| {
self.for_item(item).with_fcx(|fcx, _this| {
let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item.id));
let item_ty = fcx.normalize_associated_types_in(item.span, &ty);

fcx.register_wf_obligation(item_ty, item.span, this.code.clone());
fcx.register_wf_obligation(item_ty, item.span, ObligationCauseCode::MiscObligation);

vec![] // no implied bounds in a const etc
});
Expand Down Expand Up @@ -339,7 +333,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
None => {
let self_ty = fcx.tcx.type_of(item_def_id);
let self_ty = fcx.normalize_associated_types_in(item.span, &self_ty);
fcx.register_wf_obligation(self_ty, ast_self_ty.span, this.code.clone());
fcx.register_wf_obligation(self_ty, ast_self_ty.span, ObligationCauseCode::MiscObligation);
}
}

Expand Down Expand Up @@ -374,7 +368,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
// parameter includes another (e.g., <T, U = T>). In those cases, we can't
// be sure if it will error or not as user might always specify the other.
if !ty.needs_subst() {
fcx.register_wf_obligation(ty, fcx.tcx.def_span(d), self.code.clone());
fcx.register_wf_obligation(ty, fcx.tcx.def_span(d), ObligationCauseCode::MiscObligation);
}
}

Expand Down Expand Up @@ -458,11 +452,11 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
let sig = fcx.tcx.liberate_late_bound_regions(def_id, &sig);

for input_ty in sig.inputs() {
fcx.register_wf_obligation(&input_ty, span, self.code.clone());
fcx.register_wf_obligation(&input_ty, span, ObligationCauseCode::MiscObligation);
}
implied_bounds.extend(sig.inputs());

fcx.register_wf_obligation(sig.output(), span, self.code.clone());
fcx.register_wf_obligation(sig.output(), span, ObligationCauseCode::MiscObligation);

// FIXME(#25759) return types should not be implied bounds
implied_bounds.push(sig.output());
Expand Down

0 comments on commit c192523

Please sign in to comment.