@@ -67,6 +67,7 @@ pub enum TypeError<'tcx> {
6767 ) ,
6868 ObjectUnsafeCoercion ( DefId ) ,
6969 ConstMismatch ( ExpectedFound < & ' tcx ty:: Const < ' tcx > > ) ,
70+ ConstMismatchTooGeneric ( ExpectedFound < & ' tcx ty:: Const < ' tcx > > , Option < String > ) ,
7071
7172 IntrinsicCast ,
7273 /// Safe `#[target_feature]` functions are not assignable to safe function pointers.
@@ -201,6 +202,12 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
201202 ConstMismatch ( ref values) => {
202203 write ! ( f, "expected `{}`, found `{}`" , values. expected, values. found)
203204 }
205+ ConstMismatchTooGeneric ( ref values, ref suggestion) => match suggestion {
206+ Some ( sugg) => {
207+ write ! ( f, "expected `{}`, found `{}`" , values. expected, sugg)
208+ }
209+ None => write ! ( f, "expected `{}`, found `{}`" , values. expected, values. found) ,
210+ } ,
204211 IntrinsicCast => write ! ( f, "cannot coerce intrinsics to function pointers" ) ,
205212 TargetFeatureCast ( _) => write ! (
206213 f,
@@ -233,6 +240,7 @@ impl<'tcx> TypeError<'tcx> {
233240 | ProjectionMismatched ( _)
234241 | ExistentialMismatch ( _)
235242 | ConstMismatch ( _)
243+ | ConstMismatchTooGeneric ( _, _)
236244 | IntrinsicCast
237245 | ObjectUnsafeCoercion ( _) => true ,
238246 }
0 commit comments