Commit graph

12 commits

Author SHA1 Message Date
Michael Wright
8fa023272f Fix allow bug in trivially_copy_pass_by_ref
Closes #3992
2019-07-03 07:15:21 +02:00
Matthias Krüger
5d58163f7d trivially_copy_pass_by_ref: print size of type and limit in the lint message 2019-05-23 23:48:20 +02:00
Philipp Hansch
38d4ac7cea
Remove all copyright license headers
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
2019-01-08 21:46:39 +01:00
Matthias Krüger
435299be30 rustfmt tests 2018-12-09 23:26:16 +01:00
Wayne Warren
67c32eb2c4 Update trivially_copy_pass_by_ref with Trait examples 2018-11-21 07:52:02 -06:00
Oliver Scherer
b8654eaa6c Stabilize tool lints 2018-10-11 12:16:22 +02:00
Manish Goregaokar
e9c025ea70 Add license header to Rust files 2018-10-06 09:43:08 -07:00
flip1995
1b6f6051a8 Adapt ui-tests to the tool_lints 2018-08-29 11:08:29 -07:00
Michael Wright
ffce3c77e4 Fix #3000 2018-08-06 08:20:50 +02:00
Ryan Cumming
08d6b3d2f6 Allow pass by ref when returning ADT with ref
This is a follow-up to #2951 that extends the logic to allow for
returning references inside structs/enums/unions. This was a simple
oversight in the first version and it's surprisingly easy to handle.
2018-08-02 17:57:49 +10:00
Ryan Cumming
58459abd0c Allow pass by reference if we return a reference
Currently this code will trigger `trivally_copy_pass_by_ref`:

```
struct OuterStruct {
    field: [u8; 8],
}

fn return_inner(outer: &OuterStruct) -> &[u8] {
    &outer.field
}
```

If we change the `outer` to be pass-by-value it will not live long
enough for us to return the reference. The above example is trivial but
I've hit this in real code that either returns a reference to either the
argument or in to `self`.

This suppresses the `trivally_copy_pass_by_ref` lint if we return a
reference and it has the same lifetime as the argument. This will likely
miss complex cases with multiple lifetimes bounded by each other but it
should cover the majority of cases with little effort.
2018-07-23 18:44:40 +10:00
Wim Looman
7547a4ddef New Lint: Pass small trivially copyable objects by value
Fixes #1680

Hardcoded for 64-bit "trivial" size for now
2018-06-15 16:53:34 +02:00