Skip to content

Commit 6efada0

Browse files
committed
add diagnostic note for #[ffi_pure] with #[ffi_const]
1 parent ab6b211 commit 6efada0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,9 @@ pub(crate) enum InvalidMachoSectionReason {
11591159

11601160
#[derive(Diagnostic)]
11611161
#[diag("`#[ffi_const]` function cannot be `#[ffi_pure]`", code = E0757)]
1162+
#[note("`#[ffi_pure]` is redundant here because `#[ffi_const]` provides stronger guarantees")]
11621163
pub(crate) struct BothFfiConstAndPure {
11631164
#[primary_span]
1165+
#[suggestion("remove `#[ffi_pure]`", code = "", applicability = "maybe-incorrect")]
11641166
pub attr_span: Span,
11651167
}

tests/ui/ffi-attrs/ffi_const2.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0757]: `#[ffi_const]` function cannot be `#[ffi_pure]`
22
--> $DIR/ffi_const2.rs:4:5
33
|
44
LL | #[unsafe(ffi_pure)]
5-
| ^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^ help: remove `#[ffi_pure]`
6+
|
7+
= note: `#[ffi_pure]` is redundant here because `#[ffi_const]` provides stronger guarantees
68

79
error: aborting due to 1 previous error
810

0 commit comments

Comments
 (0)