about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-04-12Update compiler/rustc_error_codes/src/error_codes/E0384.mdJimmy Ohn-0/+13
Add an example for the shadowing usage.
2024-04-12Auto merge of #123736 - compiler-errors:multiply-on-rhs, r=estebankbors-4/+34
Don't delay a bug if we suggest adding a semicolon to the RHS of an assign operator It only makes sense to delay a bug based on the assumption that "[we] defer to the later error produced by `check_lhs_assignable`" *if* the expression we're erroring actually is an LHS; otherwise, we should still report the error since it's both useful and required. Fixes #123722
2024-04-12Auto merge of #123490 - niluxv:strict_prov_unwind_seh, r=Amanieubors-41/+73
Refactor `panic_unwind/seh.rs` pointer use * `x86` now conforms to strict-provenance * `x86_64` now uses the expose API (instead of `as` casts) * changed `ptr_t` from a type alias to a `repr(transparent)` struct for some extra type-safety * replaced the `ptr!` macro by methods on `ptr_t`, as there is now no reason (as far as I can see) anymore to use a macro On `x86_64` pointers in SEH are represented by 32-bit offsets from `__ImageBase`, so we can't use a pointer type. It might be possible to leak the provenance into the FFI by using a `MaybeUninit<u32>` instead of a `u32`, but that is a bit more involved than using expose, and I'm not sure that would be worth it.
2024-04-12Auto merge of #123838 - matthiaskrgr:rollup-zkgwyye, r=matthiaskrgrbors-250/+335
Rollup of 7 pull requests Successful merges: - #123599 (remove some things that do not need to be) - #123763 (Set the host library path in run-make v2) - #123775 (Make `PlaceRef` and `OperandValue::Ref` share a common `PlaceValue` type) - #123789 (move QueryKeyStringCache from rustc_middle to rustc_query_impl, where it actually used) - #123826 (Move rare overflow error to a cold function) - #123827 (linker: Avoid some allocations in search directory iteration) - #123829 (Fix revisions syntax in cfg(ub_checks) test) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-12Rollup merge of #123829 - saethlin:fix-revisions, r=jieyouxuMatthias Krüger-1/+1
Fix revisions syntax in cfg(ub_checks) test `//@ revisions YES NO` doesn't do anything without the `:`. Thanks for pointing this out to me. r? jieyouxu
2024-04-12Rollup merge of #123827 - petrochenkov:searchdirs, r=NadrierilMatthias Krüger-22/+21
linker: Avoid some allocations in search directory iteration This is more a cleanup than actual optimization.
2024-04-12Rollup merge of #123826 - kornelski:one-in-a-quintillion, r=AmanieuMatthias Krüger-2/+8
Move rare overflow error to a cold function `scoped.spawn()` generates unnecessary inlined panic-formatting code for a branch that will never be taken.
2024-04-12Rollup merge of #123789 - klensy:rq, r=cjgillotMatthias Krüger-18/+13
move QueryKeyStringCache from rustc_middle to rustc_query_impl, where it actually used Also allows to drop measureme dep on rustc_middle.
2024-04-12Rollup merge of #123775 - scottmcm:place-val, r=cjgillotMatthias Krüger-169/+239
Make `PlaceRef` and `OperandValue::Ref` share a common `PlaceValue` type Both `PlaceRef` and `OperandValue::Ref` need the triple of the backend pointer immediate, the optional backend metadata for DSTs, and the actual alignment of the place (since it can differ from the ABI alignment). This PR introduces a new `PlaceValue` type for those three values, leaving [`PlaceRef`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/mir/place/struct.PlaceRef.html) with the `TyAndLayout` and a `PlaceValue`, just like how [`OperandRef`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/mir/operand/struct.OperandRef.html) is a `TyAndLayout` and an `OperandValue`. This means that various places that use `Ref`s as places can just pass the `PlaceValue` along, like in the below excerpt from the diff: ```diff match operand.val { - OperandValue::Ref(ptr, meta, align) => { - debug_assert_eq!(meta, None); + OperandValue::Ref(source_place_val) => { + debug_assert_eq!(source_place_val.llextra, None); debug_assert!(matches!(operand_kind, OperandValueKind::Ref)); - let fake_place = PlaceRef::new_sized_aligned(ptr, cast, align); + let fake_place = PlaceRef { val: source_place_val, layout: cast }; Some(bx.load_operand(fake_place).val) } ``` There's more refactoring that I'd like to do after this, but I wanted to stop the PR here where it's hopefully easy (albeit probably not quick) to review since I tried to keep every change line-by-line clear. (Most are just adding `.val` to get to a field.) You can also go commit-at-a-time if you'd like. Each passed tidy and the codegen tests on my machine (though I didn't run the cg_gcc ones).
2024-04-12Rollup merge of #123763 - cuviper:host-rpath-run-make-v2, r=jieyouxuMatthias Krüger-20/+43
Set the host library path in run-make v2 When the build is configured with `[rust] rpath = false`, we need to set `LD_LIBRARY_PATH` (or equivalent) to what would have been the `RPATH`, so the compiler can find its own libraries. The old `tools.mk` code has this environment prefixed in the `$(BARE_RUSTC)` variable, so we just need to wire up something similar for run-make v2. This is now set while building each `rmake.rs` itself, as well as in the `rust-make-support` helpers for `rustc` and `rustdoc` commands. This is also available in a `set_host_rpath` function for manual commands, like in the `compiler-builtins` test.
2024-04-12Rollup merge of #123599 - matthiaskrgr:rm, r=cjgillotMatthias Krüger-18/+10
remove some things that do not need to be
2024-04-12Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieubors-3/+12
Add `A: 'static` bound for `Arc/Rc::pin_in` Analogous to https://github.com/rust-lang/rust/pull/79327 Needed to preserve pin's [drop guarantee](https://doc.rust-lang.org/std/pin/index.html#drop-guarantee)
2024-04-11Use `env::split_paths`/`join_paths` in runtestJosh Stone-16/+15
2024-04-11Auto merge of #123823 - matthiaskrgr:rollup-8zdtggx, r=matthiaskrgrbors-367/+330
Rollup of 8 pull requests Successful merges: - #122882 (Avoid a panic in `set_output_capture` in the default panic handler) - #123523 (Account for trait/impl difference when suggesting changing argument from ref to mut ref) - #123744 (Silence `unused_imports` for redundant imports) - #123784 (Replace `document.write` with `document.head.insertAdjacent`) - #123798 (Avoid invalid socket address in length calculation) - #123804 (Stop using `HirId` for fn-like parents since closures are not `OwnerNode`s) - #123806 (Panic on overflow in `BorrowedCursor::advance`) - #123820 (Add my former address to .mailmap) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-11Fix revisions syntaxBen Kimock-1/+1
2024-04-12linker: Avoid some allocations in search directory iterationVadim Petrochenkov-22/+21
2024-04-11Move rare overflow error to a cold functionKornel-2/+8
2024-04-11Rollup merge of #123820 - bash:mailmap, r=workingjubileeMatthias Krüger-0/+1
Add my former address to .mailmap
2024-04-11Rollup merge of #123806 - joboet:advanced_overflow, r=AmanieuMatthias Krüger-2/+12
Panic on overflow in `BorrowedCursor::advance` Passing `usize::MAX` to `advance` clearly isn't correct, but the current assertion fails to detect this when overflow checks are disabled. This isn't unsound, but should probably be fixed regardless.
2024-04-11Rollup merge of #123804 - compiler-errors:podcrab-fix, r=jieyouxuMatthias Krüger-34/+84
Stop using `HirId` for fn-like parents since closures are not `OwnerNode`s This is a minimal fix for #123273. I'm overall pretty disappointed w/ the state of this code; although it's "just diagnostics", it still should be maintainable and understandable and neither of those are true. I believe this code really needs some major overhauling before anything more should be added to it, because there are subtle invariants that are being exercised and subsequently broken all over the place, and I don't think we should just paper over them (e.g.) by delaying bugs or things like that. I wouldn't be surprised if fixing up this code would also yield better diagnostics.
2024-04-11Rollup merge of #123798 - tniessen:patch-1, r=workingjubileeMatthias Krüger-2/+2
Avoid invalid socket address in length calculation This has no effect on the lengths of these constants, but since the IP address portion of the socket addresses was intentionally chosen to be the largest valid value, it seems appropriate to also use the largest valid value for the other components (as opposed to invalid values exceeding the possible ranges).
2024-04-11Rollup merge of #123784 - GuillaumeGomez:replace-document-write, r=notriddleMatthias Krüger-2/+1
Replace `document.write` with `document.head.insertAdjacent` From [this comment](https://github.com/rust-lang/rust/pull/123706/files#r1559864981), using `document.write` is strongly discouraged (explained on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/write)). I think in this case it was mostly ok but better be on the safe side. r? `@notriddle`
2024-04-11Rollup merge of #123744 - compiler-errors:redundant-due-to-glob, r=petrochenkovMatthias Krüger-275/+43
Silence `unused_imports` for redundant imports Quick fix for https://github.com/rust-lang/rust/issues/121708#issuecomment-2048105393 r? `@petrochenkov` cc `@joshtriplett` I think this is right, would like confirmation. I also think it's weird that we're using `=` to assign to `is_redundant` but using `per_ns` for the actual spans. Seems like this could be weirdly order dependent, but that's unrelated to this change.
2024-04-11Rollup merge of #123523 - estebank:issue-123414, r=BoxyUwUMatthias Krüger-43/+158
Account for trait/impl difference when suggesting changing argument from ref to mut ref Do not ICE when encountering a lifetime error involving an argument with an immutable reference of a method that differs from the trait definition. Fix #123414.
2024-04-11Rollup merge of #122882 - Zoxc:panic-output-panic, r=AmanieuMatthias Krüger-9/+29
Avoid a panic in `set_output_capture` in the default panic handler This avoid a panic in the default panic handler by not using `set_output_capture` as `OUTPUT_CAPTURE.with` may panic once `OUTPUT_CAPTURE` is dropped. A new non-panicking `try_set_output_capture` variant of `set_output_capture` is added for use in the default panic handler.
2024-04-11Auto merge of #123814 - matthiaskrgr:rollup-lxn0t4t, r=matthiaskrgrbors-72/+67
Rollup of 5 pull requests Successful merges: - #123459 (Correctly handle inlining of doc hidden foreign items) - #123740 (Reduce Size of `ModifierInfo`) - #123770 (Correct broken link in core::pin doc) - #123777 (Deduplicate some function implementations between the parser and AST/HIR) - #123808 (codegen tests: Tolerate `nuw` `nsw` on `trunc`) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-11remove some things that do not need to beMatthias Krüger-18/+10
2024-04-11Refactor `panic_unwind/seh.rs` pointer use; x86 now conforms to ↵niluxv-41/+73
strict-provenance
2024-04-11Add my former address to .mailmapTau Gärtli-0/+1
2024-04-11Silence unused_imports lint for redundant importsMichael Goulet-275/+43
2024-04-11Rollup merge of #123808 - maurer:nuw-nsw-trunc, r=durin42Matthias Krüger-5/+5
codegen tests: Tolerate `nuw` `nsw` on `trunc` llvm/llvm-project#87910 infers `nuw` and `nsw` on some `trunc` instructions we're doing `FileCheck` on. Tolerate but don't require them to support both release and head LLVM. `@rustbot` label: +llvm-main cc `@durin42`
2024-04-11Rollup merge of #123777 - oli-obk:operator_cleanup, r=jieyouxuMatthias Krüger-36/+3
Deduplicate some function implementations between the parser and AST/HIR These functions already existed on parser binops, so just convert back to them back and invoke the equivalent method.
2024-04-11Rollup merge of #123770 - tomokinat:master, r=joboetMatthias Krüger-5/+5
Correct broken link in core::pin doc This is a minor correction to the doc, which fails to link `Unpin` trait. Before (rendered): ![before](https://github.com/rust-lang/rust/assets/49511064/c4f2f94d-91ea-4cee-be69-b0053453194a) After (rendered): ![before](https://github.com/rust-lang/rust/assets/49511064/847068f8-73b2-4acb-ab78-3351ffe5b0a0)
2024-04-11Rollup merge of #123740 - veera-sivarajan:reduce-size-of-modifierinfo, ↵Matthias Krüger-3/+3
r=petrochenkov Reduce Size of `ModifierInfo` I added `ModifierInfo` in #121940 and had used a `u64` for the `size` field even though the largest value it holds is `512`. This PR changes the type of the `size` field to `u16`.
2024-04-11Rollup merge of #123459 - GuillaumeGomez:fix-123435, r=notriddleMatthias Krüger-23/+51
Correctly handle inlining of doc hidden foreign items Fixes #123435. In case a foreign item has doc(hidden) attribute, we simply merged its attributes with the re-export's, making it being removed once in the `strip_hidden` pass. The solution was to use the same as for local reexported items: merge attributes, but not some of them (like `doc(hidden)`). I originally checked if we could simply update `Item::is_doc_hidden` method to use `self.inline_stmt_id.is_some_and(|def_id| tcx.is_doc_hidden(def_id))` but unfortunately, it added (local) items that shouldn't be inlined. At least it unifies local and foreign items inlining, which I think is the best course of action here. r? `@notriddle`
2024-04-11Replace `document.write` with `document.head.insertAdjacentHTML`Guillaume Gomez-2/+1
2024-04-11Auto merge of #123732 - a1phyr:io_error_factor, r=cuviperbors-159/+67
Factor some common `io::Error` constants
2024-04-11codegen tests: Tolerate `nuw` `nsw` on `trunc`Matthew Maurer-5/+5
llvm/llvm-project#87910 infers `nuw` and `nsw` on some `trunc` instructions we're doing `FileCheck` on. Tolerate but don't require them to support both release and head LLVM.
2024-04-11core: panic on overflow in `BorrowedCursor`joboet-2/+12
2024-04-11Stop using HirId for fn-like parentsMichael Goulet-34/+84
2024-04-11Auto merge of #123795 - matthiaskrgr:rollup-deesd9c, r=matthiaskrgrbors-113/+470
Rollup of 4 pull requests Successful merges: - #123660 (Make the computation of `coroutine_captures_by_ref_ty` more sophisticated) - #123738 (Call lower_const_param instead of duplicating the code) - #123774 (Fix typo MaybeUnit -> MaybeUninit) - #123790 (correct the handling of `bootstrap-cache-path` option) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-11Avoid invalid socket address in length calculationTobias Nießen-2/+2
2024-04-11Rollup merge of #123790 - onur-ozkan:invalid-config-option, r=clubby789Matthias Krüger-2/+4
correct the handling of `bootstrap-cache-path` option This change makes `build.bootstrap-cache-path` option to be configurable with `./configure` script, so it can be used like `./configure --bootstrap-cache-path=demo`.
2024-04-11Rollup merge of #123774 - Lee-Janggun:master, r=lqdMatthias Krüger-1/+1
Fix typo MaybeUnit -> MaybeUninit
2024-04-11Rollup merge of #123738 - spastorino:reuse-lower-const-param, r=compiler-errorsMatthias Krüger-5/+6
Call lower_const_param instead of duplicating the code Follow up of #123689 r? `@oli-obk` I had this commit in my old branch that I had forgotten about, `@fmease` pointed about this in #123689 I've left the branches that are not `Range` as do nothing as that's what we are currently doing but maybe we want to err or something.
2024-04-11Rollup merge of #123660 - compiler-errors:coroutine-closure-env, r=oli-obkMatthias Krüger-105/+459
Make the computation of `coroutine_captures_by_ref_ty` more sophisticated Currently, we treat all the by-(mut/)ref borrows of a coroutine-closure as having a "closure env" borrowed lifetime. When we have the given code: ```rust let x: &'a i32 = ...; let c = async || { let _x = *x; }; ``` Then when we call: ```rust c() // which, because `AsyncFn` takes a `&self`, we insert an autoref: (&c /* &'env {coroutine-closure} */)() ``` We will return a future whose captures contain `&'env i32` instead of `&'a i32`, which is way more restrictive than necessary. We should be able to drop `c` while the future is alive since it's not actually borrowing any data *originating from within* the closure's captures, but since the capture has that `'env` lifetime, this is not possible. This wouldn't be true, for example, if the closure captured `i32` instead of `&'a i32`, because the `'env` lifetime is actually *necessary* since the data (`i32`) is owned by the closure. This PR identifies two criteria where we *need* to take the borrow with the closure env lifetime: 1. If the closure borrows data from inside the closure's captures. This is not true if the parent capture is by-ref, OR if the parent capture is by-move and the child capture begins with a deref projection. This is the example described above. 2. If we're dealing with mutable references, since we cannot reborrow `&'env mut &'a mut i32` into `&'a mut i32`, *only* `&'env mut i32`. See the documentation on `should_reborrow_from_env_of_parent_coroutine_closure` for more info. **important:** As disclaimer states on that function, luckily, if this heuristic is not correct, then the program is not unsound, since we still borrowck and validate the choices made from this function -- the only side-effect is that the user may receive unnecessary borrowck errors. Fixes #123241
2024-04-11Auto merge of #123788 - bjorn3:disable_ctrlc_on_wasi, r=Nilstrieb,lcnrbors-34/+13
Disable Ctrl-C handling on WASM WASM fundamentally doesn't support signals. If WASI ever gets support for notifying the guest process of a Ctrl-C that happened, this would have to be done through the guest process polling for the signal, which will require thread support in WASI too to be compatible with the api provided by the ctrlc crate.
2024-04-11Call lower_const_param instead of duplicating the codeSantiago Pastorino-5/+6
2024-04-11Remove wasm dep filter from tidybjorn3-33/+7
It incorrectly filters out non-wasm dependencies too.
2024-04-11Disable Ctrl-C handling on WASMbjorn3-1/+6
WASM fundamentally doesn't support signals. If WASI ever gets support for notifying the guest process of a Ctrl-C that happened, this would have to be done through the guest process polling for the signal, which will require thread support in WASI too to be compatible with the api provided by the ctrlc crate.