rust/compiler
Luigi Sartor Piucco 8a8717e971
fix: don't panic on volatile access to null
According to
https://discourse.llvm.org/t/rfc-volatile-access-to-non-dereferenceable-memory-may-be-well-defined/86303/4,
LLVM allows volatile operations on null and handles it correctly. This
should be allowed in Rust as well, because I/O memory may be hard-coded
to address 0 in some cases, like the AVR chip ATtiny1626.

A test case that ensured a failure when passing null to volatile was
removed, since it's now valid.

Due to the addition of `maybe_is_aligned` to `ub_checks`,
`maybe_is_aligned_and_not_null` was refactored to use it.

docs: revise restrictions on volatile operations

A distinction between usage on Rust memory vs. non-Rust memory was
introduced. Documentation was reworded to explain what that means, and
make explicit that:

- No trapping can occur from volatile operations;
- On Rust memory, all safety rules must be respected;
- On Rust memory, the primary difference from regular access is that
  volatile always involves a memory dereference;
- On Rust memory, the only data affected by an operation is the one
  pointed to in the argument(s) of the function;
- On Rust memory, provenance follows the same rules as non-volatile
  access;
- On non-Rust memory, any address known to not contain Rust memory is
  valid (including 0 and usize::MAX);
- On non-Rust memory, no Rust memory may be affected (it is implicit
  that any other non-Rust memory may be affected, though, even if not
  referenced by the pointer). This should be relevant when, for example,
  reading register A causes a flag to change in register B, or writing
  to A causes B to change in some way. Everything affected mustn't be
  inside an allocation.
- On non-Rust memory, provenance is irrelevant and a pointer with none
  can be used in a valid way.

fix: don't lint null as UB for volatile

Also remove a now-unneeded `allow` line.

fix: additional wording nits
2025-07-18 13:41:34 -03:00
..
rustc rename stable_mir to rustc_public, and rustc_smir to rustc_public_bridge 2025-07-14 09:25:54 +00:00
rustc_abi Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubilee 2025-07-07 17:28:14 +00:00
rustc_arena Introduce Arena::try_alloc_from_iter. 2025-04-19 01:13:18 +00:00
rustc_ast Rollup merge of #143631 - hkBst:update-escaper-2, r=compiler-errors 2025-07-17 10:41:45 +02:00
rustc_ast_ir Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_ast_lowering Allow Early stage to emit errors 2025-07-15 09:01:03 +02:00
rustc_ast_passes compiler: rename {ast,hir}::BareFn* to FnPtr* 2025-07-06 15:03:08 -07:00
rustc_ast_pretty fix: Include frontmatter in -Zunpretty output 2025-07-10 10:26:02 -05:00
rustc_attr_data_structures Auto merge of #140399 - tiif:unstable_impl, r=lcnr,BoxyUwU 2025-07-17 01:57:55 +00:00
rustc_attr_parsing Rollup merge of #143984 - JonathanBrouwer:fix-feature-gate-ice, r=Urgau 2025-07-17 10:41:49 +02:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Rollup merge of #143901 - compiler-errors:region-constraint-nits, r=lcnr 2025-07-14 18:05:47 +02:00
rustc_builtin_macros Improve path segment joining. 2025-07-17 08:37:19 +10:00
rustc_codegen_cranelift Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
rustc_codegen_gcc Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
rustc_codegen_llvm Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
rustc_codegen_ssa Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
rustc_const_eval Rollup merge of #143975 - RalfJung:type-id-eq, r=oli-obk 2025-07-17 10:41:48 +02:00
rustc_data_structures Fix wrong cache event query key 2025-07-07 15:16:42 +02:00
rustc_driver Remove recursion_limit increases. 2025-04-02 16:25:27 +11:00
rustc_driver_impl rename stable_mir to rustc_public, and rustc_smir to rustc_public_bridge 2025-07-14 09:25:54 +00:00
rustc_error_codes New example for E0536 2025-07-15 09:21:27 +02:00
rustc_error_messages Remove unused feature gates 2025-06-28 23:36:46 +00:00
rustc_errors Rollup merge of #143661 - Muscraft:other-suggestion-message, r=estebank 2025-07-11 07:35:20 +02:00
rustc_expand Rollup merge of #143984 - JonathanBrouwer:fix-feature-gate-ice, r=Urgau 2025-07-17 10:41:49 +02:00
rustc_feature Implement other logics 2025-07-15 13:48:30 +00:00
rustc_fluent_macro Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
rustc_fs_util Retry if creating temp fails with access denied 2025-04-25 11:28:36 +00:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Auto merge of #142903 - cjgillot:local-def-path-hash, r=compiler-errors 2025-07-17 08:36:42 +00:00
rustc_hir_analysis Auto merge of #144044 - fmease:rollup-kg413pt, r=fmease 2025-07-17 05:24:30 +00:00
rustc_hir_pretty Retire hir::*ItemRef. 2025-07-13 13:50:01 +00:00
rustc_hir_typeck Auto merge of #144044 - fmease:rollup-kg413pt, r=fmease 2025-07-17 05:24:30 +00:00
rustc_incremental Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk 2025-05-07 12:39:54 +00:00
rustc_index use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_index_macros In rustc_mir_tranform, iterate over index newtypes instead of ints 2025-04-12 11:53:07 +00:00
rustc_infer Simplify make_query_region_constraints 2025-07-13 19:22:17 +00:00
rustc_interface Avoid building C++ for rustc_llvm with --compile-time-deps 2025-07-11 13:32:03 +00:00
rustc_lexer test(lexer): Add frontmatter unit test 2025-07-10 10:25:29 -05:00
rustc_lint fix: don't panic on volatile access to null 2025-07-18 13:41:34 -03:00
rustc_lint_defs Implement resolver warnings about reexporting private dependencies 2025-07-15 15:44:25 +02:00
rustc_llvm Avoid building C++ for rustc_llvm with --compile-time-deps 2025-07-11 13:32:03 +00:00
rustc_log Add documentation for init_logger_with_additional_layer 2025-06-12 12:11:15 +02:00
rustc_macros Fix line break after ":" in unpretty attribute print 2025-07-06 09:51:47 +02:00
rustc_metadata resolve: Merge NameBindingKind::Module into NameBindingKind::Res 2025-07-16 08:28:17 +03:00
rustc_middle Auto merge of #144044 - fmease:rollup-kg413pt, r=fmease 2025-07-17 05:24:30 +00:00
rustc_mir_build Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obk 2025-07-14 04:29:53 +00:00
rustc_mir_dataflow Remove support for SwitchInt edge effects in backward dataflow analyses 2025-07-11 10:56:50 +02:00
rustc_mir_transform Propagate from borrowed locals in CopyProp 2025-07-10 09:36:20 +02:00
rustc_monomorphize Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
rustc_next_trait_solver Add the core logic in old and new solvers 2025-07-15 13:48:30 +00:00
rustc_parse Rollup merge of #143631 - hkBst:update-escaper-2, r=compiler-errors 2025-07-17 10:41:45 +02:00
rustc_parse_format update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_passes Auto merge of #144044 - fmease:rollup-kg413pt, r=fmease 2025-07-17 05:24:30 +00:00
rustc_pattern_analysis only check for mixed deref/normal constructors when needed 2025-07-04 23:47:31 -07:00
rustc_privacy Implement other logics 2025-07-15 13:48:30 +00:00
rustc_proc_macro update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_public Implement other logics 2025-07-15 13:48:30 +00:00
rustc_public_bridge rename stable_mir to rustc_public, and rustc_smir to rustc_public_bridge 2025-07-14 09:25:54 +00:00
rustc_query_impl Remove unused allow attrs 2025-07-07 12:58:16 +00:00
rustc_query_system use is_multiple_of instead of manual modulo 2025-07-05 10:55:35 +02:00
rustc_resolve Rollup merge of #143984 - JonathanBrouwer:fix-feature-gate-ice, r=Urgau 2025-07-17 10:41:49 +02:00
rustc_sanitizers Remove support for dyn* 2025-07-01 19:00:21 +00:00
rustc_serialize use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_session Fix CI 2025-07-15 13:48:30 +00:00
rustc_span Auto merge of #142903 - cjgillot:local-def-path-hash, r=compiler-errors 2025-07-17 08:36:42 +00:00
rustc_symbol_mangling Remove support for dyn* 2025-07-01 19:00:21 +00:00
rustc_target Rollup merge of #143409 - Gelbpunkt:xgot-mips64-musl, r=compiler-errors 2025-07-17 03:58:29 +02:00
rustc_thread_pool Correct comments. 2025-06-28 17:58:21 +08:00
rustc_trait_selection Rollup merge of #143431 - xizheyin:143392, r=compiler-errors 2025-07-17 10:41:44 +02:00
rustc_traits Implement other logics 2025-07-15 13:48:30 +00:00
rustc_transmute compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
rustc_ty_utils Rollup merge of #143793 - fmease:lta-opaq-inf-recur, r=oli-obk 2025-07-17 10:41:45 +02:00
rustc_type_ir Auto merge of #140399 - tiif:unstable_impl, r=lcnr,BoxyUwU 2025-07-17 01:57:55 +00:00
rustc_type_ir_macros Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00