@@ -313,7 +313,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
313
313
314
314
/// Instantiates the path for the given trait reference, assuming that it's
315
315
/// bound to a valid trait type. Returns the def_id for the defining trait.
316
- /// Fails if the type is a type other than a trait type.
316
+ /// The type _cannot_ be a type other than a trait type.
317
317
///
318
318
/// If the `projections` argument is `None`, then assoc type bindings like `Foo<T=X>`
319
319
/// are disallowed. Otherwise, they are pushed onto the vector given.
@@ -331,6 +331,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
331
331
trait_ref. path . segments . last ( ) . unwrap ( ) )
332
332
}
333
333
334
+ /// Get the DefId of the given trait ref. It _must_ actually be a trait.
334
335
fn trait_def_id ( & self , trait_ref : & hir:: TraitRef ) -> DefId {
335
336
let path = & trait_ref. path ;
336
337
match path. def {
@@ -339,13 +340,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
339
340
Def :: Err => {
340
341
self . tcx ( ) . sess . fatal ( "cannot continue compilation due to previous error" ) ;
341
342
}
342
- _ => {
343
- span_fatal ! ( self . tcx( ) . sess, path. span, E0245 , "`{}` is not a trait" ,
344
- self . tcx( ) . hir. node_to_pretty_string( trait_ref. ref_id) ) ;
345
- }
343
+ _ => unreachable ! ( ) ,
346
344
}
347
345
}
348
346
347
+ /// The given `trait_ref` must actually be trait.
349
348
pub ( super ) fn instantiate_poly_trait_ref_inner ( & self ,
350
349
trait_ref : & hir:: TraitRef ,
351
350
self_ty : Ty < ' tcx > ,
0 commit comments