]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0398.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0398.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 In Rust 1.3, the default object lifetime bounds are expected to change, as
4 described in [RFC 1156]. You are getting a warning because the compiler
5 thinks it is possible that this change will cause a compilation error in your
6 code. It is possible, though unlikely, that this is a false alarm.
7
8 The heart of the change is that where `&'a Box<SomeTrait>` used to default to
9 `&'a Box<SomeTrait+'a>`, it now defaults to `&'a Box<SomeTrait+'static>` (here,
10 `SomeTrait` is the name of some trait type). Note that the only types which are
11 affected are references to boxes, like `&Box<SomeTrait>` or
12 `&[Box<SomeTrait>]`. More common types like `&SomeTrait` or `Box<SomeTrait>`
13 are unaffected.
14
15 To silence this warning, edit your code to use an explicit bound. Most of the
16 time, this means that you will want to change the signature of a function that
17 you are calling. For example, if the error is reported on a call like `foo(x)`,
18 and `foo` is defined as follows:
19
20 ```
21 # trait SomeTrait {}
22 fn foo(arg: &Box<SomeTrait>) { /* ... */ }
23 ```
24
25 You might change it to:
26
27 ```
28 # trait SomeTrait {}
29 fn foo<'a>(arg: &'a Box<SomeTrait+'a>) { /* ... */ }
30 ```
31
32 This explicitly states that you expect the trait object `SomeTrait` to contain
33 references (with a maximum lifetime of `'a`).
34
35 [RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md