about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-01-12 00:01:53 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-02-11 02:59:06 +0000
commit39d73d5bbb3118382474f3df82b8c156d29fff01 (patch)
tree0f76172a02c14de9c17a8941cb02359523e31327 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parentb7ec4c13f34dae4a2309f5dcc074e149b36ea81b (diff)
downloadrust-39d73d5bbb3118382474f3df82b8c156d29fff01.tar.gz
rust-39d73d5bbb3118382474f3df82b8c156d29fff01.zip
Use MIR body to identify more "default equivalent" calls
When looking for `Default` impls that could be derived, we look at the
body of their `fn default()` and if it is an fn call or literal we check
if they are equivalent to what `#[derive(Default)]` would have used.

Now, when checking those fn calls in the `fn default()` body, we also
compare against the corresponding type's `Default::default` body to see
if our call is equivalent to that one.

For example, given

```rust
struct S;

impl S {
    fn new() -> S { S }
}

impl Default for S {
    fn default() -> S { S::new() }
}
```

`<S as Default>::default()` and `S::new()` are considered equivalent.
Given that, if the user also writes

```rust
struct R {
    s: S,
}

impl Default for R {
    fn default() -> R {
        R { s: S::new() }
    }
}
```

the `derivable_impls` lint will now trigger.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions