Skip to content

Commit b96e61b

Browse files
committed
---
yaml --- r: 234987 b: refs/heads/stable c: 900af2c h: refs/heads/master i: 234985: 797aba3 234983: cf18654 v: v3
1 parent 45480f1 commit b96e61b

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
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: b1931e48a01b418b4b1ba6c747f2c99a5b10d96f
32+
refs/heads/stable: 900af2c6d9b21ca1b1db35b7b09b0fb59cf78b84
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/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/stable/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)