Skip to content

Commit a3fa189

Browse files
authored
Rollup merge of rust-lang#65294 - varkor:lint-inline-prototype, r=matthewjasper
Lint ignored `#[inline]` on function prototypes Fixes rust-lang#51280. - Adds a `unused_attribute` lint for `#[inline]` on function prototypes. - As a consequence, foreign items, impl items and trait items now have their attributes checked, which could cause some code to no longer compile (it was previously erroneously ignored).
2 parents cac6821 + f47f530 commit a3fa189

29 files changed

+461
-207
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ dependencies = [
150150

151151
[[package]]
152152
name = "bitflags"
153-
version = "1.1.0"
153+
version = "1.2.1"
154154
source = "registry+https://github.com/rust-lang/crates.io-index"
155-
checksum = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
155+
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
156156

157157
[[package]]
158158
name = "blake2-rfc"

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
arena = { path = "../libarena" }
14-
bitflags = "1.0"
14+
bitflags = "1.2.1"
1515
fmt_macros = { path = "../libfmt_macros" }
1616
graphviz = { path = "../libgraphviz" }
1717
jobserver = "0.1"

src/librustc/error_codes.rs

+52-1
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,7 @@ rejected in your own crates.
22192219
"##,
22202220

22212221
E0736: r##"
2222-
#[track_caller] and #[naked] cannot be applied to the same function.
2222+
`#[track_caller]` and `#[naked]` cannot both be applied to the same function.
22232223
22242224
Erroneous code example:
22252225
@@ -2237,6 +2237,57 @@ See [RFC 2091] for details on this and other limitations.
22372237
[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
22382238
"##,
22392239

2240+
E0738: r##"
2241+
`#[track_caller]` cannot be used in traits yet. This is due to limitations in
2242+
the compiler which are likely to be temporary. See [RFC 2091] for details on
2243+
this and other restrictions.
2244+
2245+
Erroneous example with a trait method implementation:
2246+
2247+
```compile_fail,E0738
2248+
#![feature(track_caller)]
2249+
2250+
trait Foo {
2251+
fn bar(&self);
2252+
}
2253+
2254+
impl Foo for u64 {
2255+
#[track_caller]
2256+
fn bar(&self) {}
2257+
}
2258+
```
2259+
2260+
Erroneous example with a blanket trait method implementation:
2261+
2262+
```compile_fail,E0738
2263+
#![feature(track_caller)]
2264+
2265+
trait Foo {
2266+
#[track_caller]
2267+
fn bar(&self) {}
2268+
fn baz(&self);
2269+
}
2270+
```
2271+
2272+
Erroneous example with a trait method declaration:
2273+
2274+
```compile_fail,E0738
2275+
#![feature(track_caller)]
2276+
2277+
trait Foo {
2278+
fn bar(&self) {}
2279+
2280+
#[track_caller]
2281+
fn baz(&self);
2282+
}
2283+
```
2284+
2285+
Note that while the compiler may be able to support the attribute in traits in
2286+
the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
2287+
2288+
[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
2289+
"##,
2290+
22402291
;
22412292
// E0006, // merged with E0005
22422293
// E0101, // replaced with E0282

0 commit comments

Comments
 (0)