@@ -956,9 +956,20 @@ pub enum DrawError {
956956}
957957
958958impl Error for DrawError {
959- fn description ( & self ) -> & str {
959+ fn source ( & self ) -> Option < & ( dyn Error + ' static ) > {
960960 use self :: DrawError :: * ;
961961 match * self {
962+ UniformBlockLayoutMismatch { ref err, .. } => Some ( err) ,
963+ _ => None ,
964+ }
965+ }
966+ }
967+
968+
969+ impl fmt:: Display for DrawError {
970+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
971+ use self :: DrawError :: * ;
972+ let desc = match self {
962973 NoDepthBuffer =>
963974 "A depth function has been requested but no depth buffer is available" ,
964975 AttributeTypeMismatch =>
@@ -1013,55 +1024,40 @@ impl Error for DrawError {
10131024 "Restarting indices (multiple objects per draw call) is not supported by the backend" ,
10141025 ClipPlaneIndexOutOfBounds =>
10151026 "Tried to enable a clip plane that does not exist."
1016- }
1017- }
1018-
1019- fn source ( & self ) -> Option < & ( dyn Error + ' static ) > {
1020- use self :: DrawError :: * ;
1021- match * self {
1022- UniformBlockLayoutMismatch { ref err, .. } => Some ( err) ,
1023- _ => None ,
1024- }
1025- }
1026- }
1027-
1028-
1029- impl fmt:: Display for DrawError {
1030- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
1031- use self :: DrawError :: * ;
1032- match * self {
1033- UniformTypeMismatch { ref name, ref expected } =>
1027+ } ;
1028+ match self {
1029+ UniformTypeMismatch { name, expected } =>
10341030 write ! (
10351031 fmt,
10361032 "{}, got: {:?}, expected: {:?}" ,
1037- self . description ( ) ,
1033+ desc ,
10381034 name,
10391035 expected,
10401036 ) ,
1041- UniformBufferToValue { ref name } =>
1037+ UniformBufferToValue { name } =>
10421038 write ! (
10431039 fmt,
10441040 "{}: {}" ,
1045- self . description ( ) ,
1041+ desc ,
10461042 name,
10471043 ) ,
1048- UniformValueToBlock { ref name } =>
1044+ UniformValueToBlock { name } =>
10491045 write ! (
10501046 fmt,
10511047 "{}: {}" ,
1052- self . description ( ) ,
1048+ desc ,
10531049 name,
10541050 ) ,
1055- UniformBlockLayoutMismatch { ref name, ref err } =>
1051+ UniformBlockLayoutMismatch { name, err } =>
10561052 write ! (
10571053 fmt,
10581054 "{}: {}, caused by {}" ,
1059- self . description ( ) ,
1055+ desc ,
10601056 name,
10611057 err,
10621058 ) ,
10631059 _ =>
1064- write ! ( fmt, "{}" , self . description ( ) ) ,
1060+ fmt. write_str ( desc ) ,
10651061 }
10661062 }
10671063}
@@ -1087,21 +1083,18 @@ pub enum SwapBuffersError {
10871083 AlreadySwapped ,
10881084}
10891085
1090- impl Error for SwapBuffersError {
1091- fn description ( & self ) -> & str {
1086+ impl Error for SwapBuffersError { }
1087+
1088+ impl fmt:: Display for SwapBuffersError {
1089+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
10921090 use self :: SwapBuffersError :: * ;
1093- match * self {
1091+ let desc = match * self {
10941092 ContextLost =>
10951093 "the OpenGL context has been lost and needs to be recreated" ,
10961094 AlreadySwapped =>
10971095 "the buffers have already been swapped" ,
1098- }
1099- }
1100- }
1101-
1102- impl fmt:: Display for SwapBuffersError {
1103- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
1104- write ! ( fmt, "{}" , self . description( ) )
1096+ } ;
1097+ fmt. write_str ( desc)
11051098 }
11061099}
11071100
@@ -1256,16 +1249,11 @@ pub struct IncompatibleOpenGl(pub String);
12561249
12571250impl fmt:: Display for IncompatibleOpenGl {
12581251 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1259- write ! ( fmt, "{}" , self . description ( ) )
1252+ fmt. write_str ( "The OpenGL implementation is too old to work with glium" )
12601253 }
12611254}
12621255
1263- impl Error for IncompatibleOpenGl {
1264- #[ inline]
1265- fn description ( & self ) -> & str {
1266- "The OpenGL implementation is too old to work with glium"
1267- }
1268- }
1256+ impl Error for IncompatibleOpenGl { }
12691257
12701258#[ allow( dead_code) ]
12711259#[ inline]
0 commit comments