Reverting changes to Result's Display impl
This commit is contained in:
parent
584a3bb5da
commit
d52f2c9b3e
|
@ -41317,28 +41317,73 @@ impl Result {
|
||||||
#[doc = "A requested pool allocation has failed due to fragmentation of the pool\'s memory"]
|
#[doc = "A requested pool allocation has failed due to fragmentation of the pool\'s memory"]
|
||||||
pub const ERROR_FRAGMENTED_POOL: Self = Result(-12);
|
pub const ERROR_FRAGMENTED_POOL: Self = Result(-12);
|
||||||
}
|
}
|
||||||
impl std::error::Error for Result {}
|
impl ::std::error::Error for Result {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
let name = match *self {
|
||||||
|
Result::SUCCESS => Some("Command completed successfully"),
|
||||||
|
Result::NOT_READY => Some("A fence or query has not yet completed"),
|
||||||
|
Result::TIMEOUT => Some("A wait operation has not completed in the specified time"),
|
||||||
|
Result::EVENT_SET => Some("An event is signaled"),
|
||||||
|
Result::EVENT_RESET => Some("An event is unsignaled"),
|
||||||
|
Result::INCOMPLETE => Some("A return array was too small for the result"),
|
||||||
|
Result::ERROR_OUT_OF_HOST_MEMORY => Some("A host memory allocation has failed"),
|
||||||
|
Result::ERROR_OUT_OF_DEVICE_MEMORY => Some("A device memory allocation has failed"),
|
||||||
|
Result::ERROR_INITIALIZATION_FAILED => Some("Initialization of a object has failed"),
|
||||||
|
Result::ERROR_DEVICE_LOST => {
|
||||||
|
Some("The logical device has been lost. See <<devsandqueues-lost-device>>")
|
||||||
|
}
|
||||||
|
Result::ERROR_MEMORY_MAP_FAILED => Some("Mapping of a memory object has failed"),
|
||||||
|
Result::ERROR_LAYER_NOT_PRESENT => Some("Layer specified does not exist"),
|
||||||
|
Result::ERROR_EXTENSION_NOT_PRESENT => Some("Extension specified does not exist"),
|
||||||
|
Result::ERROR_FEATURE_NOT_PRESENT => {
|
||||||
|
Some("Requested feature is not available on this device")
|
||||||
|
}
|
||||||
|
Result::ERROR_INCOMPATIBLE_DRIVER => Some("Unable to find a Vulkan driver"),
|
||||||
|
Result::ERROR_TOO_MANY_OBJECTS => {
|
||||||
|
Some("Too many objects of the type have already been created")
|
||||||
|
}
|
||||||
|
Result::ERROR_FORMAT_NOT_SUPPORTED => {
|
||||||
|
Some("Requested format is not supported on this device")
|
||||||
|
}
|
||||||
|
Result::ERROR_FRAGMENTED_POOL => Some(
|
||||||
|
"A requested pool allocation has failed due to fragmentation of the pool\'s memory",
|
||||||
|
),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
name.unwrap_or("unknown error")
|
||||||
|
}
|
||||||
|
}
|
||||||
impl fmt::Display for Result {
|
impl fmt::Display for Result {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let name = match *self {
|
let name = match *self {
|
||||||
Result::SUCCESS => Some(stringify!(SUCCESS)),
|
Result::SUCCESS => Some("Command completed successfully"),
|
||||||
Result::NOT_READY => Some(stringify!(NOT_READY)),
|
Result::NOT_READY => Some("A fence or query has not yet completed"),
|
||||||
Result::TIMEOUT => Some(stringify!(TIMEOUT)),
|
Result::TIMEOUT => Some("A wait operation has not completed in the specified time"),
|
||||||
Result::EVENT_SET => Some(stringify!(EVENT_SET)),
|
Result::EVENT_SET => Some("An event is signaled"),
|
||||||
Result::EVENT_RESET => Some(stringify!(EVENT_RESET)),
|
Result::EVENT_RESET => Some("An event is unsignaled"),
|
||||||
Result::INCOMPLETE => Some(stringify!(INCOMPLETE)),
|
Result::INCOMPLETE => Some("A return array was too small for the result"),
|
||||||
Result::ERROR_OUT_OF_HOST_MEMORY => Some(stringify!(ERROR_OUT_OF_HOST_MEMORY)),
|
Result::ERROR_OUT_OF_HOST_MEMORY => Some("A host memory allocation has failed"),
|
||||||
Result::ERROR_OUT_OF_DEVICE_MEMORY => Some(stringify!(ERROR_OUT_OF_DEVICE_MEMORY)),
|
Result::ERROR_OUT_OF_DEVICE_MEMORY => Some("A device memory allocation has failed"),
|
||||||
Result::ERROR_INITIALIZATION_FAILED => Some(stringify!(ERROR_INITIALIZATION_FAILED)),
|
Result::ERROR_INITIALIZATION_FAILED => Some("Initialization of a object has failed"),
|
||||||
Result::ERROR_DEVICE_LOST => Some(stringify!(ERROR_DEVICE_LOST)),
|
Result::ERROR_DEVICE_LOST => {
|
||||||
Result::ERROR_MEMORY_MAP_FAILED => Some(stringify!(ERROR_MEMORY_MAP_FAILED)),
|
Some("The logical device has been lost. See <<devsandqueues-lost-device>>")
|
||||||
Result::ERROR_LAYER_NOT_PRESENT => Some(stringify!(ERROR_LAYER_NOT_PRESENT)),
|
}
|
||||||
Result::ERROR_EXTENSION_NOT_PRESENT => Some(stringify!(ERROR_EXTENSION_NOT_PRESENT)),
|
Result::ERROR_MEMORY_MAP_FAILED => Some("Mapping of a memory object has failed"),
|
||||||
Result::ERROR_FEATURE_NOT_PRESENT => Some(stringify!(ERROR_FEATURE_NOT_PRESENT)),
|
Result::ERROR_LAYER_NOT_PRESENT => Some("Layer specified does not exist"),
|
||||||
Result::ERROR_INCOMPATIBLE_DRIVER => Some(stringify!(ERROR_INCOMPATIBLE_DRIVER)),
|
Result::ERROR_EXTENSION_NOT_PRESENT => Some("Extension specified does not exist"),
|
||||||
Result::ERROR_TOO_MANY_OBJECTS => Some(stringify!(ERROR_TOO_MANY_OBJECTS)),
|
Result::ERROR_FEATURE_NOT_PRESENT => {
|
||||||
Result::ERROR_FORMAT_NOT_SUPPORTED => Some(stringify!(ERROR_FORMAT_NOT_SUPPORTED)),
|
Some("Requested feature is not available on this device")
|
||||||
Result::ERROR_FRAGMENTED_POOL => Some(stringify!(ERROR_FRAGMENTED_POOL)),
|
}
|
||||||
|
Result::ERROR_INCOMPATIBLE_DRIVER => Some("Unable to find a Vulkan driver"),
|
||||||
|
Result::ERROR_TOO_MANY_OBJECTS => {
|
||||||
|
Some("Too many objects of the type have already been created")
|
||||||
|
}
|
||||||
|
Result::ERROR_FORMAT_NOT_SUPPORTED => {
|
||||||
|
Some("Requested format is not supported on this device")
|
||||||
|
}
|
||||||
|
Result::ERROR_FRAGMENTED_POOL => Some(
|
||||||
|
"A requested pool allocation has failed due to fragmentation of the pool\'s memory",
|
||||||
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(x) = name {
|
if let Some(x) = name {
|
||||||
|
|
|
@ -14,8 +14,3 @@ fn display_flags() {
|
||||||
fn display_enum() {
|
fn display_enum() {
|
||||||
assert_eq!(vk::ChromaLocation::MIDPOINT.to_string(), "MIDPOINT");
|
assert_eq!(vk::ChromaLocation::MIDPOINT.to_string(), "MIDPOINT");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn display_result() {
|
|
||||||
assert_eq!(vk::Result::SUCCESS.to_string(), "SUCCESS");
|
|
||||||
}
|
|
||||||
|
|
|
@ -1216,9 +1216,12 @@ pub fn generate_enum<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_result(ident: Ident, _enum: &vkxml::Enumeration) -> Tokens {
|
pub fn generate_result(ident: Ident, _enum: &vkxml::Enumeration) -> Tokens {
|
||||||
let display_notation = _enum.elements.iter().filter_map(|elem| {
|
let notation = _enum.elements.iter().filter_map(|elem| {
|
||||||
let variant_name = match *elem {
|
let (variant_name, notation) = match *elem {
|
||||||
vkxml::EnumerationElement::Enum(ref constant) => constant.name.as_str(),
|
vkxml::EnumerationElement::Enum(ref constant) => (
|
||||||
|
constant.name.as_str(),
|
||||||
|
constant.notation.as_ref().map(|s| s.as_str()).unwrap_or(""),
|
||||||
|
),
|
||||||
_ => {
|
_ => {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -1226,17 +1229,25 @@ pub fn generate_result(ident: Ident, _enum: &vkxml::Enumeration) -> Tokens {
|
||||||
|
|
||||||
let variant_ident = variant_ident(&_enum.name, variant_name);
|
let variant_ident = variant_ident(&_enum.name, variant_name);
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
#ident::#variant_ident => Some(stringify!(#variant_ident))
|
#ident::#variant_ident => Some(#notation)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let notation2 = notation.clone();
|
||||||
quote! {
|
quote! {
|
||||||
impl std::error::Error for #ident {}
|
impl ::std::error::Error for #ident {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
let name = match *self {
|
||||||
|
#(#notation),*,
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
name.unwrap_or("unknown error")
|
||||||
|
}
|
||||||
|
}
|
||||||
impl fmt::Display for #ident {
|
impl fmt::Display for #ident {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let name = match *self {
|
let name = match *self {
|
||||||
#(#display_notation),*,
|
#(#notation2),*,
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(x) = name {
|
if let Some(x) = name {
|
||||||
|
|
Loading…
Reference in a new issue