@@ -3,7 +3,6 @@ use super::CandidateSource;
33use super :: MethodError ;
44use super :: NoMatchData ;
55
6- use crate :: errors:: MethodCallOnUnknownRawPointee ;
76use crate :: FnCtxt ;
87use rustc_data_structures:: fx:: FxHashSet ;
98use rustc_errors:: Applicability ;
@@ -433,21 +432,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
433432 if is_suggestion. 0 {
434433 // Ambiguity was encountered during a suggestion. Just keep going.
435434 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+ {
437439 // this case used to be allowed by the compiler,
438440 // so we do a future-compat lint here for the 2015 edition
439441 // (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+ ) ;
451449 } else {
452450 // Ended up encountering a type variable when doing autoderef,
453451 // but it may not be a type variable after processing obligations
@@ -458,10 +456,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
458456 . unwrap_or_else ( |_| span_bug ! ( span, "instantiating {:?} failed?" , ty) ) ;
459457 let ty = self . resolve_vars_if_possible ( ty. value ) ;
460458 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+ }
465474 ty:: Error ( guar) => guar,
466475 _ => bug ! ( "unexpected bad final type in method autoderef" ) ,
467476 } ;
0 commit comments