Commit Graph

1698 Commits

Author SHA1 Message Date
Alex Macleod
3474df6a8e Rewrite empty_line_after_doc_comments and empty_line_after_outer_attr 2024-08-24 18:07:31 +00:00
bors
30e0b69908 Auto merge of #12993 - GuillaumeGomez:too_long_first_doc_paragraph, r=Centri3
Add new `too_long_first_doc_paragraph` first paragraph lint

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

changelog: Add new `too_long_first_doc_paragraph` first paragraph lint
2024-08-24 15:23:34 +00:00
bors
497177fa50 Auto merge of #13296 - Jarcho:get_src_display3, r=Alexendoo
Replace more uses of `snippet_opt`.

Almost all calls are removed after this.

changelog: none
2024-08-24 12:42:32 +00:00
Jason Newcomb
9450b4af48 Replace more uses of snippet_opt. 2024-08-21 14:41:18 -04:00
Jason Newcomb
8a4c34a5b7 Start removing snippet_opt 2024-08-21 12:25:10 -04:00
bors
ba6bc81277 Auto merge of #13278 - Alexendoo:misc-cleanup, r=y21
Misc cleanup

changelog: none
2024-08-19 17:42:25 +00:00
bors
bfe7f070bd Auto merge of #13248 - Alexendoo:format-arg-ast-fallback, r=xFrednet
Remove `find_format_arg_expr` AST fallback

If the function fails where it shouldn't we can fix that directly, but the fallback path is untested as I'm not aware of a case where it would fail

changelog: none
2024-08-18 09:11:03 +00:00
Alex Macleod
ed46141081 Remove duplicate type_diagnostic_name function 2024-08-17 18:10:46 +00:00
bors
1984752623 Auto merge of #13255 - Jarcho:get_src_display2, r=Manishearth
Remove more `snippet_opt` calls

First commit is the same as #13244

changelog: none
2024-08-12 18:50:19 +00:00
bors
52192aa321 Auto merge of #13243 - Alexendoo:rustcversion, r=flip1995
Replace `rustc_semver` with `rustc_session::RustcVersion`

Allows dropping a dependency but there is a behaviour change here, the following versions are no longer accepted:

* `1` (would need to be `1.0` or `1.0.0`)
* `1.0.0-alpha`
* `1.0.0-alpha.2`
* `1.0.0-beta`

But this seems unlikely to effect anybody, I did some GitHub searching and found no occurrences outside our UI tests

r? `@flip1995`

changelog: none
2024-08-12 08:24:00 +00:00
Jason Newcomb
ddf2ba5886 Remove more instances of snippet_opt. 2024-08-11 18:07:53 -04:00
Alex Macleod
4231e93bf7 Remove find_format_arg_expr AST fallback 2024-08-10 10:50:47 +00:00
Jason Newcomb
f9509d3574 Refactor absolute_paths:
* Check the path length first
* Use `is_from_proc_macro`
* Use symbols instead of strings when checking crate names
2024-08-09 22:08:29 -04:00
Jason Newcomb
9afab36ca9 Rename get_source_text to get_source_range. Add new get_source_text which returns a displayable string-like type. 2024-08-09 09:27:00 -04:00
Alex Macleod
b32a0176fa Replace rustc_semver with rustc_session::RustcVersion 2024-08-09 13:00:24 +00:00
Philipp Krones
7a73a101e9
Merge remote-tracking branch 'upstream/master' into rustup 2024-08-08 18:54:43 +02:00
bors
b1e87922c1 Auto merge of #13200 - Jarcho:constant_no_typeck, r=Alexendoo
Don't use `LateContext` in the constant evaluator

This also changes the interface to require explicitly creating the context. `constant` could be added back in, but the others are probably not worth it.

A couple of bugs have been fixed. The wrong `TypeckResults` was used once when evaluating a constant, and the wrong `ParamEnv` was used by some callers (there wasn't a way to use the correct one).

changelog: none
2024-08-08 14:42:42 +00:00
Jason Newcomb
e4ad36d6a8 Require ConstEvalCtxt to be constructed. 2024-08-08 10:37:10 -04:00
Jason Newcomb
d2cb227eb4 Don't store LateContext in ConstEvalLateContext 2024-08-08 10:34:53 -04:00
Jason Newcomb
3779062955 Add HasSession trait 2024-08-08 10:31:45 -04:00
Jason Newcomb
16633a2d7b Replace in_constant with is_in_const_context. Use only the state in LateContext to avoid walking the HIR tree. 2024-08-07 09:57:27 -04:00
Jason Newcomb
4e57b2c46f Use -D warnings instead of deny-warnings feature. 2024-08-06 10:46:39 -04:00
Alex Macleod
1ea7bddbdf Remove multispan_sugg[_with_applicability] 2024-08-04 13:14:23 +00:00
bors
1ea827fa03 Auto merge of #13115 - tesuji:rm-dup-peels, r=dswij
Remove duplicated `peel_middle_ty_refs`

TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too?

changelog: none
2024-08-03 07:32:30 +00:00
Alex Macleod
943a8e0646 Remove some miscellaneous #[allow]s 2024-07-29 19:57:39 +00:00
shenyifu
38a3462037 Fix fix under loop may dropping loop label when applying fix. 2024-07-29 17:43:03 +08:00
Mark Rousskov
5faea65d4d step cfg(bootstrap) 2024-07-28 14:46:29 -04:00
bors
d20be39c7f Auto merge of #13149 - jusexton:issue-13123, r=dswij
Fix while_let_on_iterator dropping loop label when applying fix.

Loop label was not persisted when displaying help and was therefore producing broken rust code when applying fixes.

Solution was to store the `ast::Label` when creating a `higher::WhileLet` from an expression and add the label name to the lint suggestion and diagnostics.

---

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

changelog: [`while_let_on_iterator`]: Fix issue dropping loop label when displaying help and applying fixes.
2024-07-27 15:23:21 +00:00
Guillaume Gomez
4969960a9c Fix dogfood lints 2024-07-26 11:21:32 +02:00
bors
c7cfe7f5e2 Auto merge of #13156 - y21:for_each_expr_visitor_refactor, r=xFrednet
Remove unnecessary `res` field in `for_each_expr` visitors

Small refactor in the `for_each_expr*` visitors. This should not change anything functionally.

Instead of storing the final value `Option<B>` in the visitor and setting it to `Some` when we get a `ControlFlow::Break(B)` from the closure, we can just directly return it from the visitor itself now that visitors support that.

cc #12829 and https://github.com/rust-lang/rust-clippy/pull/12830#discussion_r1627882827

changelog: none
2024-07-25 17:51:02 +00:00
Philipp Krones
4e6851e50b Merge commit '37f4fbb92913586b73a35772efd00eccd1cbbe13' into clippy-subtree-update 2024-07-25 18:29:17 +02:00
Philipp Krones
71b0f0fcac
Bump Clippy version -> 0.1.82 2024-07-25 18:23:37 +02:00
Philipp Krones
9f53fc32cf
Merge remote-tracking branch 'upstream/master' into rustup 2024-07-25 18:23:27 +02:00
y21
de1e163779 get rid of unnecessary res field in for_each_expr visitors 2024-07-25 15:02:31 +02:00
bors
5e6540f049 Auto merge of #13146 - Alexendoo:cast-lossless-128, r=y21
Lint casts to `u128` in `cast_lossless`

Reverts #12496 per https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60as.20u128.60.20trigger.20cast_lossless

Also changes the lint messages and refactors the suggestion production - Fixes #12695

changelog: [`cast_lossless`]: lint casts to `u128`
2024-07-24 21:00:05 +00:00
Alex Macleod
6d28e1a954 Lint casts to u128 in cast_lossless 2024-07-24 14:32:41 +00:00
blyxyas
b21a91ae3a Replace local variables signifying "done" or "loop break", use ControlFlow #12830 2024-07-24 01:40:58 +02:00
jusexton
0cdf6e172c Fix while_let_on_iterator dropping loop label when applying fix. 2024-07-23 02:55:58 -05:00
Jason Newcomb
e34c6dbae5 Refactor for using config values:
* Construct lint passes by taking `Conf` by reference.
* Use `HashSet` configs in less places
* Move some `check_crate` code into the pass constructor when possible.
2024-07-17 14:05:49 -04:00
Lzu Tao
a5fd2c98bd Remove duplicated peel_middle_ty_refs
TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too?
2024-07-17 12:51:08 +07:00
Noah Lev
f2c1265483 Add ConstArgKind::Path and make ConstArg its own HIR node
This is a very large commit since a lot needs to be changed in order to
make the tests pass. The salient changes are:

- `ConstArgKind` gets a new `Path` variant, and all const params are now
  represented using it. Non-param paths still use `ConstArgKind::Anon`
  to prevent this change from getting too large, but they will soon use
  the `Path` variant too.

- `ConstArg` gets a distinct `hir_id` field and its own variant in
  `hir::Node`. This affected many parts of the compiler that expected
  the parent of an `AnonConst` to be the containing context (e.g., an
  array repeat expression). They have been changed to check the
  "grandparent" where necessary.

- Some `ast::AnonConst`s now have their `DefId`s created in
  rustc_ast_lowering rather than `DefCollector`. This is because in some
  cases they will end up becoming a `ConstArgKind::Path` instead, which
  has no `DefId`. We have to solve this in a hacky way where we guess
  whether the `AnonConst` could end up as a path const since we can't
  know for sure until after name resolution (`N` could refer to a free
  const or a nullary struct). If it has no chance as being a const
  param, then we create a `DefId` in `DefCollector` -- otherwise we
  decide during ast_lowering. This will have to be updated once all path
  consts use `ConstArgKind::Path`.

- We explicitly use `ConstArgHasType` for array lengths, rather than
  implicitly relying on anon const type feeding -- this is due to the
  addition of `ConstArgKind::Path`.

- Some tests have their outputs changed, but the changes are for the
  most part minor (including removing duplicate or almost-duplicate
  errors). One test now ICEs, but it is for an incomplete, unstable
  feature and is now tracked at #127009.
2024-07-16 19:27:28 -07:00
Noah Lev
6e99e2d748 Use ConstArg for array lengths 2024-07-16 19:27:28 -07:00
Noah Lev
620a056a33 hir: Create hir::ConstArgKind enum
This will allow lowering const params to a dedicated enum variant, rather
than to an `AnonConst` that is later examined during `ty` lowering.
2024-07-16 19:27:28 -07:00
apoisternex
489a77831c fix [excessive_precision] suggestions on float literal written in scientific notation
fixes: #12954

changelog: fix [`excessive_precision`] suggestions on float literal written in scientific notation
2024-07-15 18:52:18 -03:00
bors
eb4d88e690 Auto merge of #13102 - tesuji:fix-needless_option_as_deref, r=Alexendoo
Fix `needless_option_as_deref` false-positive on struct literals

changelog: [`needless_option_as_deref`] Fix false-positive on struct literals.

Fixes #13077 .

r?  Alexendoo
2024-07-15 16:23:41 +00:00
Lzu Tao
dcee2e8a0f Dont stop find loop node at struct field node 2024-07-15 15:56:17 +00:00
Philipp Krones
c1fd25d0aa Merge commit 'b794b8e08c16517a941dc598bb1483e8e12a8592' into clippy-subtree-update 2024-07-11 15:44:03 +02:00
Philipp Krones
1ced73e66a
Merge remote-tracking branch 'upstream/master' into rustup 2024-07-11 15:29:08 +02:00
bors
e82cfdc559 Auto merge of #127476 - jieyouxu:rollup-16wyb0b, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - #126841 ([`macro_metavar_expr_concat`] Add support for literals)
 - #126881 (Make `NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE` a deny-by-default lint in edition 2024)
 - #126921 (Give VaList its own home)
 - #127367 (Run alloc sync tests)
 - #127431 (Use field ident spans directly instead of the full field span in diagnostics on local fields)
 - #127437 (Uplift trait ref is knowable into `rustc_next_trait_solver`)
 - #127439 (Uplift elaboration into `rustc_type_ir`)
 - #127451 (Improve `run-make/output-type-permutations` code and improve `filename_not_in_denylist` API)
 - #127452 (Fix intrinsic const parameter counting with `effects`)
 - #127459 (rustdoc-json: add type/trait alias tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-08 06:47:12 +00:00
Maybe Waffle
791ff40337 Add support for mir::TerminatorKind::TailCall in clippy 2024-07-07 17:11:05 +02:00