Skip to content

Commit 8d3bb7e

Browse files
brsonthestinger
authored andcommitted
rustc: Remove some dead code from method resolution
1 parent 7fbe800 commit 8d3bb7e

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/librustc/middle/typeck/check/method.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ impl<'self> LookupContext<'self> {
194194
self.push_inherent_candidates(self_ty);
195195
self.push_extension_candidates();
196196

197-
let mut enum_dids = ~[];
198197
let mut self_ty = self_ty;
199198
let mut autoderefs = 0;
200199
loop {
@@ -236,7 +235,7 @@ impl<'self> LookupContext<'self> {
236235
}
237236

238237
// Otherwise, perform autoderef.
239-
match self.deref(self_ty, &mut enum_dids) {
238+
match self.deref(self_ty) {
240239
None => { break; }
241240
Some(ty) => {
242241
self_ty = ty;
@@ -248,20 +247,8 @@ impl<'self> LookupContext<'self> {
248247
self.search_for_autosliced_method(self_ty, autoderefs)
249248
}
250249

251-
pub fn deref(&self, ty: ty::t, enum_dids: &mut ~[ast::def_id])
250+
pub fn deref(&self, ty: ty::t)
252251
-> Option<ty::t> {
253-
match ty::get(ty).sty {
254-
ty_enum(did, _) => {
255-
// Watch out for newtype'd enums like "enum t = @T".
256-
// See discussion in typeck::check::do_autoderef().
257-
if enum_dids.iter().any(|x| x == &did) {
258-
return None;
259-
}
260-
enum_dids.push(did);
261-
}
262-
_ => {}
263-
}
264-
265252
match ty::deref(self.tcx(), ty, false) {
266253
None => None,
267254
Some(t) => {
@@ -285,7 +272,6 @@ impl<'self> LookupContext<'self> {
285272
* we'll want to find the inherent impls for `C`.
286273
*/
287274

288-
let mut enum_dids = ~[];
289275
let mut self_ty = self_ty;
290276
loop {
291277
match get(self_ty).sty {
@@ -314,7 +300,7 @@ impl<'self> LookupContext<'self> {
314300
// n.b.: Generally speaking, we only loop if we hit the
315301
// fallthrough case in the match above. The exception
316302
// would be newtype enums.
317-
self_ty = match self.deref(self_ty, &mut enum_dids) {
303+
self_ty = match self.deref(self_ty) {
318304
None => { return; }
319305
Some(ty) => { ty }
320306
}

0 commit comments

Comments
 (0)