rust/compiler
Matthias Krüger 77152955b8
Rollup merge of #127106 - spastorino:improve-unsafe-extern-blocks-diagnostics, r=compiler-errors
Improve unsafe extern blocks diagnostics

Closes #126327

For this code:

```rust
extern {
    pub fn foo();
    pub safe fn bar();
}
```

We get ...

```
error: items in unadorned `extern` blocks cannot have safety qualifiers
 --> test.rs:3:5
  |
3 |     pub safe fn bar();
  |     ^^^^^^^^^^^^^^^^^^
  |
help: add unsafe to this `extern` block
  |
1 | unsafe extern {
  | ++++++

error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
 --> test.rs:3:9
  |
3 |     pub safe fn bar();
  |         ^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
  = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
```

And then making the extern block unsafe, we get ...

```
error: extern block cannot be declared unsafe
 --> test.rs:1:1
  |
1 | unsafe extern {
  | ^^^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
  = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable

error: items in unadorned `extern` blocks cannot have safety qualifiers
 --> test.rs:3:5
  |
3 |     pub safe fn bar();
  |     ^^^^^^^^^^^^^^^^^^

error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
 --> test.rs:3:9
  |
3 |     pub safe fn bar();
  |         ^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
  = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.
```

r? ``@compiler-errors``
2024-06-29 22:10:57 +02:00
..
rustc Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=... 2024-05-02 19:48:29 +02:00
rustc_abi Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoerister 2024-06-25 15:51:35 +00:00
rustc_arena Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_ast Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
rustc_ast_ir Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_ast_lowering Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
rustc_ast_passes Rollup merge of #127106 - spastorino:improve-unsafe-extern-blocks-diagnostics, r=compiler-errors 2024-06-29 22:10:57 +02:00
rustc_ast_pretty Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
rustc_attr Use a dedicated type instead of a reference for the diagnostic context 2024-06-18 15:42:11 +00:00
rustc_baked_icu_data Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_borrowck Rollup merge of #126884 - estebank:issue-125634, r=Nadrieril 2024-06-25 18:03:00 +02:00
rustc_builtin_macros Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
rustc_codegen_cranelift cg_clif: Define build opts from FramePointer 2024-06-23 00:36:33 -07:00
rustc_codegen_gcc Remove type_i1 and type_struct from cg_ssa 2024-06-21 19:30:26 +00:00
rustc_codegen_llvm Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errors 2024-06-29 22:10:55 +02:00
rustc_codegen_ssa Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errors 2024-06-29 22:10:55 +02:00
rustc_const_eval Enable const casting for f16 and f128 2024-06-27 04:36:29 -05:00
rustc_data_structures rustc_data_structures: Explicitly check for 64-bit atomics support 2024-06-28 10:26:45 +02:00
rustc_driver Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_driver_impl Auto merge of #126834 - bjorn3:interface_refactor, r=michaelwoerister 2024-06-25 09:35:53 +00:00
rustc_error_codes Auto merge of #126319 - workingjubilee:rollup-lendnud, r=workingjubilee 2024-06-12 11:10:50 +00:00
rustc_error_messages Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_errors Clarify comment on changing to warn future breakage items 2024-06-26 17:00:46 +02:00
rustc_expand Rollup merge of #126928 - nnethercote:124141-pre, r=oli-obk 2024-06-27 02:06:19 -04:00
rustc_feature Rollup merge of #124741 - nebulark:patchable-function-entries-pr, r=estebank,workingjubilee 2024-06-28 08:34:07 +02:00
rustc_fluent_macro Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_fs_util Remove useless tidy-alphabetical markers. 2024-06-20 09:23:20 +10:00
rustc_graphviz Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_hir Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoerister 2024-06-25 15:51:35 +00:00
rustc_hir_analysis Make queries more explicit 2024-06-27 12:03:57 -04:00
rustc_hir_pretty Rename the 2 unambiguous precedence levels to PREC_UNAMBIGUOUS 2024-06-23 18:31:47 -07:00
rustc_hir_typeck Rollup merge of #126925 - surechen:fix_125631, r=compiler-errors 2024-06-26 07:50:18 +02:00
rustc_incremental Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_index Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_index_macros rustc_span: Minor improvements 2024-06-16 14:08:25 +03:00
rustc_infer Make queries more explicit 2024-06-27 12:03:57 -04:00
rustc_interface Updated diagnostic messages 2024-06-27 22:24:36 +02:00
rustc_lexer Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_lint Rollup merge of #127045 - compiler-errors:explicit, r=oli-obk 2024-06-29 09:14:57 +02:00
rustc_lint_defs sudo CI=green && Review changes <3 2024-06-25 18:06:22 +02:00
rustc_llvm Auto merge of #126907 - glaubitz:sparc-fixes, r=nagisa 2024-06-27 05:44:47 +00:00
rustc_log Bump tracing-tree and allow rendering lines again 2024-06-12 10:11:41 +00:00
rustc_macros Remove redundant argument from subdiagnostic method 2024-06-18 15:42:11 +00:00
rustc_metadata Make queries more explicit 2024-06-27 12:03:57 -04:00
rustc_middle Rollup merge of #127045 - compiler-errors:explicit, r=oli-obk 2024-06-29 09:14:57 +02:00
rustc_mir_build Rollup merge of #126835 - Nadrieril:reify-decision-tree, r=matthewjasper 2024-06-29 09:14:56 +02:00
rustc_mir_dataflow Save 2 pointers in TerminatorKind (96 → 80 bytes) 2024-06-21 18:02:05 -07:00
rustc_mir_transform Rollup merge of #127101 - matthiaskrgr:thonk, r=compiler-errors 2024-06-29 09:14:58 +02:00
rustc_monomorphize Use a dedicated type instead of a reference for the diagnostic context 2024-06-18 15:42:11 +00:00
rustc_next_trait_solver Make queries more explicit 2024-06-27 12:03:57 -04:00
rustc_parse Rollup merge of #127103 - compiler-errors:tighten-trait-bound-parsing, r=fmease 2024-06-29 09:14:59 +02:00
rustc_parse_format Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_passes Revert "Rollup merge of #126938 - RalfJung:link_section, r=compiler-errors" 2024-06-28 20:59:01 +00:00
rustc_pattern_analysis Replace f16 and f128 pattern matching stubs with real implementations 2024-06-23 04:28:42 -05:00
rustc_privacy Do not ICE in privacy when type inference fails. 2024-06-17 10:09:27 +00:00
rustc_query_impl Allow tracing through item_bounds query invocations on opaques 2024-06-19 08:47:55 +00:00
rustc_query_system Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoerister 2024-06-25 15:51:35 +00:00
rustc_resolve Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
rustc_sanitizers Split out IntoIterator and non-Iterator constructors for AliasTy/AliasTerm/TraitRef/projection 2024-06-24 11:28:21 -04:00
rustc_serialize Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_session Rollup merge of #124741 - nebulark:patchable-function-entries-pr, r=estebank,workingjubilee 2024-06-28 08:34:07 +02:00
rustc_smir Add method to get all attributes on a definition 2024-06-28 13:24:41 +08:00
rustc_span Rollup merge of #124741 - nebulark:patchable-function-entries-pr, r=estebank,workingjubilee 2024-06-28 08:34:07 +02:00
rustc_symbol_mangling Use a dedicated type instead of a reference for the diagnostic context 2024-06-18 15:42:11 +00:00
rustc_target rustc_target: Build sparc_unknown_linux_gnu with -mcpu=v9 and -m32 2024-06-24 17:58:21 +02:00
rustc_trait_selection Make queries more explicit 2024-06-27 12:03:57 -04:00
rustc_traits Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_transmute safe transmute: support non-ZST, variantful, uninhabited enums 2024-06-14 21:11:08 +00:00
rustc_ty_utils Rename InstanceDef -> InstanceKind 2024-06-16 21:35:21 -04:00
rustc_type_ir Make queries more explicit 2024-06-27 12:03:57 -04:00
rustc_type_ir_macros Uplift TraitPredicate 2024-05-11 18:20:00 -04:00
stable_mir Add method to get all attributes on a definition 2024-06-28 13:24:41 +08:00