about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-08-03Auto merge of #128370 - petrochenkov:libsearch, r=bjorn3bors-38/+65
linker: Pass fewer search directories to the linker - The logic for passing `-L` directories to the linker is consolidated in a single function, so the search priorities are immediately clear. - Only `-Lnative=`, `-Lframework=` `-Lall=` directories are passed to linker, but not `-Lcrate=` and others. That's because only native libraries are looked up by name by linker, all Rust crates are passed using full paths, and their directories should not interfere with linker search paths. - The main sysroot library directory shouldn't generally be passed because it shouldn't contain native libraries, except for one case which is now marked with a FIXME. - This also helps with https://github.com/rust-lang/rust/pull/123436, in which we need to walk the same list of directories manually. The next step is to migrate `find_native_static_library` to exactly the same set and order of search directories (which may be a bit annoying for the `iOSSupport` directories https://github.com/rust-lang/rust/pull/121430#issuecomment-2256372341).
2024-08-03Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelixbors-143/+71
Revert recent changes to dead code analysis This is a revert to recent changes to dead code analysis, namely: * efdf219 Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov * a70dc297a899b76793a14c5705f6ec78fd7a57a7 Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix * 31fe9628cf830a08e7194a446f66c668aaea86e9 Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix * 2724aeaaeb127a8073e39461caacbe21a128ce7b Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix * 977c5fd419ade52467f7de79d5bfc25c0c893275 Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov * 13314df21b0bb0cdd02c6760581d1b9f1052fa7e Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in ##127153. Some of these reverts (#126315 and #126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs? I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way. cc `@mu001999` r? `@pnkfelix` Fixes #128272 Fixes #126169
2024-08-03Revert "Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix"Michael Goulet-93/+28
This reverts commit 13314df21b0bb0cdd02c6760581d1b9f1052fa7e, reversing changes made to 6e534c73c35f569492ed5fb5f349075d58ed8b7e.
2024-08-03Revert "Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov"Michael Goulet-1/+1
This reverts commit 977c5fd419ade52467f7de79d5bfc25c0c893275, reversing changes made to 24c94f0e4f5aa333c665fbbba423172c30176624.
2024-08-03Revert "Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix"Michael Goulet-25/+16
This reverts commit 2724aeaaeb127a8073e39461caacbe21a128ce7b, reversing changes made to d929a42a664c026167800801b26d734db925314f.
2024-08-03Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix"Michael Goulet-12/+28
This reverts commit 31fe9628cf830a08e7194a446f66c668aaea86e9, reversing changes made to f20307851ead9fbbb9fa88bbffb3258a069230a6.
2024-08-03Revert "Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix"Michael Goulet-22/+10
This reverts commit a70dc297a899b76793a14c5705f6ec78fd7a57a7, reversing changes made to ceae37188b9f1be527bb16c9d657a161be7dbbe3.
2024-08-03Revert "Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov"Michael Goulet-19/+17
This reverts commit 91b18a058c4661f82e420b633dc0a3e1ccd14b88, reversing changes made to 9aedec9313dc8ecf9bdcb5f09c4eb0ad8b9a4875.
2024-08-03Fix linking to sanitizers on Apple targetsVadim Petrochenkov-3/+7
2024-08-03linker: Pass fewer search directories to the linkerVadim Petrochenkov-38/+61
2024-08-03Rollup merge of #128557 - nyurik:dup-init, r=compiler-errorsMatthias Krüger-2/+2
chore: use shorthand initializer Tiny readability improvement - don't use redundant initializer vars
2024-08-03Rollup merge of #128483 - nnethercote:still-more-cfg-cleanups, r=petrochenkovMatthias Krüger-153/+169
Still more `cfg` cleanups Found while looking closely at `cfg`/`cfg_attr` processing code. r? `````````@petrochenkov`````````
2024-08-03Rollup merge of #128368 - nnethercote:rustfmt-tweaks, r=cuviperMatthias Krüger-2/+2
Formatting tweaks Some small post-#125443 formatting tweaks. r? ``@cuviper``
2024-08-03Rollup merge of #126704 - sayantn:sha, r=AmanieuMatthias Krüger-0/+7
Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate This is an effort towards #126624. This adds support for these 3 target-features and introduces the feature flag `sha512_sm_x86`, which would gate these target-features and the yet-to-be-implemented detection and intrinsics in stdarch.
2024-08-03Miri: add a flag to do recursive validity checkingRalf Jung-78/+129
2024-08-02Use ParamEnv::reveal_all in CFIMichael Goulet-2/+3
2024-08-03Re-enable SimplifyToExp in match_branches.DianQK-4/+1
2024-08-03Simplify match based on the cast result of `IntToInt`.DianQK-62/+80
2024-08-03Assert that all attributes are actually checked via `CheckAttrVisitor` and ↵Oli Scherer-6/+79
aren't accidentally usable on completely unrelated HIR nodes Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-08-02chore: use shorthand initializerYuri Astrakhan-2/+2
2024-08-02Only walk ribs to collect possibly shadowed params if we are adding params ↵Michael Goulet-96/+105
in our new rib
2024-08-02Check divergence value first before doing span operations in warn_if_unreachableMichael Goulet-18/+18
2024-08-02Rollup merge of #128494 - RalfJung:mir-lazy-lists, r=compiler-errorsMatthias Krüger-44/+113
MIR required_consts, mentioned_items: ensure we do not forget to fill these lists Bodies initially get created with empty required_consts and mentioned_items, but at some point those should be filled. Make sure we notice when that is forgotten.
2024-08-02Rollup merge of #128453 - RalfJung:raw_eq, r=saethlinMatthias Krüger-6/+0
raw_eq: using it on bytes with provenance is not UB (outside const-eval) The current behavior of raw_eq violates provenance monotonicity. See https://github.com/rust-lang/rust/pull/124921 for an explanation of provenance monotonicity. It is violated in raw_eq because comparing bytes without provenance is well-defined, but adding provenance makes the operation UB. So remove the no-provenance requirement from raw_eq. However, the requirement stays in-place for compile-time invocations of raw_eq, that indeed cannot deal with provenance. Cc `@rust-lang/opsem`
2024-08-02Rollup merge of #126818 - estebank:suggestions-fix, r=wesleywiserMatthias Krüger-8/+35
Better handle suggestions for the already present code and fix some suggestions When a suggestion part is for code that is already present, skip it. If all the suggestion parts for a suggestion are for code that is already there, do not emit the suggestion. Fix two suggestions that treat `span_suggestion` as if it were `span_help`.
2024-08-02More information for fully-qualified suggestion when there are multiple implsEsteban Küber-21/+49
``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/E0283.rs:30:21 | LL | fn create() -> u32; | ------------------- `Coroutine::create` defined here ... LL | let cont: u32 = Coroutine::create(); | ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL | let cont: u32 = <Impl as Coroutine>::create(); | ++++++++ + LL | let cont: u32 = <AnotherImpl as Coroutine>::create(); | +++++++++++++++ + ```
2024-08-01Skip over args when determining if coroutine-closure's inner coroutine ↵Michael Goulet-13/+53
consumes its upvars
2024-08-02Add the `sha512`, `sm3` and `sm4` target featuressayantn-0/+7
Add the feature in `core/lib.rs`
2024-08-01Fallback to string formatting if source is not availableclubby789-9/+13
2024-08-01Specify the integer type of the `powi` LLVM intrinsicTrevor Gross-8/+8
Since LLVM <https://reviews.llvm.org/D99439> (4c7f820b2b20, "Update @llvm.powi to handle different int sizes for the exponent"), the size of the integer can be specified for the `powi` intrinsic. Make use of this so it is more obvious that integer size is consistent across all float types. This feature is available since LLVM 13 (October 2021). Based on bootstrap we currently support >= 17.0, so there should be no support problems.
2024-08-01Do not underline suggestions for code that is already thereEsteban Küber-8/+35
When a suggestion part is for already present code, do not highlight it. If after that there are no highlights left, do not show the suggestion at all. Fix clippy lint suggestion incorrectly treated as `span_help`.
2024-08-01Rollup merge of #128496 - clubby789:box-syntax-multipart, r=compiler-errorsMatthias Krüger-12/+23
Fix removed `box_syntax` diagnostic if source isn't available Fix #128442
2024-08-01Rollup merge of #128482 - RalfJung:ptr-signed-offset, r=oli-obkMatthias Krüger-210/+161
interpret: on a signed deref check, mention the right pointer in the error When a negative offset (like `ptr.offset(-10)`) goes out-of-bounds, we currently show an error saying that we expect the *resulting* pointer to be inbounds for 10 bytes. That's confusing, so this PR makes it so that instead we say that we expect the *original* pointer `ptr` to have 10 bytes *to the left*. I also realized I can simplify the pointer arithmetic logic and handling of "staying inbounds of a target `usize`" quite a bit; the second commit does that.
2024-08-01MIR required_consts, mentioned_items: ensure we do not forget to fill these ↵Ralf Jung-44/+113
lists
2024-08-01Fix removed `box_syntax` diagnostic if source isn't availableclubby789-12/+23
2024-08-01fix the way we detect overflow for inbounds arithmetic (and tweak the error ↵Ralf Jung-9/+15
message)
2024-08-01interpret: simplify pointer arithmetic logicRalf Jung-122/+26
2024-08-01on a signed deref check, mention the right pointer in the errorRalf Jung-80/+121
2024-08-01Auto merge of #127543 - carbotaniuman:more_unsafe_attr_verification, ↵bors-86/+140
r=estebank,traviscross More unsafe attr verification This code denies unsafe on attributes such as `#[test]` and `#[ignore]`, while also changing the `MetaItem` parsing so `unsafe` in args like `#[allow(unsafe(dead_code))]` is not accidentally allowed. Tracking: - https://github.com/rust-lang/rust/issues/123757
2024-08-01Distinguish the two kinds of token range.Nicholas Nethercote-78/+124
When collecting tokens there are two kinds of range: - a range relative to the parser's full token stream (which we get when we are parsing); - a range relative to a single AST node's token stream (which we use within `LazyAttrTokenStreamImpl` when replacing tokens). These are currently both represented with `Range<u32>` and it's easy to mix them up -- until now I hadn't properly understood the difference. This commit introduces `ParserRange` and `NodeRange` to distinguish them. This also requires splitting `ReplaceRange` in two, giving the new types `ParserReplacement` and `NodeReplacement`. (These latter two names reduce the overloading of the word "range".) The commit also rewrites some comments to be clearer. The end result is a little more verbose, but much clearer.
2024-08-01Move a comment to a better spot.Nicholas Nethercote-2/+1
2024-08-01Streamline attribute stitching on AST nodes.Nicholas Nethercote-15/+10
It can be done more concisely.
2024-08-01Rollup merge of #128458 - clubby789:optimize-unused-attr, r=compiler-errorsMatthias Krüger-0/+30
Emit an error if `#[optimize]` is applied to an incompatible item #54882 The RFC specifies that this should emit a lint. I used the same allow logic as the `coverage` attribute (also allowing modules and impl blocks) - this should possibly be changed depending on if it's decided to allow 'propogation' of the attribute.
2024-08-01Rollup merge of #128450 - dpaoliello:coff, r=bjorn3Matthias Krüger-5/+1
Create COFF archives for non-LLVM backends `ar_archive_writer` now supports creating COFF archives, so enable them for the non-LLVM backends when requested. r? ``@bjorn3``
2024-08-01Auto merge of #128461 - matthiaskrgr:rollup-3dpp11g, r=matthiaskrgrbors-339/+375
Rollup of 7 pull requests Successful merges: - #123813 (Add `REDUNDANT_IMPORTS` lint for new redundant import detection) - #126697 ([RFC] mbe: consider the `_` in 2024 an expression) - #127159 (match lowering: Hide `Candidate` from outside the lowering algorithm) - #128244 (Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks) - #128431 (Add myself as VxWorks target maintainer for reference) - #128438 (Add special-case for [T, 0] in dropck_outlives) - #128457 (Fix docs for OnceLock::get_mut_or_init) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-01Rollup merge of #128452 - dingxiangfei2009:smart-ptr-require-maybe-sized, ↵Matthias Krüger-27/+23
r=compiler-errors derive(SmartPointer): require pointee to be maybe sized cc ``@Darksonn`` So `#[pointee]` has to be `?Sized` in order for deriving `SmartPointer` to be meaningful. cc ``@compiler-errors`` for suggestions in #127681
2024-08-01Rollup merge of #128449 - Urgau:tmp-allow-negative-lit-lint, r=compiler-errorsMatthias Krüger-1/+2
Temporarily switch `ambiguous_negative_literals` lint to allow This PR temporarily switch the `ambiguous_negative_literals` lint to `allow-by-default`, as asked by T-lang in https://github.com/rust-lang/rust/issues/128287#issuecomment-2260902036.
2024-08-01Rollup merge of #128443 - compiler-errors:async-unreachable, r=fmeaseMatthias Krüger-21/+35
Properly mark loop as diverging if it has no breaks Due to specifics about the desugaring of the `.await` operator, HIR typeck doesn't recognize that `.await`ing an `impl Future<Output = !>` will diverge in the same way as calling a `fn() -> !`. This is because the await operator desugars to approximately: ```rust loop { match future.poll(...) { Poll::Ready(x) => break x, Poll::Pending => {} } } ``` We know that the value of `x` is `!`, however since `break` is a coercion site, we coerce `!` to some `?0` (the type of the loop expression). Then since the type of the `loop {...}` expression is `?0`, we will not detect the loop as diverging like we do with other expressions that evaluate to `!`: https://github.com/rust-lang/rust/blob/0b5eb7ba7bd796fb39c8bb6acd9ef6c140f28b65/compiler/rustc_hir_typeck/src/expr.rs#L240-L243 We can technically fix this in two ways: 1. Make coercion of loop exprs more eagerly result in a type of `!` when the only break expressions have type `!`. 2. Make loops understand that all of that if they have only diverging break values, then the loop diverges as well. (1.) likely has negative effects on inference, and seems like a weird special case to drill into coercion. However, it turns out that (2.) is very easy to implement, we already record whether a loop has any break expressions, and when we do so, we actually skip over any break expressions with diverging values!: https://github.com/rust-lang/rust/blob/0b5eb7ba7bd796fb39c8bb6acd9ef6c140f28b65/compiler/rustc_hir_typeck/src/expr.rs#L713-L716 Thus, we can consider the loop as diverging if we see that it has no breaks, which is the change implemented in this PR. This is not usually a problem in regular code for two reasons: 1. In regular code, we already mark `break diverging()` as unreachable if `diverging()` is unreachable. We don't do this for `.await`, since we suppress unreachable errors within `.await` (#64930). Un-suppressing this code will result in spurious unreachable expression errors pointing to internal await machinery. 3. In loops that truly have no breaks (e.g. `loop {}`), we already evaluate the type of the loop to `!`, so this special case is kinda moot. This only affects loops that have `break`s with values of type `!`. Thus, this seems like a change that may affect more code than just `.await`, but it likely does not in meaningful ways; if it does, it's certainly correct to apply. Fixes #128434
2024-08-01Rollup merge of #128296 - heiher:update-metadata, r=UrgauMatthias Krüger-6/+6
Update target-spec metadata for loongarch64 targets
2024-07-31Rollup merge of #128438 - Bryanskiy:empty-array-dropck, r=lcnrMatthias Krüger-2/+9
Add special-case for [T, 0] in dropck_outlives implements/fixes #110288. r? `@lcnr`