Commit graph

1084 commits

Author SHA1 Message Date
y21
bb58083ce5 new lint: while_pop_unwrap 2023-04-29 18:59:06 +02:00
bors
96f8471d81 Auto merge of #10649 - jsoref:spelling, r=Jarcho
Spelling

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling).

The misspellings have been reported at https://github.com/jsoref/rust-clippy/actions/runs/4710771873#summary-12776860721

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/rust-clippy/actions/runs/4710771874#summary-12776860722

changelog: none
2023-04-23 22:30:06 +00:00
Josh Soref
6f7801f810 Rewrite search_same description 2023-04-23 10:53:06 -04:00
Josh Soref
d2061faf9e Spelling
* applying
* binding
* complex
* constituent
* demonstrate
* desugaring
* exact
* expression
* for
* functionalities
* github
* implementation
* infers
* multiple conflicting traits
* mutable
* necessarily
* nightly
* nonexistent
* optional
* parameter
* reassignments
* resources
* substitution
* suggestion
* that
* that array is
* using the

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-23 10:52:27 -04:00
bors
496c11005c Auto merge of #10679 - y21:better-const-ctx-check, r=Jarcho
use `is_inside_const_context` for `in_constant` util fn

Fixes #10452.

This PR improves the `in_constant` util function to detect more cases of const contexts. Previously this function would not detect cases like expressions in array length position or expression in an inline const block `const { .. }`.

changelog: [`bool_to_int_with_if`]: recognize array length operand as being in a const context and don't suggest `usize::from` there
2023-04-23 13:33:51 +00:00
Philipp Krones
0add5bb0f1
Bump Clippy version -> 0.1.71 2023-04-23 03:39:19 -07:00
Philipp Krones
583c97e9bb
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-23 03:39:03 -07:00
bors
86d8f1268a Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
DrMeepster
68c4776b46 offset_of 2023-04-21 02:14:02 -07:00
y21
654d12ff89 use is_inside_const_context query for in_constant 2023-04-20 22:43:59 +02:00
Camille GILLOT
8ead58c67b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
Maybe Waffle
2ebfbc5753 Remove very useless as_substs usage from clippy 2023-04-18 17:39:08 +00:00
Philipp Krones
6b95029f17 Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup 2023-04-11 15:31:08 +02:00
bors
d048c1130f Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input

Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
0963a66ab3 Make elaborator generic 2023-04-06 23:30:22 +00:00
Philipp Krones
04c387efe7
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-06 12:32:32 +02:00
Gary Guo
293c1a1a6a Fix tools 2023-04-06 09:34:16 +01:00
Gary Guo
f5ac844296 Refactor unwind from Option to a new enum 2023-04-06 09:34:16 +01:00
Oli Scherer
e9c7fb10b9 Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
Oli Scherer
e610ddfa5e box a bunch of large types 2023-04-04 13:58:50 +00:00
Oli Scherer
ff7636db6a Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer
929696d754 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00
Oli Scherer
a6beddcc5a rust-analyzer guided enum variant structification 2023-04-04 09:44:45 +00:00
bors
6a6a262f7b Auto merge of #109010 - compiler-errors:rtn, r=eholk
Initial support for return type notation (RTN)

See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/

1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter.
    * I'd add this in a follow-up.
3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~
    * I don't think we actually want this.
5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`.
    * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it.
7. ~I'm not in love with the feature gate name 😺~
    * I renamed it to `return_type_notation` ✔️

Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later.

r? `@ghost`
2023-03-31 18:04:12 +00:00
Samuel "Sam" Tardieu
6601d85c22 Flag bufreader.lines().filter_map(Result::ok) as suspicious 2023-03-31 14:43:30 +02:00
Trevor Gross
4cf5bdc60c Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
bors
c5011e9d42 Auto merge of #10553 - Nilstrieb:better-uninit, r=Alexendoo
In uninit checking, add fallback for polymorphic types

After #10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit).

fixes #10551

changelog: [uninit_vec]: fix false positive for polymorphic types
changelog: [uninit_assumed_init]: fix false positive for polymorphic types
2023-03-29 18:26:35 +00:00
Nilstrieb
51b4d2a1e8 In uninit checking, add fallback for polymorphic types 2023-03-29 19:46:44 +02:00
Alex Macleod
6589d79492 Replace remaining usage of FormatArgsExpn 2023-03-28 21:28:57 +00:00
Alex Macleod
3259b48568 Migrate format_args.rs to rustc_ast::FormatArgs
No longer lints empty precisions `{:.}` as the spans aren't available
2023-03-28 12:22:22 +00:00
Michael Goulet
fc6262fa0c Add (..) syntax for RTN 2023-03-28 01:14:28 +00:00
Guillaume Gomez
538e8bdcc8 Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
Remove the `NodeId` of `ast::ExprKind::Async`

This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416.

In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`.
It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27 18:56:19 +02:00
Michael Goulet
db4e4afce8 Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
bluthej
2493be2196 Improve is_range_full implementation
Make this function work with signed integer types by extracting the
underlying type and finding the min and max values.

Change the signature to make it more consistent:
- The range is now given as an `Expr` in order to extract the type
- The container's path is now passed, and only as an `Option` so that
  the function can be called in the general case without a container
2023-03-26 19:12:36 +02:00
bluthej
1d168b31c3
Merge branch 'rust-lang:master' into clear-with-drain 2023-03-26 19:11:38 +02:00
Philipp Krones
8df896c076 Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyup 2023-03-24 14:26:19 +01:00
Philipp Krones
62cba5d971
Merge remote-tracking branch 'upstream/master' into rustup 2023-03-24 13:36:09 +01:00
bors
58eb9964cc Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
bors
f34590478b Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs)
 - #109137 (resolve: Querify most cstore access methods (subset 2))
 - #109380 (add `known-bug` test for unsoundness issue)
 - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate))
 - #109475 (Simpler checked shifts in MIR building)
 - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.)
 - #109506 (make param bound vars visibly bound vars with -Zverbose)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 12:35:05 +00:00
Michael Goulet
b506eb5338 Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
Scott McMurray
8bdd54e8c6 Add CastKind::Transmute to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic.

Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22 15:15:41 -07:00
bluthej
85d428101d Pull is_full_range method from iter_with_drain
Rename method to `is_range_full` because the type is actually
`RangeFull`.

Method moved to `clippy_utils` for reuse in `clear_with_drain`.
2023-03-22 11:01:51 +01:00
Vadim Petrochenkov
cae7b87711 rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
Nilstrieb
84b6049eb9 Use uninit checking from rustc
rustc has proper heuristics for actually checking whether a type allows
being left uninitialized (by asking CTFE). We can now use this for our
helper instead of rolling our own bad version with false positives.
2023-03-21 18:28:06 +01:00
Arpad Borsos
1e17a443b3 Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
Matthias Krüger
60fe49c54c Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors
Remove box expressions from HIR

After #108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed.

This is based on top of #108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!)

````@rustbot```` label +S-blocked
2023-03-17 08:42:37 +01:00
Samuel "Sam" Tardieu
ffabdab8cf New lint to detect &std::path::MAIN_SEPARATOR.to_string() 2023-03-16 21:42:04 +01:00
Mara Bos
d1b28f3a5f Fix clippy. 2023-03-16 12:08:07 +01:00
clubby789
f2eddc5924 Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
bors
491f63214a Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00