@@ -201,7 +201,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
201
201
self . lookup_probe ( span, segment. ident , self_ty, call_expr, ProbeScope :: TraitsInScope ) ?;
202
202
203
203
if span. edition ( ) < Edition :: Edition2021 {
204
- if let sym:: try_from | sym :: try_into = segment. ident . name {
204
+ if let sym:: try_into = segment. ident . name {
205
205
if let probe:: PickKind :: TraitPick = pick. kind {
206
206
if !matches ! ( self . tcx. crate_name( pick. item. def_id. krate) , sym:: std | sym:: core)
207
207
{
@@ -526,6 +526,33 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
526
526
expr_id,
527
527
ProbeScope :: TraitsInScope ,
528
528
) ?;
529
+
530
+ if span. edition ( ) < Edition :: Edition2021 {
531
+ if let sym:: try_into | sym:: try_from | sym:: from_iter = method_name. name {
532
+ if let probe:: PickKind :: TraitPick = pick. kind {
533
+ if !matches ! ( tcx. crate_name( pick. item. def_id. krate) , sym:: std | sym:: core) {
534
+ tcx. struct_span_lint_hir ( FUTURE_PRELUDE_COLLISION , expr_id, span, |lint| {
535
+ let trait_name = tcx. def_path_str ( pick. item . container . assert_trait ( ) ) ;
536
+
537
+ let mut lint = lint. build ( & format ! (
538
+ "trait method `{}` will become ambiguous in Rust 2021" ,
539
+ method_name. name
540
+ ) ) ;
541
+
542
+ lint. span_suggestion (
543
+ span,
544
+ "disambiguate the associated function" ,
545
+ format ! ( "<{} as {}>::{}" , self_ty, trait_name, method_name. name, ) ,
546
+ Applicability :: MachineApplicable ,
547
+ ) ;
548
+
549
+ lint. emit ( ) ;
550
+ } ) ;
551
+ }
552
+ }
553
+ }
554
+ }
555
+
529
556
debug ! ( "resolve_ufcs: pick={:?}" , pick) ;
530
557
{
531
558
let mut typeck_results = self . typeck_results . borrow_mut ( ) ;
0 commit comments