Closed
Description
The following seems to have regressed maybe yesterday or the day before on nightly, but builds on stable. It is real code, sorry its not 100% minimal :)
use core::fmt;
use core::fmt::Debug;
use std::io;
/// An error in decoding a message or struct.
#[derive(Clone, Debug, PartialEq)]
pub enum DecodeError {
/// A version byte specified something we don't know how to handle.
/// Includes unknown realm byte in an OnionHopData packet
UnknownVersion,
/// Unknown feature mandating we fail to parse message (eg TLV with an even, unknown type)
UnknownRequiredFeature,
/// Value was invalid, eg a byte which was supposed to be a bool was something other than a 0
/// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
/// syntactically incorrect, etc
InvalidValue,
/// Buffer too short
ShortRead,
/// A length descriptor in the packet didn't describe the later data correctly
BadLengthDescriptor,
/// Error from std::io
Io(/// (C-not exported) as ErrorKind doesn't have a reasonable mapping
io::ErrorKind),
/// The message included zlib-compressed values, which we don't support.
UnsupportedCompression,
}
impl fmt::Display for DecodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DecodeError::UnknownVersion => f.write_str("Unknown realm byte in Onion packet"),
DecodeError::UnknownRequiredFeature => f.write_str("Unknown required feature preventing decode"),
DecodeError::InvalidValue => f.write_str("Nonsense bytes didn't map to the type they were interpreted as"),
DecodeError::ShortRead => f.write_str("Packet extended beyond the provided bytes"),
DecodeError::BadLengthDescriptor => f.write_str("A length descriptor in the packet didn't describe the later data correctly"),
DecodeError::Io(ref e) => e.fmt(f),
DecodeError::UnsupportedCompression => f.write_str("We don't support receiving messages with zlib-compressed fields"),
}
}
}
Error running this on playground for feb 1's nightly:
⣿
Standard Error
Compiling playground v0.0.1 (/playground)
error[E0034]: multiple applicable items in scope
--> src/lib.rs:39:32
|
39 | DecodeError::Io(ref e) => e.fmt(f),
| ^^^ multiple `fmt` found
|
= note: candidate #1 is defined in an impl of the trait `std::fmt::Display` for the type `ErrorKind`
= note: candidate #2 is defined in an impl of the trait `Debug` for the type `ErrorKind`
help: disambiguate the associated function for candidate #1
|
39 | DecodeError::Io(ref e) => std::fmt::Display::fmt(&e, f),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
|
39 | DecodeError::Io(ref e) => Debug::fmt(&e, f),
| ~~~~~~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0034`.
error: could not compile `playground` due to previous error
Warnings
No main function was detected, so your code was compiled
but not run. If you’d like to execute your code, please
add a main function.