@@ -3,7 +3,6 @@ use super::CandidateSource;
3
3
use super :: MethodError ;
4
4
use super :: NoMatchData ;
5
5
6
- use crate :: errors:: MethodCallOnUnknownRawPointee ;
7
6
use crate :: FnCtxt ;
8
7
use rustc_data_structures:: fx:: FxHashSet ;
9
8
use rustc_errors:: Applicability ;
@@ -433,21 +432,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
433
432
if is_suggestion. 0 {
434
433
// Ambiguity was encountered during a suggestion. Just keep going.
435
434
debug ! ( "ProbeContext: encountered ambiguity in suggestion" ) ;
436
- } else if bad_ty. reached_raw_pointer && !self . tcx . features ( ) . arbitrary_self_types {
435
+ } else if bad_ty. reached_raw_pointer
436
+ && !self . tcx . features ( ) . arbitrary_self_types
437
+ && !self . tcx . sess . at_least_rust_2018 ( )
438
+ {
437
439
// this case used to be allowed by the compiler,
438
440
// so we do a future-compat lint here for the 2015 edition
439
441
// (see https://github.com/rust-lang/rust/issues/46906)
440
- if self . tcx . sess . at_least_rust_2018 ( ) {
441
- self . dcx ( ) . emit_err ( MethodCallOnUnknownRawPointee { span } ) ;
442
- } else {
443
- self . tcx . node_span_lint (
444
- lint:: builtin:: TYVAR_BEHIND_RAW_POINTER ,
445
- scope_expr_id,
446
- span,
447
- "type annotations needed" ,
448
- |_| { } ,
449
- ) ;
450
- }
442
+ self . tcx . node_span_lint (
443
+ lint:: builtin:: TYVAR_BEHIND_RAW_POINTER ,
444
+ scope_expr_id,
445
+ span,
446
+ "type annotations needed" ,
447
+ |_| { } ,
448
+ ) ;
451
449
} else {
452
450
// Ended up encountering a type variable when doing autoderef,
453
451
// but it may not be a type variable after processing obligations
@@ -458,10 +456,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
458
456
. unwrap_or_else ( |_| span_bug ! ( span, "instantiating {:?} failed?" , ty) ) ;
459
457
let ty = self . resolve_vars_if_possible ( ty. value ) ;
460
458
let guar = match * ty. kind ( ) {
461
- ty:: Infer ( ty:: TyVar ( _) ) => self
462
- . err_ctxt ( )
463
- . emit_inference_failure_err ( self . body_id , span, ty. into ( ) , E0282 , true )
464
- . emit ( ) ,
459
+ ty:: Infer ( ty:: TyVar ( _) ) => {
460
+ let raw_ptr_call =
461
+ bad_ty. reached_raw_pointer && !self . tcx . features ( ) . arbitrary_self_types ;
462
+ let mut err = self . err_ctxt ( ) . emit_inference_failure_err (
463
+ self . body_id ,
464
+ span,
465
+ ty. into ( ) ,
466
+ E0282 ,
467
+ !raw_ptr_call,
468
+ ) ;
469
+ if raw_ptr_call {
470
+ err. span_label ( span, "cannot call a method on a raw pointer with an unknown pointee type" ) ;
471
+ }
472
+ err. emit ( )
473
+ }
465
474
ty:: Error ( guar) => guar,
466
475
_ => bug ! ( "unexpected bad final type in method autoderef" ) ,
467
476
} ;
0 commit comments