about summary refs log tree commit diff
path: root/clippy_lints/src/dereference.rs
AgeCommit message (Collapse)AuthorLines
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-1/+1
The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424.
2025-02-06Merge commit '3e3715c31236bff56f1c63a1de2c7bbdfcfb0923' into ↵Philipp Krones-26/+41
clippy-subtree-update
2025-01-28Merge commit '51d49c1ae2785b24ef18a46ef233fc1d91844666' into ↵Philipp Krones-1/+1
clippy-subtree-update
2025-01-23`visit_x_unambig`Boxy-1/+1
2025-01-23The clipper :3cBoxy-19/+13
2024-12-26Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into ↵Philipp Krones-6/+5
clippy-subtree-update
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-1/+2
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-0/+1
2024-12-12Fix toolsMichael Goulet-0/+1
2024-12-10Remove more traces of anonymous ADTsMichael Goulet-1/+0
2024-11-30Eliminate magic numbers from expression precedenceDavid Tolnay-14/+14
2024-11-28Merge commit 'ff4a26d442bead94a4c96fb1de967374bc4fbd8e' into ↵Philipp Krones-8/+7
clippy-subtree-update
2024-11-26Rollup merge of #133140 - dtolnay:precedence, r=fmeaseMichael Goulet-5/+5
Inline ExprPrecedence::order into Expr::precedence The representation of expression precedence in rustc_ast has been an obstacle to further improvements in the pretty-printer (continuing from #119105 and #119427). Previously the operation of *"does this expression have lower precedence than that one"* (relevant for parenthesis insertion in macro-generated syntax trees) consisted of 3 steps: 1. Convert `Expr` to `ExprPrecedence` using `.precedence()` 2. Convert `ExprPrecedence` to `i8` using `.order()` 3. Compare using `<` As far as I can guess, the reason for the separation between `precedence()` and `order()` was so that both `rustc_ast::Expr` and `rustc_hir::Expr` could convert as straightforwardly as possible to the same `ExprPrecedence` enum, and then the more finicky logic performed by `order` could be present just once. The mapping between `Expr` and `ExprPrecedence` was intended to be as straightforward as possible: ```rust match self.kind { ExprKind::Closure(..) => ExprPrecedence::Closure, ... } ``` although there were exceptions of both many-to-one, and one-to-many: ```rust ExprKind::Underscore => ExprPrecedence::Path, ExprKind::Path(..) => ExprPrecedence::Path, ... ExprKind::Match(_, _, MatchKind::Prefix) => ExprPrecedence::Match, ExprKind::Match(_, _, MatchKind::Postfix) => ExprPrecedence::PostfixMatch, ``` Where the nature of `ExprPrecedence` becomes problematic is when a single expression kind might be associated with multiple different precedence levels depending on context (outside the expression) and contents (inside the expression). For example consider what is the precedence of an ExprKind::Closure `$closure`. Well, on the left-hand side of a binary operator it would need parentheses in order to avoid the trailing binary operator being absorbed into the closure body: `($closure) + Rhs`, so the precedence is something lower than that of `+`. But on the right-hand side of a binary operator, a closure is just a straightforward prefix expression like a unary op, which is a relatively high precedence level, higher than binops but lower than method calls: `Lhs + $closure` is fine without parens but `($closure).method()` needs them. But as a third case, if the closure contains an explicit return type, then the precedence is an even higher level than that, never needing parenthesization even in a binop left-hand side or method call: `|| -> bool { false } + Rhs` or `|| -> bool { false }.method()`. You can see that trying to capture all of this resolution about expressions into `ExprPrecedence` violates the intention of `ExprPrecedence` being a straightforward one-to-one correspondence from each AST and HIR `ExprKind` variant. It would be possible to attempt that by doing stuff like `ExprPrecedence::Closure(Side::Leading, ReturnType::No)`, but I don't foresee the original envisioned benefit of the `precedence()`/`order()` distinction being retained in this approach. Instead I want to move toward a model that Syn has been using successfully. In Syn, there is a Precedence enum but it differs from rustc in the following ways: - There are [relatively few variants](https://github.com/dtolnay/syn/blob/2.0.87/src/precedence.rs#L11-L47) compared to rustc's `ExprPrecedence`. For example there is no distinction at the precedence level between returns and closures, or between loops and method calls. - We distinguish between [leading](https://github.com/dtolnay/syn/blob/2.0.87/src/fixup.rs#L293) and [trailing](https://github.com/dtolnay/syn/blob/2.0.87/src/fixup.rs#L309) precedence, taking into account an expression's context such as what token follows it (for various syntactic bail-outs in Rust's grammar, like ambiguities around break-with-value) and how it relates to operators from the surrounding syntax tree. - There are no hardcoded mysterious integer quantities like rustc's `PREC_CLOSURE = -40`. All precedence comparisons are performed via PartialOrd on a C-like enum. This PR is just a first step in these changes. As you can tell from Syn, I definitely think there is value in having a dedicated type to represent precedence, instead of what `order()` is doing with `i8`. But that is a whole separate adventure because rustc_ast doesn't even agree consistently on `i8` being the type for precedence order; `AssocOp::precedence` instead uses `usize` and there are casts in both directions. It is likely that a type called `ExprPrecedence` will re-appear, but it will look substantially different from the one that existed before this PR.
2024-11-19remove `TypingMode::from_param_env` in clippylcnr-6/+9
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-1/+1
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-4/+5
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-17Inline ExprPrecedence::order into Expr::precedenceDavid Tolnay-5/+5
2024-10-29Remove region from adjustmentsMichael Goulet-1/+1
2024-09-24Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into ↵Philipp Krones-44/+29
clippy-subtree-update
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-1/+1
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-08Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into ↵Philipp Krones-2/+2
clippy-subtree-update
2024-07-11Merge commit 'b794b8e08c16517a941dc598bb1483e8e12a8592' into ↵Philipp Krones-11/+26
clippy-subtree-update
2024-06-27Merge commit '68a799aea9b65e2444fbecfe32217ce7d5a3604f' into ↵Philipp Krones-27/+21
clippy-subtree-update
2024-06-23Rename the 2 unambiguous precedence levels to PREC_UNAMBIGUOUSDavid Tolnay-3/+3
2024-05-30Auto merge of #125764 - flip1995:clippy-subtree-update, r=Manishearthbors-9/+5
Clippy subtree update r? `@Manishearth`
2024-05-30Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into ↵Philipp Krones-9/+5
clippy-subtree-update
2024-05-29Don't require `visit_body` to take a lifetime that must outlive the function ↵Oli Scherer-1/+1
call
2024-05-09Rename Generics::params to Generics::own_paramsMichael Goulet-1/+1
2024-05-02Merge commit '20b085d500dfba5afe0869707bf357af3afe20be' into ↵Philipp Krones-2/+2
clippy-subtree-update
2024-04-18Merge commit 'ca3b393750ee8d870bf3215dcf6509cafa5c0445' into ↵Philipp Krones-0/+9
clippy-subtree-update
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-2/+2
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+1
2024-04-08Thread pattern types through the HIROli Scherer-0/+1
2024-02-27Merge commit '10136170fe9ed01e46aeb4f4479175b79eb0e3c7' into ↵Philipp Krones-5/+3
clippy-subtree-update
2024-02-12Lower anonymous structs or unions to HIRFrank King-0/+1
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-1/+1
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+1
2024-01-12Delegation implementation: step 1Bryanskiy-0/+1
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-1/+1
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-01Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-syncPhilipp Krones-1/+1
2023-11-17rename bound region instantiationlcnr-1/+1
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-16Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyupPhilipp Krones-115/+168
2023-11-02Merge commit '09ac14c901abc43bd0d617ae4a44e8a4fed98d9c' into clippyupPhilipp Krones-28/+33
2023-10-20s/Generator/Coroutine/Oli Scherer-2/+2
2023-10-16fix lint failures in clippyArthur Lafrance-1/+1
2023-09-25Merge commit '7671c283a50b5d1168841f3014b14000f01dd204' into clippyupPhilipp Krones-369/+5
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-1/+0
2023-09-12Merge commit '98363cbf6a7c3f8b571a7d92a3c645bb4376e4a6' into clippyupPhilipp Krones-12/+19
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-1/+2
2023-08-06Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJungMatthias Krüger-1/+1
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`