about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/traits.rs
AgeCommit message (Collapse)AuthorLines
2023-09-06make comments less crypticouz-a-1/+1
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-10/+4
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-2/+1
2023-06-19s/Clause/ClauseKindMichael Goulet-2/+2
2023-01-09refactor: cleanupRejyr-2/+0
2023-01-09migrate: `traits.rs`Rejyr-15/+12
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-1/+2
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-1/+1
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-23Migrate all diagnosticsNilstrieb-2/+2
2022-10-01Refactor rustc lint APIMaybe Waffle-17/+17
2022-06-30lint: port drop trait/glue diagnosticsDavid Wood-13/+8
Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-21Rename `~const Drop` to `~const Destruct`Deadbeef-4/+0
2022-03-16rustc_error: make ErrorReported impossible to constructmark-2/+2
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-01-26drive-by: use is_const and is_const_if_constMichael Goulet-2/+1
2021-12-03Use let_else in some more places in rustc_lintest31-12/+8
2021-09-09fmtDeadbeef-2/+2
2021-09-09Do not lint for ~const Drop boundsDeadbeef-0/+5
2021-08-22Rollup merge of #86747 - FabianWolff:issue-86653, r=GuillaumeGomezGuillaume Gomez-16/+20
Improve wording of the `drop_bounds` lint This PR addresses #86653. The issue is sort of a false positive of the `drop_bounds` lint, but I would argue that the best solution for #86653 is simply a rewording of the warning message and lint description, because even if the lint is _technically_ wrong, it still forces the programmer to think about what they are doing, and they can always use `#[allow(drop_bounds)]` if they think that they really need the `Drop` bound. There are two issues with the current warning message and lint description: - First, it says that `Drop` bounds are "useless", which is technically incorrect because they actually do have the effect of allowing you e.g. to call methods that also have a `Drop` bound on their generic arguments for some reason. I have changed the wording to emphasize not that the bound is "useless", but that it is most likely not what was intended. - Second, it claims that `std::mem::needs_drop` detects whether a type has a destructor. But I think this is also technically wrong: The `Drop` bound says whether the type has a destructor or not, whereas `std::mem::needs_drop` also takes nested types with destructors into account, even if the top-level type does not itself have one (although I'm not 100% sure about the exact terminology here, i.e. whether the "drop glue" of the top-level type counts as a destructor or not). cc `@jonhoo,` does this solve the issue for you? r? `@GuillaumeGomez`
2021-08-13move Constness into TraitPredicateDeadbeef-1/+1
2021-07-18feat(rustc_lint): add `dyn_drop`Michael Howell-1/+62
Based on the conversation in #86747. Explanation ----------- A trait object bound of the form `dyn Drop` is most likely misleading and not what the programmer intended. `Drop` bounds do not actually indicate whether a type can be trivially dropped or not, because a composite type containing `Drop` types does not necessarily implement `Drop` itself. Naïvely, one might be tempted to write a deferred drop system, to pull cleaning up memory out of a latency-sensitive code path, using `dyn Drop` trait objects. However, this breaks down e.g. when `T` is `String`, which does not implement `Drop`, but should probably be accepted. To write a trait object bound that accepts anything, use a placeholder trait with a blanket implementation. ```rust trait Placeholder {} impl<T> Placeholder for T {} fn foo(_x: Box<dyn Placeholder>) {} ```
2021-06-30Improve wording of the `drop_bounds` lintFabian Wolff-16/+20
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-2/+1
Items are guaranteed to be HIR owner.
2021-01-16Review changesJack Huey-2/+2
2020-10-01Uplift drop-bounds lint from clippyMichael Howell-0/+79