Skip to content

Conversation

@Veykril
Copy link
Member

@Veykril Veykril commented Sep 3, 2021

bors r+

bors bot added a commit that referenced this pull request Sep 3, 2021
10135: minor: fix some clippy lints r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
| cargo_metadata::Message::BuildFinished(_)
| cargo_metadata::Message::TextLine(_)
| _ => (),
_ => (),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, it makes sense, but the default branch was a bit weird (we might want to know if new message types are added).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we won't know that though because due to non exhaustiveness we have to use a wildcard no matter what

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's was an "ugh" for the old code, not for your change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream added non-exhaustive, that's why we need this here. Last weekend I almost got to prototyping miniserde-based cargo data to have more control over this :-)

if diagnosed_extern_crates.contains(krate) {
continue;
}
if let (Some(krate), PathKind::Plain | PathKind::Abs) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was intentional.

Copy link
Member Author

@Veykril Veykril Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how so? It doesn't really change the nesting level, though on another note match + if guard seems like the proper way here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this isn't an if let ... {} else {}, just an if let

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was indeed intentional -- multiline conditions are not readable. In

if let (Some(krate), PathKind::Plain | PathKind::Abs) =
    (directive.import.path.segments().first(), &directive.import.path.kind)

you need to read a lot to understand what the heck are you even matching. With match, scrutinee comes first, which I personally find easier on the eyes: pattern in isolation doesn't make much sense, it only is meaningful with respect to a specific expression you pattern match.

But no strong opinion here!

if !fn_traits.contains(&assoc_data.trait_id) {
return None;
}
if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably intentional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what reason? To me collapsing the matches seems better personally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: here, a complicated pattern comes before the expression to match.

@Veykril
Copy link
Member Author

Veykril commented Sep 3, 2021

bors r-

@bors
Copy link
Contributor

bors bot commented Sep 3, 2021

Canceled.

@lnicola
Copy link
Member

lnicola commented Sep 3, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 3, 2021

@bors bors bot merged commit ac25201 into rust-lang:master Sep 3, 2021
| cargo_metadata::Message::BuildFinished(_)
| cargo_metadata::Message::TextLine(_)
| _ => (),
_ => (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream added non-exhaustive, that's why we need this here. Last weekend I almost got to prototyping miniserde-based cargo data to have more control over this :-)

if diagnosed_extern_crates.contains(krate) {
continue;
}
if let (Some(krate), PathKind::Plain | PathKind::Abs) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was indeed intentional -- multiline conditions are not readable. In

if let (Some(krate), PathKind::Plain | PathKind::Abs) =
    (directive.import.path.segments().first(), &directive.import.path.kind)

you need to read a lot to understand what the heck are you even matching. With match, scrutinee comes first, which I personally find easier on the eyes: pattern in isolation doesn't make much sense, it only is meaningful with respect to a specific expression you pattern match.

But no strong opinion here!

if !fn_traits.contains(&assoc_data.trait_id) {
return None;
}
if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: here, a complicated pattern comes before the expression to match.

_ => {
// FIXME report error (ambiguous associated type)
(TyKind::Error.intern(&Interner), None)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, much better!

@Veykril Veykril deleted the clippy branch October 29, 2021 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants