]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0303.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0303.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 Sub-bindings, e.g. `ref x @ Some(ref y)` are now allowed under
4 `#![feature(bindings_after_at)]` and checked to make sure that
5 memory safety is upheld.
6
7 --------------
8
9 In certain cases it is possible for sub-bindings to violate memory safety.
10 Updates to the borrow checker in a future version of Rust may remove this
11 restriction, but for now patterns must be rewritten without sub-bindings.
12
13 Before:
14
15 ```compile_fail
16 match Some("hi".to_string()) {
17     ref op_string_ref @ Some(s) => {},
18     None => {},
19 }
20 ```
21
22 After:
23
24 ```
25 match Some("hi".to_string()) {
26     Some(ref s) => {
27         let op_string_ref = &Some(s);
28         // ...
29     },
30     None => {},
31 }
32 ```
33
34 The `op_string_ref` binding has type `&Option<&String>` in both cases.
35
36 See also [Issue 14587][issue-14587].
37
38 [issue-14587]: https://github.com/rust-lang/rust/issues/14587