`assert_eq!` ignores type limits


#1

Hello again,

I’m just writing some doc-tests and was wondering about the assert macro:

/// ```
/// use packing::foo;
///
/// let x = foo();
/// assert_eq!(x, 0x34);
/// assert_eq!(x, 0x1234);
/// assert_eq!(x, 0x12FF34);
/// assert_eq!(x, 0x1211DEADBEEF0000000000011FF34);
/// ```
pub fn foo() -> u8 {
    0x34
}

The doc-test passes. I would expect here at lest a warning like this:

warning: comparison is useless due to type limits

Can I enable this somehow?
Is this an issue of Rust?

Kind regards,
Roman

PS: I’m using stable rustc 1.23.0.


#2

You could add #![deny(warnings)] or similar to your file.


#3

Just tried it. One need to add this link in every doc-test snippet. So this is not an intuitive solution.