@@ -956,9 +956,20 @@ pub enum DrawError {
956
956
}
957
957
958
958
impl Error for DrawError {
959
- fn description ( & self ) -> & str {
959
+ fn source ( & self ) -> Option < & ( dyn Error + ' static ) > {
960
960
use self :: DrawError :: * ;
961
961
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 {
962
973
NoDepthBuffer =>
963
974
"A depth function has been requested but no depth buffer is available" ,
964
975
AttributeTypeMismatch =>
@@ -1013,55 +1024,40 @@ impl Error for DrawError {
1013
1024
"Restarting indices (multiple objects per draw call) is not supported by the backend" ,
1014
1025
ClipPlaneIndexOutOfBounds =>
1015
1026
"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 } =>
1034
1030
write ! (
1035
1031
fmt,
1036
1032
"{}, got: {:?}, expected: {:?}" ,
1037
- self . description ( ) ,
1033
+ desc ,
1038
1034
name,
1039
1035
expected,
1040
1036
) ,
1041
- UniformBufferToValue { ref name } =>
1037
+ UniformBufferToValue { name } =>
1042
1038
write ! (
1043
1039
fmt,
1044
1040
"{}: {}" ,
1045
- self . description ( ) ,
1041
+ desc ,
1046
1042
name,
1047
1043
) ,
1048
- UniformValueToBlock { ref name } =>
1044
+ UniformValueToBlock { name } =>
1049
1045
write ! (
1050
1046
fmt,
1051
1047
"{}: {}" ,
1052
- self . description ( ) ,
1048
+ desc ,
1053
1049
name,
1054
1050
) ,
1055
- UniformBlockLayoutMismatch { ref name, ref err } =>
1051
+ UniformBlockLayoutMismatch { name, err } =>
1056
1052
write ! (
1057
1053
fmt,
1058
1054
"{}: {}, caused by {}" ,
1059
- self . description ( ) ,
1055
+ desc ,
1060
1056
name,
1061
1057
err,
1062
1058
) ,
1063
1059
_ =>
1064
- write ! ( fmt, "{}" , self . description ( ) ) ,
1060
+ fmt. write_str ( desc ) ,
1065
1061
}
1066
1062
}
1067
1063
}
@@ -1087,21 +1083,18 @@ pub enum SwapBuffersError {
1087
1083
AlreadySwapped ,
1088
1084
}
1089
1085
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 > {
1092
1090
use self :: SwapBuffersError :: * ;
1093
- match * self {
1091
+ let desc = match * self {
1094
1092
ContextLost =>
1095
1093
"the OpenGL context has been lost and needs to be recreated" ,
1096
1094
AlreadySwapped =>
1097
1095
"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)
1105
1098
}
1106
1099
}
1107
1100
@@ -1256,16 +1249,11 @@ pub struct IncompatibleOpenGl(pub String);
1256
1249
1257
1250
impl fmt:: Display for IncompatibleOpenGl {
1258
1251
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" )
1260
1253
}
1261
1254
}
1262
1255
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 { }
1269
1257
1270
1258
#[ allow( dead_code) ]
1271
1259
#[ inline]
0 commit comments