about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-07-16zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`Erik Kaneda-1/+2
This also adds an additional `unsafe` block to address compiler errors.
2024-07-16Auto merge of #126484 - Oneirical:test-in-peace, r=jieyouxu,kobzolbors-50/+83
Migrate `std-core-cycle`, `obey-crate-type-flag`, `mixing-libs` and `issue-18943` `run-make` tests to `rmake.rs` Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). try-job: x86_64-apple-1 try-job: x86_64-msvc try-job: aarch64-gnu
2024-07-16Auto merge of #127819 - matthiaskrgr:rollup-djdffkl, r=matthiaskrgrbors-500/+643
Rollup of 8 pull requests Successful merges: - #127669 (Fix the issue of invalid suggestion for a reference of iterator) - #127707 (match lowering: Use an iterator to find `expand_until`) - #127730 (Fix and enforce `unsafe_op_in_unsafe_fn` in compiler) - #127789 (delete #![allow(unsafe_op_in_unsafe_fn)] in teeos) - #127805 (run-make-support: update gimli to 0.31.0) - #127808 (Make ErrorGuaranteed discoverable outside types, consts, and lifetimes) - #127817 (Fix a bunch of sites that were walking instead of visiting, making it impossible for visitor impls to look at these values) - #127818 (Various ast validation simplifications) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-16Rollup merge of #127818 - oli-obk:ast_validation_simplifications, r=petrochenkovMatthias Krüger-71/+27
Various ast validation simplifications Changes pulled out of https://github.com/rust-lang/rust/pull/127524 These are needed to make ast validation a mutable visitor, as we can't keep immutable references to the AST around in that case. But I think they are simplifying things in general and can stand on their own
2024-07-16Rollup merge of #127817 - oli-obk:mut_visitor_fix, r=petrochenkovMatthias Krüger-3/+3
Fix a bunch of sites that were walking instead of visiting, making it impossible for visitor impls to look at these values This doesn't affects anything right now, but a `MutVisitor` impl could be surprised by this. The reason this doesn't affect anything is that no one overrrides `visit_lifetime` or `visit_param_bounds` currently.
2024-07-16Rollup merge of #127808 - oli-obk:tainting_visitors2, r=lcnr,nnethercoteMatthias Krüger-32/+38
Make ErrorGuaranteed discoverable outside types, consts, and lifetimes types like `PatKind` could contain `ErrorGuaranteed`, but not return them via `tainted_by_errors` or `error_reported` (see https://github.com/rust-lang/rust/pull/127687#discussion_r1679027883). Now this happens, but it's a bit fragile as you can see with the `TypeSuperVisitable for Ty` impl. We will catch any problems around Ty, Region or Const at runtime with an assert, and everything using derives will not have such issues, as it will just invoke the `TypeVisitable for ErrorGuaranteed` impl
2024-07-16Rollup merge of #127805 - Mrmaxmeier:run-make-bump-gimli, r=jieyouxuMatthias Krüger-2/+13
run-make-support: update gimli to 0.31.0 This version bump is required for the tests in #126985 as suggested [here](https://github.com/rust-lang/rust/pull/126985#issuecomment-2196745112). r​? tgross35 (^ that didn't work. cc `@tgross35)` try-job: x86_64-msvc try-job: x86_64-mingw try-job: aarch64-apple try-job: test-various try-job: armhf-gnu try-job: dist-x86_64-linux
2024-07-16Rollup merge of #127789 - Sword-Destiny:master, r=petrochenkovMatthias Krüger-27/+29
delete #![allow(unsafe_op_in_unsafe_fn)] in teeos deny unsafe_op_in_unsafe_fn for teeos
2024-07-16Rollup merge of #127730 - compiler-errors:ed-2024-unsafe, r=petrochenkovMatthias Krüger-350/+432
Fix and enforce `unsafe_op_in_unsafe_fn` in compiler In preparation for edition 2024, this PR previews the fallout of enabling the `unsafe_op_in_unsafe_fn` lint in the compiler, since it's defaulting to warn in the new edition (#112038). The major annoyance comes primarily from the `rustc_codegen_llvm` module, where there's a ton of unsafe calls. I tended to wrap individual calls to unsafe fns in `unsafe {}`, but there a handful of places I chose to just wrap several calls in an `unsafe {}` block just because it would've been excessive to wrap each call individually. This doesn't enable the lint for the standard library, since I'm not totally certain what T-libs prefers w/ this lint.
2024-07-16Rollup merge of #127707 - Zalathar:expand-until, r=NadrierilMatthias Krüger-14/+19
match lowering: Use an iterator to find `expand_until` A small cleanup that I noticed while looking at #127164. This makes it easier to see that the split point is always the index after the found item, or the whole list if no stopping point was found. r? `@Nadrieril`
2024-07-16Rollup merge of #127669 - chenyukang:yukang-fix-deref-127590, r=nnethercoteMatthias Krüger-1/+82
Fix the issue of invalid suggestion for a reference of iterator Fixes #127590
2024-07-16Fix a bunch of sites that were walking instead of visiting, making it ↵Oli Scherer-3/+3
impossible for visitor impls to look at these values
2024-07-16Remove a boilerplaty abstractionOli Scherer-61/+17
2024-07-16Remove a needless borrowOli Scherer-7/+7
2024-07-16Just store a span instead of the whole itemOli Scherer-3/+3
2024-07-16Remove an unnecessary implOli Scherer-6/+9
2024-07-16Fix the issue of invalid suggestion for a reference of iteratoryukang-9/+3
2024-07-16add test for issue 127590yukang-0/+87
2024-07-16Make `ErrorGuaranteed` discoverable outside types, consts, and lifetimesOli Scherer-26/+29
2024-07-16Auto merge of #127617 - lnicola:sync-from-ra, r=lnicolabors-4424/+7363
Subtree update of `rust-analyzer` r? `@ghost`
2024-07-16run-make-support: update gimli to 0.31.0Mrmaxmeier-2/+13
2024-07-16Auto merge of #127796 - tgross35:rollup-ubo5hzb, r=tgross35bors-274/+629
Rollup of 6 pull requests Successful merges: - #120990 (Suggest a borrow when using dbg) - #127047 (fix least significant digits of f128 associated constants) - #127709 (match lowering: Move `MatchPair` tree creation to its own module) - #127770 (Update books) - #127780 (Make sure trait def ids match before zipping args in `note_function_argument_obligation`) - #127795 (Fix typos in RELEASES.md) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-16Use re-exported Idx and IndexVec in pat_analysisLaurențiu Nicola-3/+2
2024-07-16Rollup merge of #127795 - programmerjake:patch-3, r=cuviperTrevor Gross-4/+4
Fix typos in RELEASES.md as requested in https://github.com/rust-lang/blog.rust-lang.org/pull/1358#discussion_r1678691772 r? `@cuviper`
2024-07-16Rollup merge of #127780 - compiler-errors:zip-args, r=jieyouxuTrevor Gross-20/+98
Make sure trait def ids match before zipping args in `note_function_argument_obligation` Fixes #126416 Fixes #127745 Didn't add both tests b/c I felt like it was unnecessary.
2024-07-16Rollup merge of #127770 - rustbot:docs-update, r=ehussTrevor Gross-0/+0
Update books ## rust-lang/book 3 commits in f1e49bf7a8ea6c31ce016a52b8a4f6e1ffcfbc64..67fa536768013d9d5a13f3a06790521d511ef711 2024-07-12 21:21:45 UTC to 2024-07-05 17:35:06 UTC - Use Rust 2021 Edition for mdBook (rust-lang/book#3974) - Backport changes to chapter 11 (rust-lang/book#3969) - Upgrade to Rust 1.79.0 (rust-lang/book#3968) ## rust-lang/edition-guide 2 commits in 941db8b3df45fd46cd87b50a5c86714b91dcde9c..5454de3d12b9ccc6375b629cf7ccda8264640aac 2024-07-14 07:06:34 UTC to 2024-07-12 06:05:29 UTC - Update timeline etc. for Rust 2024 - 2024: Add note about never_type_fallback_flowing_into_unsafe lint level. (rust-lang/edition-guide#311) ## rust-embedded/book 1 commits in b10c6acaf0f43481f6600e95d4b5013446e29f7a..019f3928d8b939ec71b63722dcc2e46330156441 2024-07-11 17:46:10 UTC to 2024-07-11 17:46:10 UTC - typo on tooling.md (rust-embedded/book#373) ## rust-lang/reference 9 commits in 1ae3deebc3ac16e276b6558e01420f8e605def08..e2f0bdc4031866734661dcdb548184bde1450baf 2024-06-29 16:59:51 +0000 to 2024-07-15 17:52:44 +0000 - Suppress type length limit test and note that it is not enforced (rust-lang/reference#1527) - elaborate on slice wide pointer metadata (rust-lang/reference#1499) - '.inst' in inline-assembly changed to '.insn' (rust-lang/reference#1453) - Clarify that `asm!` blocks can be duplicated or deduplicated by the compiler (rust-lang/reference#1441) - Add mdbook-spec (rust-lang/reference#1520) - Add note about static libraries not linking their dependencies (rust-lang/reference#1472) - more explicitly explain the UB around immutable extern statics (rust-lang/reference#1502) - Improvements to `items/functions.md` (rust-lang/reference#1458) - Enable mdbook smart-punctuation. (rust-lang/reference#1516) ## rust-lang/rust-by-example 1 commits in 658c6c27cb975b92227936024816986c2d3716fb..89aecb6951b77bc746da73df8c9f2b2ceaad494a 2024-07-11 12:33:43 UTC to 2024-07-11 12:33:43 UTC - Update option_result.md (rust-lang/rust-by-example#1864) ## rust-lang/rustc-dev-guide 6 commits in d6e3a32a557db5902e714604def8015d6bb7e0f7..0c4d55cb59fe440d1a630e4e5774d043968edb3f 2024-07-15 15:16:43 UTC to 2024-07-01 19:05:14 UTC - Improve documentation of MIR queries & passes (rust-lang/rustc-dev-guide#1434) - Bump dependencies for date-check tool (rust-lang/rustc-dev-guide#2012) - Fix typo: lists -> lints (rust-lang/rustc-dev-guide#2011) - use "bootstrap" instead of "rustbuild" (rust-lang/rustc-dev-guide#2010) - Fix grammar issue in optimize-build.md (rust-lang/rustc-dev-guide#2009) - Update name of Fuchsia builder (rust-lang/rustc-dev-guide#2008)
2024-07-16Rollup merge of #127709 - Zalathar:pair-mod, r=NadrierilTrevor Gross-245/+272
match lowering: Move `MatchPair` tree creation to its own module This makes it easier to see that `MatchPair::new` has only one non-recursive caller, because the recursive callers are all in this module. No functional changes. --- I have used `git diff --color-moved` to verify that the moved code is identical to the old code, except for reduced visibility on the helper methods.
2024-07-16Rollup merge of #127047 - tspiteri:f128-aconsts-lsd, r=tgross35Trevor Gross-3/+3
fix least significant digits of f128 associated constants While the numbers are parsed to the correct value, the decimal numbers in the source were rounded to zero instead of to the nearest, making the literals different from the values shown in the documentation.
2024-07-16Rollup merge of #120990 - chenyukang:yukang-fix-120327-dbg, r=oli-obkTrevor Gross-2/+252
Suggest a borrow when using dbg Fixes #120327 r? ````@estebank````
2024-07-16Auto merge of #127680 - Kobzol:bootstrap-cmd-refactor-6, r=onur-ozkanbors-187/+147
Bootstrap command refactoring: port remaining commands with access to `Build` (step 6) Continuation of https://github.com/rust-lang/rust/pull/127450. This PR ports commands in bootstrap that can easily get access to `Build(er)` to `BootstrapCommand`. After this PR, everything that can access `Build(er)` should be using the new API. Statistics of `bootstrap` code (ignoring `src/bin/<shims>`) after this PR: ``` 7 usages of `Command::new` 69 usages of `command()` (new API) - out of that: 16 usages of `as_command_mut()` (new API, but accesses the inner command) ``` Tracking issue: https://github.com/rust-lang/rust/issues/126819 r? `@onur-ozkan`
2024-07-15Fix typos in RELEASES.mdJacob Lifshay-4/+4
as requested in https://github.com/rust-lang/blog.rust-lang.org/pull/1358#discussion_r1678691772
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-308/+383
2024-07-16fmtMichael Goulet-42/+49
2024-07-16deny unsafe_op_in_unsafe_fn for teeos袁浩----天命剑主-0/+1
2024-07-16clean unsafe op in unsafe fn袁浩----天命剑主-13/+15
2024-07-16clean unsafe op in unsafe fn袁浩----天命剑主-4/+4
2024-07-16clean unsafe op in unsafe fn袁浩----天命剑主-9/+9
2024-07-16delete #![allow(unsafe_op_in_unsafe_fn)]袁浩----天命剑主-1/+0
this is redundant, so we can just delete it.
2024-07-16Auto merge of #127638 - adwinwhite:cache_string, r=oli-obkbors-10/+28
Add cache for `allocate_str` Best effort cache for string allocation in const eval. Fixes [rust-lang/miri#3470](https://github.com/rust-lang/miri/issues/3470).
2024-07-16Use an iterator to find `expand_until`Zalathar-14/+19
This makes it easier to see that the split point is always the index after the found item, or the whole list if no stopping point was found.
2024-07-15Auto merge of #127629 - tesuji:suggest-option-ref-unwrap_or, r=estebankbors-1/+164
Suggest using `map_or` when `Option<&T>::unwrap_or where T: Deref` fails Fix #127545 Split from https://github.com/rust-lang/rust/pull/127596#pullrequestreview-2171898588
2024-07-15Make sure trait def ids match before zipping args in ↵Michael Goulet-20/+98
note_function_argument_obligation
2024-07-15Auto merge of #127777 - matthiaskrgr:rollup-qp2vkan, r=matthiaskrgrbors-1359/+3635
Rollup of 6 pull requests Successful merges: - #124921 (offset_from: always allow pointers to point to the same address) - #127407 (Make parse error suggestions verbose and fix spans) - #127684 (consolidate miri-unleashed tests for mutable refs into one file) - #127729 (Stop using the `gen` identifier in the compiler) - #127736 (Add myself to the review rotation) - #127758 (coverage: Restrict `ExpressionUsed` simplification to `Code` mappings) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-15Rollup merge of #127758 - Zalathar:expression-used, r=oli-obkMatthias Krüger-26/+37
coverage: Restrict `ExpressionUsed` simplification to `Code` mappings In the future, branch and MC/DC mappings might have expressions that don't correspond to any single point in the control-flow graph. That makes it trickier to keep track of which expressions should expect an `ExpressionUsed` node. We therefore sidestep that complexity by only performing `ExpressionUsed` simplification for expressions associated directly with ordinary `Code` mappings. (This simplification step is inherited from the original coverage implementation, which only supported `Code` mappings anyway, so there's no particular reason to extend it to other kinds of mappings unless we specifically choose to.) Relevant to: - #124154 - #126677 - #124278 ```@rustbot``` label +A-code-coverage
2024-07-15Rollup merge of #127736 - tgross35:patch-1, r=AmanieuMatthias Krüger-0/+1
Add myself to the review rotation
2024-07-15Rollup merge of #127729 - compiler-errors:ed-2024-gen, r=oli-obkMatthias Krüger-68/+79
Stop using the `gen` identifier in the compiler In preparation for edition 2024, this PR previews the fallout of removing usages of `gen` since it's being reserved as a keyword. There are two notable changes here: 1. Had to rename `fn gen(..)` in gen/kill analysis to `gen_`. Not certain there's a better name than that. 2. There are (false?[^1]) positives in `rustc_macros` when using synstructure, which uses `gen impl` to mark an implementation. We could suppress this in a one-off way, or perhaps just ignore `gen` in macros altogether, since if an identifier ends up in expanded code then it'll get properly denied anyways. Not relevant to the compiler, but it's gonna be really annoying to change `rand`'s `gen` fn in the library and miri... [^1]: I haven't looked at the synstructure proc macro code itself so I'm not certain if it'll start to fail when converted to ed2024 (or, e.g., when syn starts parsing `gen` as a kw).
2024-07-15Rollup merge of #127684 - RalfJung:unleashed-mutable-refs, r=oli-obkMatthias Krüger-427/+399
consolidate miri-unleashed tests for mutable refs into one file r? ```@oli-obk```
2024-07-15Rollup merge of #127407 - estebank:parser-suggestions, r=oli-obkMatthias Krüger-777/+3052
Make parse error suggestions verbose and fix spans Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-15Rollup merge of #124921 - RalfJung:offset-from-same-addr, r=oli-obkMatthias Krüger-61/+67
offset_from: always allow pointers to point to the same address This PR implements the last remaining part of the t-opsem consensus in https://github.com/rust-lang/unsafe-code-guidelines/issues/472: always permits offset_from when both pointers have the same address, no matter how they are computed. This is required to achieve *provenance monotonicity*. Tracking issue: https://github.com/rust-lang/rust/issues/117945 ### What is provenance monotonicity and why does it matter? Provenance monotonicity is the property that adding arbitrary provenance to any no-provenance pointer must never make the program UB. More specifically, in the program state, data in memory is stored as a sequence of [abstract bytes](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#abstract-byte), where each byte can optionally carry provenance. When a pointer is stored in memory, all of the bytes it is stored in carry that provenance. Provenance monotonicity means: if we take some byte that does not have provenance, and give it some arbitrary provenance, then that cannot change program behavior or introduce UB into a UB-free program. We care about provenance monotonicity because we want to allow the optimizer to remove provenance-stripping operations. Removing a provenance-stripping operation effectively means the program after the optimization has provenance where the program before the optimization did not -- since the provenance removal does not happen in the optimized program. IOW, the compiler transformation added provenance to previously provenance-free bytes. This is exactly what provenance monotonicity lets us do. We care about removing provenance-stripping operations because `*ptr = *ptr` is, in general, (likely) a provenance-stripping operation. Specifically, consider `ptr: *mut usize` (or any integer type), and imagine the data at `*ptr` is actually a pointer (i.e., we are type-punning between pointers and integers). Then `*ptr` on the right-hand side evaluates to the data in memory *without* any provenance (because [integers do not have provenance](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html#integers-do-not-have-provenance)). Storing that back to `*ptr` means that the abstract bytes `ptr` points to are the same as before, except their provenance is now gone. This makes `*ptr = *ptr` a provenance-stripping operation (Here we assume `*ptr` is fully initialized. If it is not initialized, evaluating `*ptr` to a value is UB, so removing `*ptr = *ptr` is trivially correct.) ### What does `offset_from` have to do with provenance monotonicity? With `ptr = without_provenance(N)`, `ptr.offset_from(ptr)` is always well-defined and returns 0. By provenance monotonicity, I can now add provenance to the two arguments of `offset_from` and it must still be well-defined. Crucially, I can add *different* provenance to the two arguments, and it must still be well-defined. In other words, this must always be allowed: `ptr1.with_addr(N).offset_from(ptr2.with_addr(N))` (and it returns 0). But the current spec for `offset_from` says that the two pointers must either both be derived from an integer or both be derived from the same allocation, which is not in general true for arbitrary `ptr1`, `ptr2`. To obtain provenance monotonicity, this PR hence changes the spec for offset_from to say that if both pointers have the same address, the function is always well-defined. ### What further consequences does this have? It means the compiler can no longer transform `end2 = begin.offset(end.offset_from(begin))` into `end2 = end`. However, it can still be transformed into `end2 = begin.with_addr(end.addr())`, which later parts of the backend (when provenance has been erased) can trivially turn into `end2 = end`. The only alternative I am aware of is a fundamentally different handling of zero-sized accesses, where a "no provenance" pointer is not allowed to do zero-sized accesses and instead we have a special provenance that indicates "may be used for zero-sized accesses (and nothing else)". `offset` and `offset_from` would then always be UB on a "no provenance" pointer, and permit zero-sized offsets on a "zero-sized provenance" pointer. This achieves provenance monotonicity. That is, however, a breaking change as it contradicts what we landed in https://github.com/rust-lang/rust/pull/117329. It's also a whole bunch of extra UB, which doesn't seem worth it just to achieve that transformation. ### What about the backend? LLVM currently doesn't have an intrinsic for pointer difference, so we anyway cast to integer and subtract there. That's never UB so it is compatible with any relaxation we may want to apply. If LLVM gets a `ptrsub` in the future, then plausibly it will be consistent with `ptradd` and [consider two equal pointers to be inbounds](https://github.com/rust-lang/rust/pull/124921#issuecomment-2205795829).
2024-07-16Suggest a borrow when using dbgyukang-2/+252