ammonia icon indicating copy to clipboard operation
ammonia copied to clipboard

Fix clippy warnings

Open notriddle opened this issue 3 years ago • 2 comments

This PR avoids fixing one clippy warning, since it's actually a breaking change.

error: type `Document` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display`
    --> src/lib.rs:2670:5
     |
2670 | /     pub fn to_string(&self) -> String {
2671 | |         let opts = Self::serialize_opts();
2672 | |         let mut ret_val = Vec::new();
2673 | |         let inner: SerializableHandle = self.0.document.children.borrow()[0].clone().into();
...    |
2676 | |         String::from_utf8(ret_val).expect("html5ever only supports UTF8")
2677 | |     }
     | |_____^
     |
     = note: `#[deny(clippy::inherent_to_string_shadow_display)]` on by default
     = help: remove the inherent method from type `Document`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string_shadow_display

This one will be fixed in version 4.

notriddle avatar Aug 15 '22 20:08 notriddle

it's actually a breaking change

Can we move that code to impl Display? Or is it still a breaking change for users of Document::to_string without importing the trait?

lnicola avatar Aug 15 '22 20:08 lnicola

I'm worried about people calling doc.to_string() without importing the ToString trait.

notriddle avatar Aug 15 '22 20:08 notriddle

bors r+

notriddle avatar Nov 28 '22 18:11 notriddle

Build succeeded:

bors[bot] avatar Nov 28 '22 18:11 bors[bot]