@@ -27,6 +27,7 @@ use syntax::ast;
27
27
use syntax:: util:: lev_distance:: { lev_distance, find_best_match_for_name} ;
28
28
use syntax_pos:: Span ;
29
29
use rustc:: hir;
30
+ use rustc:: lint;
30
31
use std:: mem;
31
32
use std:: ops:: Deref ;
32
33
use std:: rc:: Rc ;
@@ -249,7 +250,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
249
250
// think cause spurious errors. Really though this part should
250
251
// take place in the `self.probe` below.
251
252
let steps = if mode == Mode :: MethodCall {
252
- match self . create_steps ( span, self_ty, is_suggestion) {
253
+ match self . create_steps ( span, scope_expr_id , self_ty, is_suggestion) {
253
254
Some ( steps) => steps,
254
255
None => {
255
256
return Err ( MethodError :: NoMatch ( NoMatchData :: new ( Vec :: new ( ) ,
@@ -291,6 +292,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
291
292
292
293
fn create_steps ( & self ,
293
294
span : Span ,
295
+ scope_expr_id : ast:: NodeId ,
294
296
self_ty : Ty < ' tcx > ,
295
297
is_suggestion : IsSuggestion )
296
298
-> Option < Vec < CandidateStep < ' tcx > > > {
@@ -318,18 +320,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
318
320
match final_ty. sty {
319
321
ty:: TyInfer ( ty:: TyVar ( _) ) => {
320
322
// Ended in an inference variable. If we are doing
321
- // a real method lookup, this is a hard error ( it's an
322
- // ambiguity and we can't make progress) .
323
+ // a real method lookup, this is a hard error because it's
324
+ // possible that there will be multiple applicable methods .
323
325
if !is_suggestion. 0 {
324
326
if reached_raw_pointer
325
327
&& !self . tcx . sess . features . borrow ( ) . arbitrary_self_types {
326
- // only produce a warning in this case, because inference variables used to
327
- // be allowed here in some cases for raw pointers
328
- struct_span_warn ! ( self . tcx. sess, span, E0619 ,
329
- "the type of this value must be known in this context" )
330
- . note ( "this will be made into a hard error in a future version of \
331
- the compiler")
332
- . emit ( ) ;
328
+ // this case used to be allowed by the compiler,
329
+ // so we do a future-compat lint here
330
+ // (see https://github.com/rust-lang/rust/issues/46906)
331
+ self . tcx . lint_node (
332
+ lint:: builtin:: TYVAR_BEHIND_RAW_POINTER ,
333
+ scope_expr_id,
334
+ span,
335
+ & format ! ( "the type of this value must be known in this context" ) ) ;
333
336
} else {
334
337
let t = self . structurally_resolved_type ( span, final_ty) ;
335
338
assert_eq ! ( t, self . tcx. types. err) ;
0 commit comments