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

Clippy subtree update #134343

Closed
wants to merge 116 commits into from
Closed

Conversation

flip1995
Copy link
Member

DJMcNab and others added 30 commits November 12, 2024 17:31
This is more likely to be intended as an intra-doc link than it is
to be intended as a refdef. If a refdef is intended, it does not
need to be nested within a list item or quote.

```markdown
- [`LONG_INTRA_DOC_LINK`]: this
  looks like an intra-doc link,
  but is actually a refdef.
  The first line will seem to
  disappear when rendered as HTML.
```
Co-Authored-By: Jason Newcomb <jsnewcomb@pm.me>
Changelog: extended [`precedence`] to lint for bitmasking and bit shifting without parentheses
The compiler uses `BitSet<Local>`, because the number of locals doesn't
get that high, so clippy should do likewise.
This updates the documentation after rust-lang#13694. It is not based on that PR
chain and can be merged independently, but should be merged after that
PR.

This is partly pulled from rust-lang#12762, but removing the Josh parts.

This includes instructions on how to publish `clippy_utils`.

Closes rust-lang/rust-clippy#13556 (yes, this
is the final PR 🙂)

r? @blyxyas

changelog: `clippy_utils` is now published to crates.io
…nishearth

Clippy subtree update

r? `@Manishearth`
Fixes rust-lang/rust-clippy#10780

We correctly no longer give a warning when a closure is passed to a
method, where one of the arguments to that method uses the variable
which would be shadowed by an argument to that closure.
Uses is defined loosely as any expression used in the calling expression
mentions the shadowee binding (except for the closure itself):

```rust
#![deny(clippy::shadow_unrelated)]
let x = Some(1);
let y = x.map(|x| x + 1);
```
will now succeed.

See linebender/xilem#745 - without this change,
all of the `expect(shadow_unrelated)` in the repository are met; with
it, none of them are.

changelog: [`shadow_unrelated`]: Don't treat closures arguments as
unrelated when the calling function uses them
The new cases are `x.map(f)` and `x.map_err(f)` when `f` is `Into::into`
or `From::from` with the same input and output types.
Fixes rust-lang#10195.

changelog: Added new [`literal_string_with_formatting_args`] `pedantic`
lint
[rust-lang#13410](rust-lang/rust-clippy#13410)
matthiaskrgr and others added 11 commits December 14, 2024 04:09
Rename `ty_def_id` so people will stop using it by accident

This function is just for cycle detection, but people keep using it because they think it's the right way of getting the def id from a `Ty` (and I can't blame them necessarily).
changelog: [`indexing_slicing`]: Clarify the relationship between
indexing_slicing and out_of_bound_indexing, clarify that this lint is
about possible panics based on runtime values, and fix array example to
not trigger the out_of_bound_indexing lint.
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#134252 (Fix `Path::is_absolute` on Hermit)
 - rust-lang#134254 (Fix building `std` for Hermit after `c_char` change)
 - rust-lang#134255 (Update includes in `/library/core/src/error.rs`.)
 - rust-lang#134261 (Document the symbol Visibility enum)
 - rust-lang#134262 (Arbitrary self types v2: adjust diagnostic.)
 - rust-lang#134265 (Rename `ty_def_id` so people will stop using it by accident)
 - rust-lang#134271 (Arbitrary self types v2: better feature gate test)
 - rust-lang#134274 (Add check-pass test for `&raw`)

r? `@ghost`
`@rustbot` modify labels: rollup
…gs, r=oli-obk

(Re-)Implement `impl_trait_in_bindings`

This reimplements the `impl_trait_in_bindings` feature for local bindings.

"`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference):

```rust
let _: impl Fn(&u8) -> &u8 = |x| x;
```

They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes:

```rust
trait Static: 'static {}
impl<T> Static for T where T: 'static {}

let local = 1;
let x: impl Static = &local;
//~^ ERROR `local` does not live long enough
```

r? oli-obk

cc rust-lang#63065

---

Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example:

```rust
type TAIT = impl Display;
let local = 0;
let x: TAIT = &local;
//~^ ERROR `local` does not live long enough
```

That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here.

---

I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
changelog:
```
changelog: [`needless_option_take`]: now lints for all temporary expressions of type  Option<T>.
```

fixes rust-lang#13671

In general, needless_option_take should report whenever take() is called
on a temporary value, not just when the temporary value is created by
as_ref().

Also, we stop emitting machine applicable fixes in these cases, since
sometimes the intention of the user is to actually clear the original
option, in cases such as `option.as_mut().take()`.
r? @ghost

changelog: none
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 15, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 15, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@matthiaskrgr
Copy link
Member

r? matthiaskrgr
@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Dec 15, 2024

📌 Commit 50d004f has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 15, 2024
@matthiaskrgr
Copy link
Member

@bors rollup=maybe

@jieyouxu
Copy link
Member

jieyouxu commented Dec 15, 2024

@flip1995 @matthiaskrgr Hi clippy folks, I think #131808 is going to conflict with this one. Is it possible for clippy subtree bump to wait for #131808 then do a resync?

@bors
Copy link
Contributor

bors commented Dec 16, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout clippy-subtree-update (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self clippy-subtree-update --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Removing src/tools/clippy/tests/ui/needless_option_take.fixed
Auto-merging src/tools/clippy/clippy_utils/src/msrvs.rs
Auto-merging src/tools/clippy/clippy_utils/src/lib.rs
Auto-merging src/tools/clippy/clippy_utils/src/ast_utils/mod.rs
CONFLICT (content): Merge conflict in src/tools/clippy/clippy_utils/src/ast_utils/mod.rs
Auto-merging src/tools/clippy/clippy_lints/src/doc/mod.rs
Auto-merging src/tools/clippy/clippy_lints/src/attrs/should_panic_without_expect.rs
CONFLICT (content): Merge conflict in src/tools/clippy/clippy_lints/src/attrs/should_panic_without_expect.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 16, 2024
@flip1995
Copy link
Member Author

I'll need a few days to get back to this. Probably until the weekend.

@bors
Copy link
Contributor

bors commented Dec 23, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout clippy-subtree-update (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self clippy-subtree-update --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Removing src/tools/clippy/tests/ui/needless_option_take.fixed
Auto-merging src/tools/clippy/clippy_utils/src/msrvs.rs
Auto-merging src/tools/clippy/clippy_utils/src/lib.rs
Auto-merging src/tools/clippy/clippy_utils/src/ast_utils/mod.rs
CONFLICT (content): Merge conflict in src/tools/clippy/clippy_utils/src/ast_utils/mod.rs
Auto-merging src/tools/clippy/clippy_lints/src/lib.rs
Auto-merging src/tools/clippy/clippy_lints/src/doc/mod.rs
Auto-merging src/tools/clippy/clippy_lints/src/attrs/should_panic_without_expect.rs
CONFLICT (content): Merge conflict in src/tools/clippy/clippy_lints/src/attrs/should_panic_without_expect.rs
Automatic merge failed; fix conflicts and then commit the result.

@flip1995
Copy link
Member Author

Today is a new sync day. Closing in favor of the new sync, I'll open in a few minutes.

@flip1995 flip1995 closed this Dec 26, 2024
@flip1995 flip1995 deleted the clippy-subtree-update branch December 26, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.