Skip to content

Commit 450d35f

Browse files
committed
Remove unused fields
Related to #46753
1 parent 36b6687 commit 450d35f

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/librustc_typeck/check/wfcheck.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ use rustc::hir;
2828

2929
pub struct CheckTypeWellFormedVisitor<'a, 'tcx:'a> {
3030
tcx: TyCtxt<'a, 'tcx, 'tcx>,
31-
code: ObligationCauseCode<'tcx>,
3231
}
3332

3433
/// Helper type of a temporary returned by .for_item(...).
3534
/// Necessary because we can't write the following bound:
3635
/// F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(FnCtxt<'b, 'gcx, 'tcx>).
3736
struct CheckWfFcxBuilder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
3837
inherited: super::InheritedBuilder<'a, 'gcx, 'tcx>,
39-
code: ObligationCauseCode<'gcx>,
4038
id: ast::NodeId,
4139
span: Span,
4240
param_env: ty::ParamEnv<'tcx>,
@@ -47,15 +45,13 @@ impl<'a, 'gcx, 'tcx> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
4745
F: for<'b> FnOnce(&FnCtxt<'b, 'gcx, 'tcx>,
4846
&mut CheckTypeWellFormedVisitor<'b, 'gcx>) -> Vec<Ty<'tcx>>
4947
{
50-
let code = self.code.clone();
5148
let id = self.id;
5249
let span = self.span;
5350
let param_env = self.param_env;
5451
self.inherited.enter(|inh| {
5552
let fcx = FnCtxt::new(&inh, param_env, id);
5653
let wf_tys = f(&fcx, &mut CheckTypeWellFormedVisitor {
5754
tcx: fcx.tcx.global_tcx(),
58-
code,
5955
});
6056
fcx.select_all_obligations_or_error();
6157
fcx.regionck_item(id, span, &wf_tys);
@@ -68,7 +64,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
6864
-> CheckTypeWellFormedVisitor<'a, 'gcx> {
6965
CheckTypeWellFormedVisitor {
7066
tcx,
71-
code: ObligationCauseCode::MiscObligation
7267
}
7368
}
7469

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

@@ -213,7 +208,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
213208
let def_id = self.tcx.hir.local_def_id(id);
214209
CheckWfFcxBuilder {
215210
inherited: Inherited::build(self.tcx, def_id),
216-
code: self.code.clone(),
217211
id,
218212
span,
219213
param_env: self.tcx.param_env(def_id),
@@ -265,7 +259,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
265259

266260
// All field types must be well-formed.
267261
for field in &variant.fields {
268-
fcx.register_wf_obligation(field.ty, field.span, this.code.clone())
262+
fcx.register_wf_obligation(field.ty, field.span, ObligationCauseCode::MiscObligation)
269263
}
270264
}
271265

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

303-
self.for_item(item).with_fcx(|fcx, this| {
297+
self.for_item(item).with_fcx(|fcx, _this| {
304298
let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item.id));
305299
let item_ty = fcx.normalize_associated_types_in(item.span, &ty);
306300

307-
fcx.register_wf_obligation(item_ty, item.span, this.code.clone());
301+
fcx.register_wf_obligation(item_ty, item.span, ObligationCauseCode::MiscObligation);
308302

309303
vec![] // no implied bounds in a const etc
310304
});
@@ -339,7 +333,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
339333
None => {
340334
let self_ty = fcx.tcx.type_of(item_def_id);
341335
let self_ty = fcx.normalize_associated_types_in(item.span, &self_ty);
342-
fcx.register_wf_obligation(self_ty, ast_self_ty.span, this.code.clone());
336+
fcx.register_wf_obligation(self_ty, ast_self_ty.span, ObligationCauseCode::MiscObligation);
343337
}
344338
}
345339

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

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

460454
for input_ty in sig.inputs() {
461-
fcx.register_wf_obligation(&input_ty, span, self.code.clone());
455+
fcx.register_wf_obligation(&input_ty, span, ObligationCauseCode::MiscObligation);
462456
}
463457
implied_bounds.extend(sig.inputs());
464458

465-
fcx.register_wf_obligation(sig.output(), span, self.code.clone());
459+
fcx.register_wf_obligation(sig.output(), span, ObligationCauseCode::MiscObligation);
466460

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

0 commit comments

Comments
 (0)