]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0398.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0398.md
CommitLineData
60c5eb7d
XL
1#### Note: this error code is no longer emitted by the compiler.
2
3In Rust 1.3, the default object lifetime bounds are expected to change, as
4described in [RFC 1156]. You are getting a warning because the compiler
5thinks it is possible that this change will cause a compilation error in your
6code. It is possible, though unlikely, that this is a false alarm.
7
8The 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
11affected are references to boxes, like `&Box<SomeTrait>` or
12`&[Box<SomeTrait>]`. More common types like `&SomeTrait` or `Box<SomeTrait>`
13are unaffected.
14
15To silence this warning, edit your code to use an explicit bound. Most of the
16time, this means that you will want to change the signature of a function that
17you are calling. For example, if the error is reported on a call like `foo(x)`,
18and `foo` is defined as follows:
19
20```
21# trait SomeTrait {}
22fn foo(arg: &Box<SomeTrait>) { /* ... */ }
23```
24
25You might change it to:
26
27```
28# trait SomeTrait {}
29fn foo<'a>(arg: &'a Box<SomeTrait+'a>) { /* ... */ }
30```
31
32This explicitly states that you expect the trait object `SomeTrait` to contain
33references (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