Commit Graph

9943 Commits

Author SHA1 Message Date
Dylan DPC
66aa7f7cac Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnay
Stabilize the `Saturating` type

Closes #87920
Closes #92354

Stabilization report https://github.com/rust-lang/rust/issues/87920#issuecomment-1652346124
FCP https://github.com/rust-lang/rust/issues/87920#issuecomment-1676438885
2023-09-17 11:23:24 +00:00
bors
21216297e9 Auto merge of #115851 - Alexendoo:clippy-doc-hidden-headers, r=flip1995
Ignore `#[doc(hidden)]` functions in clippy doc lints

Fixes https://github.com/rust-lang/rust-clippy/issues/11501

The implementation before #115689 had a check for unsugared doc comments that also happened to catch `#[doc(hidden)]`, this adds the check back in more explicitly

852bf4e51b/src/tools/clippy/clippy_lints/src/doc.rs (L526-L529)

r? `@flip1995`
2023-09-15 09:55:31 +00:00
Ralf Jung
3226e4b010 don't point at const usage site for resolution-time errors
also share the code that emits the actual error
2023-09-14 22:34:05 +02:00
Ralf Jung
1d49cb6118 move required_consts check to general post-mono-check function 2023-09-14 22:30:42 +02:00
bors
9756a13580 Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling

- Move all of the checks for valid let expression positions to parsing.
- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location.
- Suppress some later errors and MIR construction for invalid let expressions.
- Fix a (drop) scope issue that was also responsible for #104172.

Fixes #104172
Fixes #104868
2023-09-14 19:56:55 +00:00
Alex Macleod
da4244e79c Ignore #[doc(hidden)] functions in clippy doc lints 2023-09-14 17:52:36 +00:00
bors
eb545d7568 Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obk
treat host effect params as erased in codegen

This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.

r? `@oli-obk`
2023-09-14 13:42:30 +00:00
Ralf Jung
477a9b88bf fix clippy (and MIR printing) handling of ConstValue::Indirect slices 2023-09-14 11:56:55 +02:00
Deadbeef
272df70b50 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Ralf Jung
b2d5d68c58 cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect 2023-09-14 07:27:30 +02:00
Ralf Jung
2aaaeb4e81 use AllocId instead of Allocation in ConstValue::ByRef 2023-09-14 07:26:24 +02:00
bors
0698591527 Auto merge of #115790 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-09-13 20:28:02 +00:00
Ralf Jung
5cd391c4ad make the set of methods between our two Const types more consistent 2023-09-13 07:29:34 +02:00
Philipp Krones
471469d30f Merge commit '98363cbf6a7c3f8b571a7d92a3c645bb4376e4a6' into clippyup 2023-09-12 18:44:06 +02:00
bors
b643f20f46 Auto merge of #115689 - Alexendoo:clippy-doc-comments, r=notriddle,Manishearth,flip1995
Reuse rustdoc's doc comment handling in Clippy

Moves `source_span_for_markdown_range` and `span_of_attrs` (renamed to `span_of_fragments`) to `rustc_resolve::rustdoc` so it can be used in Clippy

Fixes https://github.com/rust-lang/rust-clippy/issues/10277
Fixes https://github.com/rust-lang/rust-clippy/issues/5593
Fixes https://github.com/rust-lang/rust-clippy/issues/10263
Fixes https://github.com/rust-lang/rust-clippy/issues/2581
2023-09-12 01:45:24 +00:00
Matthew Jasper
ab08a3d7b2 Update tools and fulldeps tests 2023-09-11 15:51:19 +00:00
Alex Macleod
54f3ddb84a Call LateLintPass::check_attribute from with_lint_attrs 2023-09-10 18:56:39 +00:00
Alex Macleod
e88a556124 Reuse rustdoc's doc comment handling in Clippy 2023-09-08 23:42:57 +00:00
John Kåre Alsaker
b5941a2fd5 Partially outline code inside the panic! macro 2023-09-08 14:05:57 +02:00
John Kåre Alsaker
0f74faf158 Use Freeze for SourceFile.lines 2023-09-07 13:05:05 +02:00
bors
953901e35c Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obk
Use relative positions inside a SourceFile.

This allows to remove the normalization of start positions for hashing, and simplify allocation of global address space.

cc `@Zoxc`
2023-09-05 21:03:56 +00:00
Urgau
a86e758228 Adjust clippy tests with new rustc help suggestion for lints 2023-09-04 14:22:02 +02:00
Camille GILLOT
d5f0f443b9 Fix clippy. 2023-09-03 15:02:47 +00:00
Camille GILLOT
c3170771f3 Use relative positions inside a SourceFile. 2023-09-03 12:56:10 +00:00
Ralf Jung
a0ebcc38d4 Merge from rustc 2023-09-03 09:28:31 +02:00
Michael Watzko
1c27ba931b Stabilize the Saturating type (saturating_int_impl, gh-87920)
Also stabilizes saturating_int_assign_impl, gh-92354.

And also make pub fns const where the underlying saturating_*
fns became const in the meantime since the Saturating type was
created.
2023-09-03 01:22:46 +02:00
Ralf Jung
f5efadebc4 Merge from rustc 2023-09-02 03:07:21 +02:00
Caio
b3136a874d [clippy] Use symbols intended for arithmetic_side_effects 2023-09-01 10:28:55 +02:00
bors
af02b43015 Auto merge of #115183 - flip1995:clippyup, r=Manishearth,oli-obk
Update Clippy

r? `@oli-obk` Assigning you, because something broke with ui_test:

```
tests/ui/crashes/ice-7272.rs FAILED:
command: "<unknown>"

A bug in `ui_test` occurred: called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

full stderr:

```

(and that 103 times)

Thought I would ping you, before starting to investigate. Maybe you know what's going on.
2023-08-29 17:03:26 +00:00
Oli Scherer
6a876f236c Bump ui_test 2023-08-29 13:47:06 +00:00
Philipp Krones
cc61aeea54 Merge commit '080b587854a73f2a8cbaecff1884860a78e2ff37' into clippyup 2023-08-24 21:32:12 +02:00
Ralf Jung
70f6321cf9 when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
Esteban Küber
32eecd4b88 Fix clippy lint for identical if/else contraining ? expressions
Follow up to #114819.
2023-08-23 00:58:09 +00:00
Ralf Jung
50f7f8e0f8 give some unwind-related terminators a more clear name 2023-08-20 15:52:38 +02:00
bors
5638860ff8 Auto merge of #11314 - GuillaumeGomez:needless_ref_mut_async_block, r=Centri3
Correctly handle async blocks for NEEDLESS_PASS_BY_REF_MUT

Fixes https://github.com/rust-lang/rust-clippy/issues/11299.

The problem was that the `async block`s are popping a closure which we didn't go into, making it miss the mutable access to the variables.

cc `@Centri3`

changelog: none
2023-08-17 18:06:36 +02:00
bors
d068043891 Auto merge of #11070 - y21:issue11065, r=flip1995
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro

Fixes #11065 (which is actually two issues: an ICE and a false positive)

It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616836099).
It *also* makes sure that the expression is not part of a macro call (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616919639). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore)

changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item
changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP)

r? `@llogiq` (reviewed #10814, which introduced these issues)
2023-08-17 18:06:36 +02:00
Matthias Krüger
39219a6dd8 Rollup merge of #114819 - estebank:issue-78124, r=compiler-errors
Point at return type when it influences non-first `match` arm

When encountering code like

```rust
fn foo() -> i32 {
    match 0 {
        1 => return 0,
        2 => "",
        _ => 1,
    }
}
```

Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`.

Fix #78124.
2023-08-15 20:34:25 +02:00
Guillaume Gomez
9e33b69644 Rollup merge of #114772 - fee1-dead-contrib:typed-did, r=b-naber
Add `{Local}ModDefId` to more strongly type DefIds`

Based on #110862 by `@Nilstrieb`
2023-08-15 14:29:45 +02:00
Esteban Küber
d0a26f1c9c bless clippy test 2023-08-14 22:00:46 +00:00
Esteban Küber
89fdc3e383 Move scrutinee HirId into MatchSource::TryDesugar 2023-08-14 21:43:56 +00:00
Nilstrieb
7c87e5c20d Use {Local}ModDefId in many queries 2023-08-14 07:22:48 +00:00
Deadbeef
b8b3e078f9 Remove constness from ImplSource::Param 2023-08-14 02:17:30 +00:00
Philipp Krones
f730a2655a Merge commit '1e8fdf492808a25d78a97e1242b835ace9924e4d' into clippyup 2023-08-11 14:05:13 +02:00
bors
a1ab2d765f Auto merge of #114719 - compiler-errors:rollup-bf1vr51, r=compiler-errors
Rollup of 5 pull requests

Successful merges:

 - #114194 (Inline trivial (noop) flush calls)
 - #114257 (Avoid using `ptr::Unique` in `LinkedList` code)
 - #114359 ([library/std] Replace condv while loop with `cvar.wait_while`.)
 - #114402 (Fix documentation of impl From<Vec<T>> for Rc<[T]>)
 - #114715 (Revert clippy lint [`filter_map_bool_then`])

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-11 06:54:10 +00:00
Catherine Flores
1ec0501bca Revert "New lint [filter_map_bool_then]"
This reverts commits 978b1daf99 and 3235d9d612.
2023-08-10 17:28:01 -05:00
Vadim Petrochenkov
36a50008d0 rustc: Move crate_types from Session to GlobalCtxt
Removes a piece of mutable state.
Follow up to #114578.
2023-08-09 14:17:54 +08:00
Matthias Krüger
5f8600939e Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk
Store the laziness of type aliases in their `DefKind`

Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not.

With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*:

Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates.

As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions.

---

This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold.

`@rustbot` label F-lazy_type_alias
r? `@oli-obk`
2023-08-08 03:30:56 +02:00
León Orell Valerian Liehr
3ff6fd2ac7 Store the laziness of type aliases in the DefKind 2023-08-07 15:54:31 +02:00
Matthias Krüger
261837c841 Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJung
Add documentation to has_deref

Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose.

cc https://github.com/rust-lang/rust/issues/114401

r? `@RalfJung`
2023-08-06 17:26:29 +02:00
ouz-a
44cd3bcbba cleanup misinformation regarding has_deref 2023-08-06 17:29:09 +03:00