rust/compiler/rustc_lint/src
Matthias Krüger 6d7d366fd3
Rollup merge of #141260 - LuigiPiucco:volatile-null, r=RalfJung
Allow volatile access to non-Rust memory, including address 0

This PR relaxes the `ub_check` in the `read_volatile`/`write_volatile` pointer operations to allow passing null. This is needed to support processors which hard-code peripheral registers on address 0, like the AVR chip ATtiny1626. LLVM understands this as valid and handles it correctly, as tested in my [PR to add a note about it](https://github.com/llvm/llvm-project/pull/139803/commits/6387c82255c56d3035d249eb54110695e76b8030#diff-81bbb96298c32fa901beb82ab3b97add27a410c01d577c1f8c01000ed2055826) (rustc generates the same LLVM IR as expected there when this PR is applied, and consequently the same AVR assembly).

Follow-up and implementation of the discussions in:
- https://internals.rust-lang.org/t/pre-rfc-conditionally-supported-volatile-access-to-address-0/12881/7
- https://github.com/Rahix/avr-device/pull/185;
- [#t-lang > Adding the possibility of volatile access to address 0](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Adding.20the.20possibility.20of.20volatile.20access.20to.20address.200/with/513303502)
- https://discourse.llvm.org/t/rfc-volatile-access-to-non-dereferenceable-memory-may-be-well-defined/86303

r? ````@RalfJung````

Also fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/29 (about as good as it'll get, null will likely never be a "normal" address in Rust)
2025-07-20 08:56:05 +02:00
..
early Implement resolver warnings about reexporting private dependencies 2025-07-15 15:44:25 +02:00
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
types added error for invalid char cast 2025-07-10 15:44:36 +05:00
async_closures.rs Move some Map methods onto TyCtxt. 2025-02-17 13:21:02 +11:00
async_fn_in_trait.rs nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
autorefs.rs setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
builtin.rs Rollup merge of #144008 - anatawa12:fix-double-negations, r=compiler-errors 2025-07-18 04:27:53 +02:00
context.rs Add track_caller attributes to trace origin of Clippy lints 2025-07-02 11:50:25 +02:00
dangling.rs Port #[rustc_as_ptr] to the new attribute system 2025-06-16 18:13:27 +03:00
default_could_be_derived.rs Port #[automatically_derived] to the new attribute parsing infrastructure 2025-07-12 17:48:50 +02:00
deref_into_dyn_supertrait.rs Retire hir::*ItemRef. 2025-07-13 13:50:01 +00:00
drop_forget_useless.rs Move methods from Map to TyCtxt, part 3. 2025-02-21 14:31:09 +11:00
early.rs early linting: avoid redundant calls to check_id 2025-06-12 19:01:19 +08:00
enum_intrinsics_non_enums.rs Fold visit into ty 2025-03-15 06:34:36 +00:00
errors.rs Move eager translation to a method on Diag 2025-04-16 21:38:59 -04:00
expect.rs Reduce uses of hir_crate. 2025-06-18 15:46:19 +00:00
for_loops_over_fallibles.rs Use span before macro expansion in lint for-loops-over-falibles 2025-05-08 21:17:33 +08:00
foreign_modules.rs Port #[link_name] to the new attribute parsing infrastructure 2025-06-28 13:53:37 +02:00
if_let_rescope.rs setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
impl_trait_overcaptures.rs Same for types 2025-07-04 18:26:09 +00:00
internal.rs Implement lint against direct uses of rustc_type_ir in compiler crates 2025-06-18 16:01:41 +02:00
invalid_from_utf8.rs Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
late.rs Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
let_underscore.rs Rustfmt 2025-02-08 22:12:13 +00:00
levels.rs Port #[automatically_derived] to the new attribute parsing infrastructure 2025-07-12 17:48:50 +02:00
lib.rs Reword mismatched-lifetime-syntaxes text based on feedback 2025-07-14 09:52:58 -04:00
lifetime_syntax.rs Reword mismatched-lifetime-syntaxes text based on feedback 2025-07-14 09:52:58 -04:00
lints.rs Rollup merge of #143914 - shepmaster:mismatched-lifetime-syntaxes-rewording, r=traviscross,jieyouxu 2025-07-17 10:41:47 +02:00
macro_expr_fragment_specifier_2024_migration.rs Rename RefTokenTreeCursor. 2024-12-18 10:39:07 +11:00
map_unit_fn.rs Stop using Key trait randomly 2025-07-05 18:37:11 +00:00
multiple_supertrait_upcastable.rs parse const trait Trait 2025-07-17 18:06:26 +08:00
non_ascii_idents.rs Make LevelAndSource a struct 2025-04-03 09:17:55 +00:00
non_fmt_panic.rs Use Option<Symbol> in panic_call. 2025-03-25 16:14:27 +11:00
non_local_def.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
nonstandard_style.rs Allow Early stage to emit errors 2025-07-15 09:01:03 +02:00
noop_method_call.rs Rustfmt 2025-02-08 22:12:13 +00:00
opaque_hidden_inferred_bound.rs Squash fold into ty 2025-03-15 06:34:36 +00:00
pass_by_value.rs Port #[rustc_pass_by_value] to the new attribute system 2025-07-04 00:07:56 +03:00
passes.rs Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
precedence.rs Temporarily switch ambiguous_negative_literals lint to allow 2024-07-31 19:36:47 +02:00
ptr_nulls.rs fix: don't panic on volatile access to null 2025-07-18 13:41:34 -03:00
redundant_semicolon.rs Dont suggest remove semi inside macro expansion for redundant semi lint 2025-06-18 00:36:51 +08:00
reference_casting.rs setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
shadowed_into_iter.rs Use is_lang_item and as_lang_item instead of handrolling their logic 2025-04-22 11:02:37 +00:00
static_mut_refs.rs Fix error message for static references or mutable references 2025-04-26 14:48:30 +09:00
tests.rs update cfg(bootstrap) 2025-01-08 21:26:39 +01:00
traits.rs Rustfmt 2025-02-08 22:12:13 +00:00
transmute.rs Make UNNECESSARY_TRANSMUTES into a HIR lint 2025-05-25 15:57:48 +00:00
types.rs improve lint doc text 2025-07-09 09:08:56 +00:00
unit_bindings.rs Rustfmt 2025-02-08 22:12:13 +00:00
unqualified_local_imports.rs Overhaul UsePath. 2025-06-03 08:23:21 +10:00
unused.rs Remove uncessary parens in closure body with unused lint 2025-07-10 09:25:56 +08:00
utils.rs Uplift clippy::invalid_null_ptr_usage as invalid_null_arguments 2025-03-30 19:33:15 +02:00