@@ -36,50 +36,37 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
3636
3737use std:: cmp;
3838use std:: fmt;
39- use syntax:: ast;
4039use syntax_pos:: Span ;
4140use errors:: DiagnosticBuilder ;
4241
4342#[ derive( Debug , PartialEq , Eq , Hash ) ]
4443pub struct TraitErrorKey < ' tcx > {
4544 span : Span ,
46- warning_node_id : Option < ast:: NodeId > ,
4745 predicate : ty:: Predicate < ' tcx >
4846}
4947
5048impl < ' a , ' gcx , ' tcx > TraitErrorKey < ' tcx > {
5149 fn from_error ( infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
52- e : & FulfillmentError < ' tcx > ,
53- warning_node_id : Option < ast:: NodeId > ) -> Self {
50+ e : & FulfillmentError < ' tcx > ) -> Self {
5451 let predicate =
5552 infcx. resolve_type_vars_if_possible ( & e. obligation . predicate ) ;
5653 TraitErrorKey {
5754 span : e. obligation . cause . span ,
58- predicate : infcx. tcx . erase_regions ( & predicate) ,
59- warning_node_id : warning_node_id
55+ predicate : infcx. tcx . erase_regions ( & predicate)
6056 }
6157 }
6258}
6359
6460impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
6561 pub fn report_fulfillment_errors ( & self , errors : & Vec < FulfillmentError < ' tcx > > ) {
6662 for error in errors {
67- self . report_fulfillment_error ( error, None ) ;
68- }
69- }
70-
71- pub fn report_fulfillment_errors_as_warnings ( & self ,
72- errors : & Vec < FulfillmentError < ' tcx > > ,
73- node_id : ast:: NodeId ) {
74- for error in errors {
75- self . report_fulfillment_error ( error, Some ( node_id) ) ;
63+ self . report_fulfillment_error ( error) ;
7664 }
7765 }
7866
7967 fn report_fulfillment_error ( & self ,
80- error : & FulfillmentError < ' tcx > ,
81- warning_node_id : Option < ast:: NodeId > ) {
82- let error_key = TraitErrorKey :: from_error ( self , error, warning_node_id) ;
68+ error : & FulfillmentError < ' tcx > ) {
69+ let error_key = TraitErrorKey :: from_error ( self , error) ;
8370 debug ! ( "report_fulfillment_errors({:?}) - key={:?}" ,
8471 error, error_key) ;
8572 if !self . reported_trait_errors . borrow_mut ( ) . insert ( error_key) {
@@ -88,10 +75,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
8875 }
8976 match error. code {
9077 FulfillmentErrorCode :: CodeSelectionError ( ref e) => {
91- self . report_selection_error ( & error. obligation , e, warning_node_id ) ;
78+ self . report_selection_error ( & error. obligation , e) ;
9279 }
9380 FulfillmentErrorCode :: CodeProjectionError ( ref e) => {
94- self . report_projection_error ( & error. obligation , e, warning_node_id ) ;
81+ self . report_projection_error ( & error. obligation , e) ;
9582 }
9683 FulfillmentErrorCode :: CodeAmbiguity => {
9784 self . maybe_report_ambiguity ( & error. obligation ) ;
@@ -101,25 +88,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10188
10289 fn report_projection_error ( & self ,
10390 obligation : & PredicateObligation < ' tcx > ,
104- error : & MismatchedProjectionTypes < ' tcx > ,
105- warning_node_id : Option < ast:: NodeId > )
91+ error : & MismatchedProjectionTypes < ' tcx > )
10692 {
10793 let predicate =
10894 self . resolve_type_vars_if_possible ( & obligation. predicate ) ;
10995
11096 if predicate. references_error ( ) {
11197 return
11298 }
113- if let Some ( warning_node_id) = warning_node_id {
114- self . tcx . sess . add_lint (
115- :: lint:: builtin:: UNSIZED_IN_TUPLE ,
116- warning_node_id,
117- obligation. cause . span ,
118- format ! ( "type mismatch resolving `{}`: {}" ,
119- predicate,
120- error. err) ) ;
121- return
122- }
99+
123100 self . probe ( |_| {
124101 let origin = TypeOrigin :: Misc ( obligation. cause . span ) ;
125102 let err_buf;
@@ -442,8 +419,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
442419
443420 pub fn report_selection_error ( & self ,
444421 obligation : & PredicateObligation < ' tcx > ,
445- error : & SelectionError < ' tcx > ,
446- warning_node_id : Option < ast:: NodeId > )
422+ error : & SelectionError < ' tcx > )
447423 {
448424 let span = obligation. cause . span ;
449425 let mut err = match * error {
@@ -466,16 +442,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
466442 } else {
467443 let trait_ref = trait_predicate. to_poly_trait_ref ( ) ;
468444
469- if let Some ( warning_node_id) = warning_node_id {
470- self . tcx . sess . add_lint (
471- :: lint:: builtin:: UNSIZED_IN_TUPLE ,
472- warning_node_id,
473- obligation. cause . span ,
474- format ! ( "the trait bound `{}` is not satisfied" ,
475- trait_ref. to_predicate( ) ) ) ;
476- return ;
477- }
478-
479445 let mut err = struct_span_err ! ( self . tcx. sess, span, E0277 ,
480446 "the trait bound `{}` is not satisfied" ,
481447 trait_ref. to_predicate( ) ) ;
@@ -541,15 +507,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
541507
542508 ty:: Predicate :: ObjectSafe ( trait_def_id) => {
543509 let violations = self . tcx . object_safety_violations ( trait_def_id) ;
544- let err = self . tcx . report_object_safety_error ( span,
545- trait_def_id,
546- warning_node_id,
547- violations) ;
548- if let Some ( err) = err {
549- err
550- } else {
551- return ;
552- }
510+ self . tcx . report_object_safety_error ( span,
511+ trait_def_id,
512+ violations)
553513 }
554514
555515 ty:: Predicate :: ClosureKind ( closure_def_id, kind) => {
@@ -577,13 +537,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
577537 // (which may fail).
578538 span_bug ! ( span, "WF predicate not satisfied for {:?}" , ty) ;
579539 }
580-
581- ty:: Predicate :: Rfc1592 ( ref data) => {
582- span_bug ! (
583- obligation. cause. span,
584- "RFC1592 predicate not satisfied for {:?}" ,
585- data) ;
586- }
587540 }
588541 }
589542 }
@@ -605,14 +558,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
605558
606559 TraitNotObjectSafe ( did) => {
607560 let violations = self . tcx . object_safety_violations ( did) ;
608- let err = self . tcx . report_object_safety_error ( span, did,
609- warning_node_id,
610- violations) ;
611- if let Some ( err) = err {
612- err
613- } else {
614- return ;
615- }
561+ self . tcx . report_object_safety_error ( span, did,
562+ violations)
616563 }
617564 } ;
618565 self . note_obligation_cause ( & mut err, obligation) ;
@@ -640,24 +587,17 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
640587 pub fn report_object_safety_error ( self ,
641588 span : Span ,
642589 trait_def_id : DefId ,
643- warning_node_id : Option < ast:: NodeId > ,
644590 violations : Vec < ObjectSafetyViolation > )
645- -> Option < DiagnosticBuilder < ' tcx > >
591+ -> DiagnosticBuilder < ' tcx >
646592 {
647- let mut err = match warning_node_id {
648- Some ( _) => None ,
649- None => {
650- let trait_str = self . item_path_str ( trait_def_id) ;
651- let mut db = struct_span_err ! (
652- self . sess, span, E0038 ,
653- "the trait `{}` cannot be made into an object" ,
654- trait_str) ;
655- db. span_label ( span,
656- & format ! ( "the trait `{}` cannot be made \
657- into an object", trait_str) ) ;
658- Some ( db)
659- }
660- } ;
593+ let trait_str = self . item_path_str ( trait_def_id) ;
594+ let mut err = struct_span_err ! (
595+ self . sess, span, E0038 ,
596+ "the trait `{}` cannot be made into an object" ,
597+ trait_str) ;
598+ err. span_label ( span, & format ! (
599+ "the trait `{}` cannot be made into an object" , trait_str
600+ ) ) ;
661601
662602 let mut reported_violations = FnvHashSet ( ) ;
663603 for violation in violations {
@@ -697,19 +637,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
697637 & buf
698638 }
699639 } ;
700- match ( warning_node_id, & mut err) {
701- ( Some ( node_id) , & mut None ) => {
702- self . sess . add_lint (
703- :: lint:: builtin:: OBJECT_UNSAFE_FRAGMENT ,
704- node_id,
705- span,
706- note. to_string ( ) ) ;
707- }
708- ( None , & mut Some ( ref mut err) ) => {
709- err. note ( note) ;
710- }
711- _ => unreachable ! ( )
712- }
640+ err. note ( note) ;
713641 }
714642 err
715643 }
0 commit comments