about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-07-03 11:20:01 -0700
committerMichael Howell <michael@notriddle.com>2021-07-18 07:55:57 -0700
commitdbd4fd5716fb53086e35aa5d1548f5f709e439a0 (patch)
tree370fcc1d53a7ba536b430e99a0c621b676b6eeb4 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parent18073052d8c3544ccb73effd289ed3acda0d66c0 (diff)
downloadrust-dbd4fd5716fb53086e35aa5d1548f5f709e439a0.tar.gz
rust-dbd4fd5716fb53086e35aa5d1548f5f709e439a0.zip
feat(rustc_lint): add `dyn_drop`
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>) {}
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions