6

`get_last_with_len`: lint `VecDeque` and any deref to slice by Alexendoo · Pull...

 2 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/8862
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

// check that recv == lhs_recv `recv.get(lhs_recv.len() - 1)`

&& path_to_local(lhs_recv) == Some(recv_local)

{

let method = match cx.typeck_results().expr_ty_adjusted(recv).peel_refs().kind() {

Contributor

@Jarcho Jarcho 12 days ago

Quick question here. This allows any type which derefs to a VecDeque or a slice. Is that intentional?

Member

Author

@Alexendoo Alexendoo 12 days ago

It is yeah

Contributor

@Jarcho Jarcho 12 days ago

I don't know if you want to handle this horrible case or not:

struct Foo(Vec<u32>);
impl Deref for Foo { type Target = Vec<u32>; ... }
impl Foo {
    // Only replace `last`, but not `get`
    fn last(&self) -> SomeType { ... }
}

I don't think it's necessary to do so. It's kind of a pathological case.

Member

Author

@Alexendoo Alexendoo 11 days ago

I'm happy to leave that one out, can't imagine it coming up


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK