diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_error_codes | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0133.md | 19 | ||||
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0741.md | 12 |
2 files changed, 26 insertions, 5 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0133.md b/compiler/rustc_error_codes/src/error_codes/E0133.md index 1adbcc313..8ca3f03ce 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0133.md +++ b/compiler/rustc_error_codes/src/error_codes/E0133.md @@ -1,4 +1,4 @@ -Unsafe code was used outside of an unsafe function or block. +Unsafe code was used outside of an unsafe block. Erroneous code example: @@ -30,4 +30,21 @@ fn main() { See the [unsafe section][unsafe-section] of the Book for more details. +#### Unsafe code in functions + +Unsafe code is currently accepted in unsafe functions, but that is being phased +out in favor of requiring unsafe blocks here too. + +``` +unsafe fn f() { return; } + +unsafe fn g() { + f(); // Is accepted, but no longer recommended + unsafe { f(); } // Recommended way to write this +} +``` + +Linting against this is controlled via the `unsafe_op_in_unsafe_fn` lint, which +is `allow` by default but will be upgraded to `warn` in a future edition. + [unsafe-section]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html diff --git a/compiler/rustc_error_codes/src/error_codes/E0741.md b/compiler/rustc_error_codes/src/error_codes/E0741.md index 70d963cd4..0c7010526 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0741.md +++ b/compiler/rustc_error_codes/src/error_codes/E0741.md @@ -10,15 +10,19 @@ struct A; struct B<const X: A>; // error! ``` -Only structural-match types (that is, types that derive `PartialEq` and `Eq`) -may be used as the types of const generic parameters. +Only structural-match types, which are types that derive `PartialEq` and `Eq` +and implement `ConstParamTy`, may be used as the types of const generic +parameters. -To fix the previous code example, we derive `PartialEq` and `Eq`: +To fix the previous code example, we derive `PartialEq`, `Eq`, and +`ConstParamTy`: ``` #![feature(adt_const_params)] -#[derive(PartialEq, Eq)] // We derive both traits here. +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] // We derive both traits here. struct A; struct B<const X: A>; // ok! |