Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustup #5711

Merged
merged 14 commits into from
Jun 23, 2020
Merged

Rustup #5711

merged 14 commits into from
Jun 23, 2020

Conversation

flip1995
Copy link
Member

changelog: none

@rust-highfive
Copy link

r? @Manishearth

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 13, 2020
@flip1995
Copy link
Member Author

Probably blocked on rust-lang/rust#73257

@Manishearth
Copy link
Member

r=me when ready!

bors and others added 2 commits June 15, 2020 04:10
Clean up type alias impl trait implementation

- Removes special case for top-level impl trait
- Removes associated opaque types
- Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types.
- Handle lifetimes in type alias impl trait more uniformly with other parameters

cc #69323
cc #63063
Closes #57188
Closes #62988
Closes #69136
Closes #73061
Stabilize Option::zip

This PR stabilizes the following API:

```rust
impl<T> Option<T> {
    pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)>;
}
```

This API has real world usage as seen in <https://grep.app/search?q=-%3E%20Option%3C%5C%28T%2C%5Cs%3FU%5C%29%3E&regexp=true&filter[lang][0]=Rust>.

The `zip_with` method is left unstably as this API is kinda niche
and it hasn't received much usage in Rust repositories on GitHub.

cc #70086
@flip1995
Copy link
Member Author

@bors r=Manishearth (let's try and see if we're waiting unnecessarily, the queue is empty anyway)

@bors
Copy link
Contributor

bors commented Jun 15, 2020

📌 Commit 08e044e has been approved by Manishearth

bors added a commit that referenced this pull request Jun 15, 2020
@bors
Copy link
Contributor

bors commented Jun 15, 2020

⌛ Testing commit 08e044e with merge 596c54f...

@bors
Copy link
Contributor

bors commented Jun 15, 2020

💔 Test failed - checks-action_test

@flip1995
Copy link
Member Author

I'll continue working on fixing the fallout of rust-lang/rust#72389 tomorrow. Now binary operators will be marked as expansions. This broke every lint, that tested for expansion with span.from_expansion(). This will require careful evaluation of every span.from_expansion() call in the Clippy code base.

@flip1995 flip1995 force-pushed the rustup branch 2 times, most recently from 63e300a to 59cb7f1 Compare June 17, 2020 15:13
@flip1995
Copy link
Member Author

TODO:

  • UNIT_CMP
  • BOOL_COMPARISON
  • ITERATOR_STEP_BY_ZERO
  • STRING_ADD

In these cases neither utils::in_macro, nor span.from_expansion() works as expected. We should prepare ourselfs for multiple FN and FP issues because of macros in the near future.

@Manishearth
Copy link
Member

@flip1995 I think we should be open to asking for that PR to be reverted while we fix this.

@Manishearth
Copy link
Member

It's a diagnostics PR. If it is causing mass lint breakage, that's a problem, and perhaps its approach is not the best one.

@flip1995
Copy link
Member Author

flip1995 commented Jun 17, 2020

Yeah, I also thought about this.

There is currently the issue, that it seems that expn info is overridden. See the string_add example for this: https://github.com/rust-lang/rust-clippy/runs/780962847#step:10:1751

We're checking if the string addition comes from an external macro (what it does)

string_add!();

#[macro_export]
macro_rules! string_add {
() => {
let y = "".to_owned();
let z = y + "...";
};
}

But since we're checking this on the expr with expr.kind == ExprKind::BinaryOp, it will get the expansion context of ExpnKind::Desugaring(DesugaringKind::Operator), instead of ExpnKind::Macro. This means that everytime we find an expr with expr.kind == BinaryOp, we can't determine, if it is from a macro expansion, unless we check every parent expression (which would definitely be a very bad idea, since I can only imagine how many bugs this would introduce and how inefficient it would be).

cc @Aaron1011

@Aaron1011
Copy link
Member

It sounds like the root issue is that ExpnKind::Desugaring and ExpnKind::Macro are mutually exclusive. What we really want is to be able to mark a Span with some desugaring information, and independently set whether or not it's coming from a macro.

I think the simplest way of achieving this would be to add an Option<DesugaringKind> to ExpnData, and delete the Desugaring variant from ExpnKind. I'll open a PR to rustc.

@Manishearth
Copy link
Member

@flip1995 Oh, the loss of this functionality is definitely a bug in rust-lang/rust#72389 , since macros affect other diagnostics in rustc too.

@Aaron1011
Copy link
Member

@flip1995: After thinking about this more, I think walking up the 'expansion stack' is actually the correct thing to do.

Consider the following code:

fn main() {
    if true || true {}
}

When we lower the if expression, we'll end up with both a DesugaringKind::CondTemporary and a DesugaringKind::Operator applied to the expression true || true. If we store the DesugaringKind alongside the existing ExpnData, we'll either need to overwrite one of the DesugaringKinds, or maintain a list of applied DesugaringKinds per ExpnData.

I think it would be simpler to have Clippy walk up the 'expansion stack' to check if an ExpnKind::Macro or ExpnKind::AstPass is present. We should be able to eliminate any performance impact by caching this in ExpnData on creation.

For the following code
```rust
let c = || bar(foo.x, foo.x)
```

We generate two different `hir::Place`s for both `foo.x`.
Handling this adds overhead for analysis we need to do for RFC 2229.

We also want to store type information at each Projection to support
analysis as part of the RFC. This resembles what we have for
`mir::Place`

This commit modifies the Place as follows:
- Rename to `PlaceWithHirId`, where there `hir_id` is that of the
expressioin.
- Move any other information that describes the access out to another
struct now called `Place`.
- Removed `Span`, it can be accessed using the [hir
API](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.span)
- Modify `Projection` to be a strucutre of its own, that currently only
contains the `ProjectionKind`.

Adding type information to projections wil be completed as part of rust-lang/project-rfc-2229#5

Closes rust-lang/project-rfc-2229#3

Co-authored-by: Aman Arora <[email protected]>
Co-authored-by: Roxane Fruytier <[email protected]>
@matthiaskrgr
Copy link
Member

The PR that fixed the ci-ice has been merged now 🎉

@phansch
Copy link
Member

phansch commented Jun 22, 2020

I believe this PR is currently waiting on rust-lang/rust#73594, right?

@Manishearth
Copy link
Member

Yes

None of the tools seem to need syn 0.15.35, so we can just build syn
1.0.

This was causing an issue with clippy's `compile-test` program: since
multiple versions of `syn` would exist in the build directory, we would
non-deterministically pick one based on filesystem iteration order. If
the pre-1.0 version of `syn` was picked, a strange build error would
occur (see
rust-lang/rust#73594 (comment))

To prevent this kind of issue from happening again, we now panic if we
find multiple versions of a crate in the build directly, instead of
silently picking the first version we find.
@flip1995
Copy link
Member Author

@bors r+

Next up: sync Clippy back in Rust repo

@bors
Copy link
Contributor

bors commented Jun 23, 2020

📌 Commit 51592f8 has been approved by flip1995

@bors
Copy link
Contributor

bors commented Jun 23, 2020

⌛ Testing commit 51592f8 with merge fa0f6a8...

@bors
Copy link
Contributor

bors commented Jun 23, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing fa0f6a8 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.