@@ -36,50 +36,37 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
36
36
37
37
use std:: cmp;
38
38
use std:: fmt;
39
- use syntax:: ast;
40
39
use syntax_pos:: Span ;
41
40
use errors:: DiagnosticBuilder ;
42
41
43
42
#[ derive( Debug , PartialEq , Eq , Hash ) ]
44
43
pub struct TraitErrorKey < ' tcx > {
45
44
span : Span ,
46
- warning_node_id : Option < ast:: NodeId > ,
47
45
predicate : ty:: Predicate < ' tcx >
48
46
}
49
47
50
48
impl < ' a , ' gcx , ' tcx > TraitErrorKey < ' tcx > {
51
49
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 {
54
51
let predicate =
55
52
infcx. resolve_type_vars_if_possible ( & e. obligation . predicate ) ;
56
53
TraitErrorKey {
57
54
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)
60
56
}
61
57
}
62
58
}
63
59
64
60
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
65
61
pub fn report_fulfillment_errors ( & self , errors : & Vec < FulfillmentError < ' tcx > > ) {
66
62
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) ;
76
64
}
77
65
}
78
66
79
67
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) ;
83
70
debug ! ( "report_fulfillment_errors({:?}) - key={:?}" ,
84
71
error, error_key) ;
85
72
if !self . reported_trait_errors . borrow_mut ( ) . insert ( error_key) {
@@ -88,10 +75,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
88
75
}
89
76
match error. code {
90
77
FulfillmentErrorCode :: CodeSelectionError ( ref e) => {
91
- self . report_selection_error ( & error. obligation , e, warning_node_id ) ;
78
+ self . report_selection_error ( & error. obligation , e) ;
92
79
}
93
80
FulfillmentErrorCode :: CodeProjectionError ( ref e) => {
94
- self . report_projection_error ( & error. obligation , e, warning_node_id ) ;
81
+ self . report_projection_error ( & error. obligation , e) ;
95
82
}
96
83
FulfillmentErrorCode :: CodeAmbiguity => {
97
84
self . maybe_report_ambiguity ( & error. obligation ) ;
@@ -101,25 +88,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
101
88
102
89
fn report_projection_error ( & self ,
103
90
obligation : & PredicateObligation < ' tcx > ,
104
- error : & MismatchedProjectionTypes < ' tcx > ,
105
- warning_node_id : Option < ast:: NodeId > )
91
+ error : & MismatchedProjectionTypes < ' tcx > )
106
92
{
107
93
let predicate =
108
94
self . resolve_type_vars_if_possible ( & obligation. predicate ) ;
109
95
110
96
if predicate. references_error ( ) {
111
97
return
112
98
}
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
+
123
100
self . probe ( |_| {
124
101
let origin = TypeOrigin :: Misc ( obligation. cause . span ) ;
125
102
let err_buf;
@@ -442,8 +419,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
442
419
443
420
pub fn report_selection_error ( & self ,
444
421
obligation : & PredicateObligation < ' tcx > ,
445
- error : & SelectionError < ' tcx > ,
446
- warning_node_id : Option < ast:: NodeId > )
422
+ error : & SelectionError < ' tcx > )
447
423
{
448
424
let span = obligation. cause . span ;
449
425
let mut err = match * error {
@@ -466,16 +442,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
466
442
} else {
467
443
let trait_ref = trait_predicate. to_poly_trait_ref ( ) ;
468
444
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
-
479
445
let mut err = struct_span_err ! ( self . tcx. sess, span, E0277 ,
480
446
"the trait bound `{}` is not satisfied" ,
481
447
trait_ref. to_predicate( ) ) ;
@@ -541,15 +507,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
541
507
542
508
ty:: Predicate :: ObjectSafe ( trait_def_id) => {
543
509
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)
553
513
}
554
514
555
515
ty:: Predicate :: ClosureKind ( closure_def_id, kind) => {
@@ -577,13 +537,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
577
537
// (which may fail).
578
538
span_bug ! ( span, "WF predicate not satisfied for {:?}" , ty) ;
579
539
}
580
-
581
- ty:: Predicate :: Rfc1592 ( ref data) => {
582
- span_bug ! (
583
- obligation. cause. span,
584
- "RFC1592 predicate not satisfied for {:?}" ,
585
- data) ;
586
- }
587
540
}
588
541
}
589
542
}
@@ -605,14 +558,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
605
558
606
559
TraitNotObjectSafe ( did) => {
607
560
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)
616
563
}
617
564
} ;
618
565
self . note_obligation_cause ( & mut err, obligation) ;
@@ -640,24 +587,17 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
640
587
pub fn report_object_safety_error ( self ,
641
588
span : Span ,
642
589
trait_def_id : DefId ,
643
- warning_node_id : Option < ast:: NodeId > ,
644
590
violations : Vec < ObjectSafetyViolation > )
645
- -> Option < DiagnosticBuilder < ' tcx > >
591
+ -> DiagnosticBuilder < ' tcx >
646
592
{
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
+ ) ) ;
661
601
662
602
let mut reported_violations = FnvHashSet ( ) ;
663
603
for violation in violations {
@@ -697,19 +637,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
697
637
& buf
698
638
}
699
639
} ;
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) ;
713
641
}
714
642
err
715
643
}
0 commit comments