about summary refs log tree commit diff
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-19 18:40:33 +0000
committerbors <bors@rust-lang.org>2024-07-19 18:40:33 +0000
commitff4b39867e3033864315bf3cada039e92a6b751e (patch)
treea9fb8f61fccf3ab188bea07474e2e40da8bf5d67 /compiler/rustc_error_codes
parent0cd01aac6a80735cc936f75b45e3545a5273e2ad (diff)
parente28be0d16892825141044350d39766be3fa228ac (diff)
downloadrust-ff4b39867e3033864315bf3cada039e92a6b751e.tar.gz
rust-ff4b39867e3033864315bf3cada039e92a6b751e.zip
Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #127295 (CFI: Support provided methods on traits)
 - #127814 (`C-cmse-nonsecure-call`: improved error messages)
 - #127949 (fix: explain E0120 better cover cases when its raised)
 - #127966 (Use structured suggestions for unconstrained generic parameters on impl blocks)
 - #127976 (Lazy type aliases: Diagostics: Detect bivariant ty params that are only used recursively)
 - #127978 (Avoid ref when using format! for perf)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0120.md24
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0798.md39
-rw-r--r--compiler/rustc_error_codes/src/lib.rs1
3 files changed, 56 insertions, 8 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0120.md b/compiler/rustc_error_codes/src/error_codes/E0120.md
index dc7258d8731..aa701df5774 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0120.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0120.md
@@ -1,7 +1,7 @@
-Drop was implemented on a trait, which is not allowed: only structs and
-enums can implement Drop.
+`Drop` was implemented on a trait object or reference, which is not allowed;
+only structs, enums, and unions can implement Drop.
 
-Erroneous code example:
+Erroneous code examples:
 
 ```compile_fail,E0120
 trait MyTrait {}
@@ -11,8 +11,16 @@ impl Drop for MyTrait {
 }
 ```
 
-A workaround for this problem is to wrap the trait up in a struct, and implement
-Drop on that:
+```compile_fail,E0120
+struct Concrete {}
+
+impl Drop for &'_ mut Concrete  {
+    fn drop(&mut self) {}
+}
+```
+
+A workaround for traits is to create a wrapper struct with a generic type,
+add a trait bound to the type, and implement `Drop` on the wrapper:
 
 ```
 trait MyTrait {}
@@ -24,13 +32,13 @@ impl <T: MyTrait> Drop for MyWrapper<T> {
 
 ```
 
-Alternatively, wrapping trait objects requires something:
+Alternatively, the `Drop` wrapper can contain the trait object:
 
 ```
 trait MyTrait {}
 
-//or Box<MyTrait>, if you wanted an owned trait object
-struct MyWrapper<'a> { foo: &'a MyTrait }
+// or Box<dyn MyTrait>, if you wanted an owned trait object
+struct MyWrapper<'a> { foo: &'a dyn MyTrait }
 
 impl <'a> Drop for MyWrapper<'a> {
     fn drop(&mut self) {}
diff --git a/compiler/rustc_error_codes/src/error_codes/E0798.md b/compiler/rustc_error_codes/src/error_codes/E0798.md
new file mode 100644
index 00000000000..da08cde3010
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0798.md
@@ -0,0 +1,39 @@
+Functions marked as `C-cmse-nonsecure-call` place restrictions on their
+inputs and outputs.
+
+- inputs must fit in the 4 available 32-bit argument registers. Alignment
+is relevant.
+- outputs must either fit in 4 bytes, or be a foundational type of
+size 8 (`i64`, `u64`, `f64`).
+- no generics can be used in the signature
+
+For more information,
+see [arm's aapcs32](https://github.com/ARM-software/abi-aa/releases).
+
+Erroneous code example:
+
+```ignore (only fails on supported targets)
+#![feature(abi_c_cmse_nonsecure_call)]
+
+#[no_mangle]
+pub fn test(
+    f: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
+) -> u32 {
+    f(1, 2, 3, 4, 5)
+}
+```
+
+Arguments' alignment is respected. In the example below, padding is inserted
+so that the `u64` argument is passed in registers r2 and r3. There is then no
+room left for the final `f32` argument
+
+```ignore (only fails on supported targets)
+#![feature(abi_c_cmse_nonsecure_call)]
+
+#[no_mangle]
+pub fn test(
+    f: extern "C-cmse-nonsecure-call" fn(u32, u64, f32) -> u32,
+) -> u32 {
+    f(1, 2, 3.0)
+}
+```
diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs
index d13d5e1bca2..2a7bc2501c0 100644
--- a/compiler/rustc_error_codes/src/lib.rs
+++ b/compiler/rustc_error_codes/src/lib.rs
@@ -536,6 +536,7 @@ E0794: 0794,
 E0795: 0795,
 E0796: 0796,
 E0797: 0797,
+E0798: 0798,
         );
     )
 }