Skip to content

Commit c924332

Browse files
committed
---
yaml --- r: 227916 b: refs/heads/try c: 900af2c h: refs/heads/master v: v3
1 parent 4331880 commit c924332

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: b1931e48a01b418b4b1ba6c747f2c99a5b10d96f
4+
refs/heads/try: 900af2c6d9b21ca1b1db35b7b09b0fb59cf78b84
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_lint/builtin.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,15 @@ impl LintPass for UnconditionalRecursion {
20072007
// method instead.
20082008
ty::MethodTypeParam(
20092009
ty::MethodParam { ref trait_ref, method_num, impl_def_id: None, }) => {
2010+
2011+
let on_self = m.substs.self_ty().map_or(false, |t| t.is_self());
2012+
if !on_self {
2013+
// we can only be recurring in a default
2014+
// method if we're being called literally
2015+
// on the `Self` type.
2016+
return false
2017+
}
2018+
20102019
tcx.trait_item(trait_ref.def_id, method_num).def_id()
20112020
}
20122021

branches/try/src/test/compile-fail/lint-unconditional-recursion.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,11 @@ fn all_fine() {
6767
let _f = all_fine;
6868
}
6969

70+
// issue 26333
71+
trait Bar {
72+
fn method<T: Bar>(&self, x: &T) {
73+
x.method(x)
74+
}
75+
}
76+
7077
fn main() {}

0 commit comments

Comments
 (0)