about summary refs log tree commit diff
path: root/src/tools
AgeCommit message (Collapse)AuthorLines
2024-07-16run-make-support: update gimli to 0.31.0Mrmaxmeier-1/+1
2024-07-16Use symbol in cfgLukas Wirth-92/+147
2024-07-16Switch token trees to use SymbolsLukas Wirth-399/+593
2024-07-16Use re-exported Idx and IndexVec in pat_analysisLaurențiu Nicola-3/+2
2024-07-16Auto merge of #127680 - Kobzol:bootstrap-cmd-refactor-6, r=onur-ozkanbors-14/+0
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-16Auto merge of #3742 - Vanille-N:master, r=RalfJungbors-6/+211
TB: Reserved + Protected + IM + lazy is a horrible combination that should not exist As discovered by `@JoJoDeveloping,` the result of having both Protector exceptions on lazy locations (protectors only protect initialized bytes) and interior mutability exceptions for protected tags (Reserved IM does not accept foreign writes when protected) leads to some very undesirable results, namely that we cannot do spurious writes even on protected activated locations. We propose that Protected Reserved IM should no longer exist and instead when a type is retagged as part of a `FnEntry` it is assumed to lose interior mutability. In fact, this was already being done implicitly because relevant transitions were guarded by an `if protected`, but the difference is that now it also applies to transitions that occur after the end of the protector.
2024-07-16Merge from rustcThe Miri Cronjob Bot-2570/+4219
2024-07-16Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2024-07-15Move rustc_infer::infer::error_reporting to rustc_infer::error_reporting::inferMichael Goulet-1/+1
2024-07-15Rollup merge of #127729 - compiler-errors:ed-2024-gen, r=oli-obkMatthias Krüger-13/+13
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 #124921 - RalfJung:offset-from-same-addr, r=oli-obkMatthias Krüger-3/+0
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-15lib: replace some `mem::forget`'s with `ManuallyDrop`Pavel Grigorenko-3/+3
2024-07-15Move `force_coloring_in_ci` from `builder_helper` to `bootstrap`Jakub Beránek-14/+0
It was only used in bootstrap. This move allows us to modify the function to work with `BootstrapCommand`, rather than `Command`.
2024-07-15Fix incorrect encoding of literals in the proc-macro-api on version 4Lukas Wirth-134/+183
2024-07-15Auto merge of #17559 - Veykril:tokentree, r=Veykrilbors-431/+910
Encode ident rawness and literal kind separately in tt::Leaf
2024-07-15Escape fetched env vars in env! expansionLukas Wirth-20/+25
2024-07-15Add cargo xtask install proc-macro-serverLukas Wirth-4/+30
2024-07-15Encode ident rawness and literal kind separately in tt::LeafLukas Wirth-410/+858
2024-07-15Auto merge of #17588 - CamWass:more-rename, r=Veykrilbors-31/+194
feat: Add incorrect case diagnostics for enum variant fields and all variables/params Updates the incorrect case diagnostic to check: 1. Fields of enum variants. Example: ```rust enum Foo { Variant { nonSnake: u8 } } ``` 2. All variable bindings, instead of just let bindings and certain match arm patters. Examples: ```rust match 1 { nonSnake => () } match 1 { nonSnake @ 1 => () } match 1 { nonSnake1 @ nonSnake2 => () } // slightly cursed, but these both introduce new // bindings that are bound to the same value. const ONE: i32 = 1; match 1 { nonSnake @ ONE } // ONE is ignored since it is not a binding match Some(1) { Some(nonSnake) => () } struct Foo { field: u8 } match (Foo { field: 1 } ) { Foo { field: nonSnake } => (); } struct Foo { nonSnake: u8 } // diagnostic here, at definition match (Foo { nonSnake: 1 } ) { // no diagnostic here... Foo { nonSnake } => (); // ...or here, since these are not where the name is introduced } for nonSnake in [] {} struct Foo(u8); for Foo(nonSnake) in [] {} ``` 3. All parameter bindings, instead of just top-level binding identifiers. Examples: ```rust fn func(nonSnake: u8) {} // worked before struct Foo { field: u8 } fn func(Foo { field: nonSnake }: Foo) {} // now get diagnostic for nonSnake ``` This is accomplished by changing the way binding identifier patterns are filtered: - Previously, all binding idents were skipped, except a few classes of "good" binding locations that were checked. - Now, all binding idents are checked, except field shorthands which are skipped. Moving from a whitelist to a blacklist potentially makes the analysis more brittle: If new pattern types are added in the future where ident pats don't introduce new names, then they may incorrectly create diagnostics. But the benefit of the blacklist approach is simplicity: I think a whitelist approach would need to recursively visit patterns to collect renaming candidates?
2024-07-15Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykrilbors-36/+80
Trigger VSCode to rename after extract variable assist is applied When the user applies the "Extract Variable" assist, the cursor is positioned at the newly inserted variable. This commit adds a command to the assist that triggers the rename action in VSCode. This way, the user can quickly rename the variable after applying the assist. Fixes part of: #17579 https://github.com/user-attachments/assets/4cf38740-ab22-4b94-b0f1-eddd51c26c29 I haven't yet looked at the module or function extraction assists yet.
2024-07-15Auto merge of #17584 - Veykril:landing-page, r=Veykrilbors-792/+1418
Implement symbol interning infra Will fix https://github.com/rust-lang/rust-analyzer/issues/15590 My unsafe-fu is not the best but it does satisfy miri. There is still some follow up work to do, notably a lot of places using strings instead of symbols/names, most notably the token tree.
2024-07-15Fix stable iteration ordering for `Map<Name, ...>` usagesLukas Wirth-29/+55
2024-07-15Make normalization regex less exactChris Denton-1/+1
2024-07-14Auto merge of #127726 - RalfJung:miri-sync, r=RalfJungbors-277/+1531
Miri subtree update r? `@ghost`
2024-07-14Fix trivial gen ident usage in toolsMichael Goulet-13/+13
2024-07-14Auto merge of #3745 - joboet:os_unfair_lock, r=RalfJungbors-7/+284
Implement the `os_unfair_lock` functions on macOS These are needed for rust-lang/rust#122408. See the documentation [here](https://developer.apple.com/documentation/os/synchronization?language=objc) and the implementation [here](https://github.com/apple-oss-distributions/libplatform/blob/a00a4cc36da2110578bcf3b8eeeeb93dcc7f4e11/src/os/lock.c#L645).
2024-07-14implement the `os_unfair_lock` functions on macOSjoboet-7/+284
2024-07-14add test for intermediate reference in '&(*x).0 as *const i32'Ralf Jung-0/+40
2024-07-14Use statics + clone instead of const until const can access staticsLukas Wirth-368/+395
2024-07-14Update manual.adocAnita Hammer-1/+1
2024-07-13Rollup merge of #127434 - onur-ozkan:use-bootstrap-instead-of-rustbuild, ↵Jubilee-6/+6
r=Mark-Simulacrum use "bootstrap" instead of "rustbuild" in comments and docs Let's stick with the single name "bootstrap" to refer to the bootstrap project to avoid confusion. This should make it clearer, especially for new contributors.
2024-07-13Address feedback from @DropDemBitsJosh McKinney-13/+10
- move `edit.rename()` to the end of the function - use a match statement to set `res.command`
2024-07-13Leave a trace of the current suboptimal status of foreign_writeNeven Villani-0/+6
2024-07-13feat: Add incorrect case diagnostics for enum variant fields and all variablesCampbell-31/+194
2024-07-13Auto merge of #127450 - Kobzol:bootstrap-cmd-refactor-5, r=onur-ozkanbors-11/+17
Bootstrap command refactoring: improve debuggability (step 5) Continuation of https://github.com/rust-lang/rust/pull/127321. This PR improves the debuggability of command execution, by improving the output logged when a command fails (it now includes the exact location where the command was created and where it was executed), and also by adding a "drop bomb", which will panic if a command was created, but not executed (which is probably a bug). Here is how the output of a failed command looks like: ``` Command "git" "foo" "[bar]" (failure_mode=Exit, stdout_mode=Capture, stderr_mode=Capture) did not execute successfully. Expected success, got exit status: 1 Created at: src/core/build_steps/compile.rs:1699:9 Executed at: src/core/build_steps/compile.rs:1699:58 STDOUT ---- STDERR ---- git: 'foo' is not a git command. See 'git --help'. ``` And this is what is printed if you forget to execute a command: ``` thread 'main' panicked at /projects/personal/rust/rust/src/tools/build_helper/src/drop_bomb/mod.rs:42:13: command constructed at `src/core/build_steps/compile.rs:1699:9` was dropped without being executed: `git` ``` Best reviewed commit by commit. Tracking issue: https://github.com/rust-lang/rust/issues/126819 r? `@onur-ozkan`
2024-07-12Trigger VSCode to rename after extract variable assist is appliedbors-33/+80
When the user applies the "Extract Variable" assist, the cursor is positioned at the newly inserted variable. This commit adds a command to the assist that triggers the rename action in VSCode. This way, the user can quickly rename the variable after applying the assist. Fixes part of: #17579
2024-07-13Allow macro expansions into `RestPat` in tuple args work as ellipsis like ↵Shoyu Vanilla-5/+108
plain `RestPat`
2024-07-12Rollup merge of #127632 - compiler-errors:precise-capturing-rustdoc, r=fmeaseJubilee-0/+1
Implement `precise_capturing` support for rustdoc Implements rustdoc (+json) support for local (i.e. non-cross-crate-inlined) RPITs with `use<...>` precise capturing syntax. Tests kinda suck. They're really hard to write 😰 r? `@fmease` or re-roll if you're too busy! also cc `@aDotInTheVoid` for the json side Tracking: * https://github.com/rust-lang/rust/issues/127228#issuecomment-2201443216 (not fully fixed for cross-crate-inlined opaques) * https://github.com/rust-lang/rust/issues/123432
2024-07-12Rollup merge of #127381 - Oneirical:testalt-consciousness, r=jieyouxuJubilee-6/+6
Migrate `issue-83045`, `rustc-macro-dep-files` and `env-dep-info` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try on musl. try-job: dist-x86_64-musl
2024-07-12Rollup merge of #127338 - Oneirical:ready-your-arbatests, r=jieyouxuJubilee-2/+5
Migrate `extra-filename-with-temp-outputs` and `issue-85019-moved-src-dir` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: armhf-gnu // try-job: test-various // already tried try-job: x86_64-msvc try-job: aarch64-apple
2024-07-12rewrite raw-dylib-custom-dlltool to rmakeOneirical-1/+0
2024-07-12derivative -> derive-wherePavel Grigorenko-1/+1
2024-07-12Improve error message of drop bombsJakub Beránek-1/+1
2024-07-12Print command creation and execution location when it failsJakub Beránek-0/+4
This should make it quicker to debug command failures.
2024-07-12Store full arm location in `DropBomb`Jakub Beránek-4/+4
Before, only the line was stored. This was enough for run-make tests, since these mostly only contain a single `rmake.rs` file, but not for bootstrap.
2024-07-12Move `DropBomb` from `run-make-support` to `build_helper`Jakub Beránek-7/+9
So that it can be also used in bootstrap.
2024-07-12Fix cloning Symbols not increasing their ref countLukas Wirth-28/+63
2024-07-12rewrite env-dep-info to rmakeOneirical-5/+6
2024-07-12rewrite rustc-macro-dep-files to rmakeOneirical-1/+0
2024-07-12rewrite and rename issue-85019-moved-src-dir to rmakeOneirical-1/+0