diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /compiler/rustc_error_codes/src/error_codes/E0320.md | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0320.md')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0320.md | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0320.md b/compiler/rustc_error_codes/src/error_codes/E0320.md new file mode 100644 index 000000000..e6e1b7c19 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0320.md @@ -0,0 +1,27 @@ +Recursion limit reached while creating drop-check rules. + +Example of erroneous code: + +```compile_fail,E0320 +enum A<T> { + B, + C(T, Box<A<(T, T)>>) +} + +fn foo<T>() { + A::<T>::B; // error: overflow while adding drop-check rules for A<T> +} +``` + +The Rust compiler must be able to reason about how a type is [`Drop`]ped, and +by extension the types of its fields, to be able to generate the glue to +properly drop a value. The code example above shows a type where this inference +is impossible because it is recursive. Note that this is *not* the same as +[E0072](E0072.html), where a type has an infinite size; the type here has a +finite size but any attempt to `Drop` it would recurse infinitely. For more +information, read [the `Drop` docs](../std/ops/trait.Drop.html). + +It is not possible to define a type with recursive drop-check rules. All such +recursion must be removed. + +[`Drop`]: ../std/ops/trait.Drop.html |