@@ -36,7 +36,6 @@ use syntax::attr::{AttributeMethods, AttrMetaMethods};
36
36
37
37
#[ derive( Debug , PartialEq , Eq , Hash ) ]
38
38
pub struct TraitErrorKey < ' tcx > {
39
- is_warning : bool ,
40
39
span : Span ,
41
40
predicate : ty:: Predicate < ' tcx >
42
41
}
@@ -47,7 +46,6 @@ impl<'tcx> TraitErrorKey<'tcx> {
47
46
let predicate =
48
47
infcx. resolve_type_vars_if_possible ( & e. obligation . predicate ) ;
49
48
TraitErrorKey {
50
- is_warning : is_warning ( & e. obligation ) ,
51
49
span : e. obligation . cause . span ,
52
50
predicate : infcx. tcx . erase_regions ( & predicate)
53
51
}
@@ -83,10 +81,6 @@ fn report_fulfillment_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
83
81
}
84
82
}
85
83
86
- fn is_warning < T > ( obligation : & Obligation < T > ) -> bool {
87
- obligation. cause . code . is_rfc1214 ( )
88
- }
89
-
90
84
pub fn report_projection_error < ' a , ' tcx > ( infcx : & InferCtxt < ' a , ' tcx > ,
91
85
obligation : & PredicateObligation < ' tcx > ,
92
86
error : & MismatchedProjectionTypes < ' tcx > )
@@ -100,8 +94,8 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
100
94
// then $X will be unified with TyError, but the error still needs to be
101
95
// reported.
102
96
if !infcx. tcx . sess . has_errors ( ) || !predicate. references_error ( ) {
103
- span_err_or_warn ! (
104
- is_warning ( obligation ) , infcx. tcx. sess, obligation. cause. span, E0271 ,
97
+ span_err ! (
98
+ infcx. tcx. sess, obligation. cause. span, E0271 ,
105
99
"type mismatch resolving `{}`: {}" ,
106
100
predicate,
107
101
error. err) ;
@@ -208,12 +202,11 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
208
202
obligation : & PredicateObligation < ' tcx > ,
209
203
error : & SelectionError < ' tcx > )
210
204
{
211
- let is_warning = is_warning ( obligation) ;
212
205
match * error {
213
206
SelectionError :: Unimplemented => {
214
207
if let ObligationCauseCode :: CompareImplMethodObligation = obligation. cause . code {
215
- span_err_or_warn ! (
216
- is_warning , infcx. tcx. sess, obligation. cause. span, E0276 ,
208
+ span_err ! (
209
+ infcx. tcx. sess, obligation. cause. span, E0276 ,
217
210
"the requirement `{}` appears on the impl \
218
211
method but not on the corresponding trait method",
219
212
obligation. predicate) ;
@@ -225,8 +218,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
225
218
226
219
if !infcx. tcx . sess . has_errors ( ) || !trait_predicate. references_error ( ) {
227
220
let trait_ref = trait_predicate. to_poly_trait_ref ( ) ;
228
- span_err_or_warn ! (
229
- is_warning , infcx. tcx. sess, obligation. cause. span, E0277 ,
221
+ span_err ! (
222
+ infcx. tcx. sess, obligation. cause. span, E0277 ,
230
223
"the trait `{}` is not implemented for the type `{}`" ,
231
224
trait_ref, trait_ref. self_ty( ) ) ;
232
225
@@ -245,8 +238,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
245
238
let predicate = infcx. resolve_type_vars_if_possible ( predicate) ;
246
239
let err = infcx. equality_predicate ( obligation. cause . span ,
247
240
& predicate) . err ( ) . unwrap ( ) ;
248
- span_err_or_warn ! (
249
- is_warning , infcx. tcx. sess, obligation. cause. span, E0278 ,
241
+ span_err ! (
242
+ infcx. tcx. sess, obligation. cause. span, E0278 ,
250
243
"the requirement `{}` is not satisfied (`{}`)" ,
251
244
predicate,
252
245
err) ;
@@ -257,8 +250,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
257
250
let predicate = infcx. resolve_type_vars_if_possible ( predicate) ;
258
251
let err = infcx. region_outlives_predicate ( obligation. cause . span ,
259
252
& predicate) . err ( ) . unwrap ( ) ;
260
- span_err_or_warn ! (
261
- is_warning , infcx. tcx. sess, obligation. cause. span, E0279 ,
253
+ span_err ! (
254
+ infcx. tcx. sess, obligation. cause. span, E0279 ,
262
255
"the requirement `{}` is not satisfied (`{}`)" ,
263
256
predicate,
264
257
err) ;
@@ -268,8 +261,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
268
261
ty:: Predicate :: Projection ( ..) | ty:: Predicate :: TypeOutlives ( ..) => {
269
262
let predicate =
270
263
infcx. resolve_type_vars_if_possible ( & obligation. predicate ) ;
271
- span_err_or_warn ! (
272
- is_warning , infcx. tcx. sess, obligation. cause. span, E0280 ,
264
+ span_err ! (
265
+ infcx. tcx. sess, obligation. cause. span, E0280 ,
273
266
"the requirement `{}` is not satisfied" ,
274
267
predicate) ;
275
268
note_obligation_cause ( infcx, obligation) ;
@@ -281,8 +274,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
281
274
report_object_safety_error ( infcx. tcx ,
282
275
obligation. cause . span ,
283
276
trait_def_id,
284
- violations,
285
- is_warning) ;
277
+ violations) ;
286
278
note_obligation_cause ( infcx, obligation) ;
287
279
}
288
280
@@ -304,8 +296,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
304
296
let expected_trait_ref = infcx. resolve_type_vars_if_possible ( & * expected_trait_ref) ;
305
297
let actual_trait_ref = infcx. resolve_type_vars_if_possible ( & * actual_trait_ref) ;
306
298
if !actual_trait_ref. self_ty ( ) . references_error ( ) {
307
- span_err_or_warn ! (
308
- is_warning , infcx. tcx. sess, obligation. cause. span, E0281 ,
299
+ span_err ! (
300
+ infcx. tcx. sess, obligation. cause. span, E0281 ,
309
301
"type mismatch: the type `{}` implements the trait `{}`, \
310
302
but the trait `{}` is required ({})",
311
303
expected_trait_ref. self_ty( ) ,
@@ -318,8 +310,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
318
310
319
311
TraitNotObjectSafe ( did) => {
320
312
let violations = object_safety_violations ( infcx. tcx , did) ;
321
- report_object_safety_error ( infcx. tcx , obligation. cause . span , did,
322
- violations, is_warning) ;
313
+ report_object_safety_error ( infcx. tcx , obligation. cause . span , did, violations) ;
323
314
note_obligation_cause ( infcx, obligation) ;
324
315
}
325
316
}
@@ -328,11 +319,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
328
319
pub fn report_object_safety_error < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
329
320
span : Span ,
330
321
trait_def_id : DefId ,
331
- violations : Vec < ObjectSafetyViolation > ,
332
- is_warning : bool )
322
+ violations : Vec < ObjectSafetyViolation > )
333
323
{
334
- span_err_or_warn ! (
335
- is_warning , tcx. sess, span, E0038 ,
324
+ span_err ! (
325
+ tcx. sess, span, E0038 ,
336
326
"the trait `{}` cannot be made into an object" ,
337
327
tcx. item_path_str( trait_def_id) ) ;
338
328
@@ -402,7 +392,17 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
402
392
let self_ty = trait_ref. self_ty ( ) ;
403
393
let all_types = & trait_ref. substs ( ) . types ;
404
394
if all_types. references_error ( ) {
405
- } else if all_types. needs_infer ( ) {
395
+ } else {
396
+ // Typically, this ambiguity should only happen if
397
+ // there are unresolved type inference variables
398
+ // (otherwise it would suggest a coherence
399
+ // failure). But given #21974 that is not necessarily
400
+ // the case -- we can have multiple where clauses that
401
+ // are only distinguished by a region, which results
402
+ // in an ambiguity even when all types are fully
403
+ // known, since we don't dispatch based on region
404
+ // relationships.
405
+
406
406
// This is kind of a hack: it frequently happens that some earlier
407
407
// error prevents types from being fully inferred, and then we get
408
408
// a bunch of uninteresting errors saying something like "<generic
@@ -430,16 +430,6 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
430
430
note_obligation_cause ( infcx, obligation) ;
431
431
}
432
432
}
433
- } else if !infcx. tcx . sess . has_errors ( ) {
434
- // Ambiguity. Coherence should have reported an error.
435
- infcx. tcx . sess . span_bug (
436
- obligation. cause . span ,
437
- & format ! (
438
- "coherence failed to report ambiguity: \
439
- cannot locate the impl of the trait `{}` for \
440
- the type `{}`",
441
- trait_ref,
442
- self_ty) ) ;
443
433
}
444
434
}
445
435
@@ -491,10 +481,6 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
491
481
let tcx = infcx. tcx ;
492
482
match * cause_code {
493
483
ObligationCauseCode :: MiscObligation => { }
494
- ObligationCauseCode :: RFC1214 ( ref subcode) => {
495
- tcx. sess . note_rfc_1214 ( cause_span) ;
496
- note_obligation_cause_code ( infcx, predicate, cause_span, subcode) ;
497
- }
498
484
ObligationCauseCode :: SliceOrArrayElem => {
499
485
tcx. sess . fileline_note (
500
486
cause_span,
0 commit comments