rust-ammonia / ammonia

Repair and secure untrusted HTML
Apache License 2.0
523 stars 43 forks source link

Fix clippy warnings #166

Closed notriddle closed 1 year ago

notriddle commented 2 years ago

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.

lnicola commented 2 years ago

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?

notriddle commented 2 years ago

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

notriddle commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded: