Skip to content

Commit bf0da44

Browse files
committed
Fix future_prelude_collision false positive
1 parent a1411de commit bf0da44

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

compiler/rustc_typeck/src/check/method/prelude2021.rs

+7
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5757
{
5858
return;
5959
}
60+
61+
// if it's an inherent `self` method (not `&self` or `&mut self`), it will take
62+
// precedence over the `TryInto` impl, and thus won't break in 2021 edition
63+
if pick.autoderefs == 0 && pick.autoref_or_ptr_adjustment.is_none() {
64+
return;
65+
}
66+
6067
// Inherent impls only require not relying on autoref and autoderef in order to
6168
// ensure that the trait implementation won't be used
6269
self.tcx.struct_span_lint_hir(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// edition:2018
2+
// check-pass
3+
#![allow(unused)]
4+
#![deny(future_prelude_collision)]
5+
6+
struct S;
7+
8+
impl S {
9+
fn try_into(self) -> S { S }
10+
}
11+
12+
// See https://github.com/rust-lang/rust/issues/86633
13+
fn main() {
14+
let s = S;
15+
let s2 = s.try_into();
16+
}

0 commit comments

Comments
 (0)