about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-12-09Rollup merge of #118766 - compiler-errors:lower-spans, r=spastorinoGuillaume Gomez-5/+6
Lower some forgotten spans I wrote a HIR visitor that visited all of the spans in the HIR, and made it ICE when we have a unlowered span. That led me to discover these unlowered spans.
2023-12-09Rollup merge of #118734 - nnethercote:literal-cleanups, r=fee1-deadGuillaume Gomez-58/+63
Unescaping cleanups Minor improvements I found while working on #118699. r? `@fee1-dead`
2023-12-09Rollup merge of #118702 - Urgau:check-cfg-strengthen-well-known, r=nnethercoteGuillaume Gomez-77/+298
Strengthen well known check-cfg names and values test https://github.com/rust-lang/rust/pull/118494 is changing the implementation of how we expect well known check-cfg names and values, but we currently don't have a test that checks every well known only some of them. This PR therefore strengthen our well known names/values test to include all of the configs to at least avoid unintended regressions and validate new entry. *this PR also contains some drive-by consolidation of unexpected `target_os`, `target_arch` into a single file* r? `@nnethercote` (maybe? feel free to re-assign)
2023-12-09Rollup merge of #118638 - nnethercote:rustc_mir_dataflow-more, r=cjgillotGuillaume Gomez-138/+102
More `rustc_mir_dataflow` cleanups r? `@cjgillot`
2023-12-09Rollup merge of #118057 - bvanjoi:fix-118048, r=cjgillotGuillaume Gomez-4/+36
dedup for duplicate suggestions Fixes #118048 An easy fix.
2023-12-09Rollup merge of #117953 - farnoy:masked-load-store, r=workingjubileeGuillaume Gomez-1/+594
Add more SIMD platform-intrinsics - [x] simd_masked_load - [x] LLVM codegen - llvm.masked.load - [x] cranelift codegen - implemented but untested - [ ] simd_masked_store - [x] LLVM codegen - llvm.masked.store - [ ] cranelift codegen Also added a run-pass test to test both intrinsics, and additional build-fail & check-fail to cover validation for both intrinsics
2023-12-09Auto merge of #116170 - matthewjasper:remove-thir-destruction-scopes, r=cjgillotbors-468/+235
Don't include destruction scopes in THIR They are not used by anyone, and add memory/performance overhead.
2023-12-09Add simd_masked_{load,store} platform-intrinsicsJakub Okoński-1/+51
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-09Add simd_masked_{load,store} platform-intrinsicsJakub Okoński-1/+594
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-09Avoid target_os and target_arch in some check-cfg testsUrgau-21/+4
as they unnecessarily clutter the diagnostic output and make the experience of adding a new target to the compiler more painful than it should be. target_os and target_arch are still being tested in the well-known-values.rs test, but in one place.
2023-12-09Strengthen well known check-cfg names and values testUrgau-56/+294
2023-12-09Auto merge of #118771 - workingjubilee:rollup-q1p3riz, r=workingjubileebors-111/+543
Rollup of 7 pull requests Successful merges: - #118198 (coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions) - #118512 (Add tests related to normalization in implied bounds) - #118610 (update target feature following LLVM API change) - #118666 (coverage: Simplify the heuristic for ignoring `async fn` return spans) - #118737 (Extend tidy alphabetical checking to `tests/`.) - #118762 (Some more minor `async gen`-related nits) - #118764 (Make async generators fused by default) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-09add test for inductive cycle hangslcnr-4/+57
2023-12-09chore: add test case for type with genericYoung-Flash-3/+69
2023-12-09Rollup merge of #118764 - compiler-errors:fused-async-iterator, r=eholkJubilee-11/+37
Make async generators fused by default I actually changed my mind about this since the implementation PR landed. I think it's beneficial for `async gen` blocks to be "fused" by default -- i.e., for them to repeatedly return `Poll::Ready(None)` -- rather than panic. We have [`FusedStream`](https://docs.rs/futures/latest/futures/stream/trait.FusedStream.html) in futures-rs to represent streams with this capability already anyways. r? eholk cc ```@rust-lang/wg-async,``` would like to know if anyone else has opinions about this.
2023-12-09Rollup merge of #118762 - compiler-errors:gen-nits, r=eholkJubilee-34/+35
Some more minor `async gen`-related nits Tiny tweaks found after `async gen` pr landed r? eholk
2023-12-09Rollup merge of #118737 - nnethercote:tidy-alphabetical-in-testsa, r=NilstriebJubilee-0/+1
Extend tidy alphabetical checking to `tests/`. This is desired for #118702. r? ```@Nilstrieb```
2023-12-09Rollup merge of #118666 - Zalathar:body-closure, r=cjgillotJubilee-31/+93
coverage: Simplify the heuristic for ignoring `async fn` return spans The code for extracting coverage spans from MIR has a special heuristic for dealing with `async fn`, so that the function's closing brace does not have a confusing double count. The code implementing that heuristic is currently mixed in with the code for flushing remaining spans after the main refinement loop, making the refinement code harder to understand. We can solve that by hoisting the heuristic to an earlier stage, after the spans have been extracted and sorted but before they have been processed by the refinement loop. The coverage tests verify that the heuristic is still effective, so coverage mappings/reports for `async fn` have not changed. --- This PR also has the side-effect of fixing the `None some_prev` panic that started appearing after #118525. The old code assumed that `prev` would always be present after the refinement loop. That was only true if the list of collected spans was non-empty, but prior to #118525 that didn't seem to come up in practice. After that change, the list of collected spans could be empty in some specific circumstances, leading to panics. The new code uses an `if let` to inspect `prev`, which correctly does nothing if there is no span present.
2023-12-09Rollup merge of #118610 - krasimirgg:llvm-18-dec, r=nikicJubilee-3/+7
update target feature following LLVM API change LLVM commit https://github.com/llvm/llvm-project/commit/e81796671890b59c110f8e41adc7ca26f8484d20 renamed* the `unaligned-scalar-mem` target feature to `fast-unaligned-access`. (*) technically the commit folded two previous features into one, but there are no references to the other one in rust.
2023-12-09Rollup merge of #118512 - spastorino:add-implied-bounds-related-tests, ↵Jubilee-8/+202
r=jackh726 Add tests related to normalization in implied bounds Getting ```@aliemjay's``` tests from #109763, so we can better track what's going on in every different example. r? ```@jackh726```
2023-12-09Rollup merge of #118198 - Zalathar:if-not, r=cjgillotJubilee-24/+168
coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions Coverage instrumentation works by extracting source code spans from MIR. However, some kinds of syntax are effectively erased during MIR building, so their spans don't necessarily exist anywhere in MIR, making them invisible to the coverage instrumentor (unless we resort to various heuristics and hacks to recover them). This PR introduces `CoverageKind::SpanMarker`, which is a new variant of `StatementKind::Coverage`. Its sole purpose is to represent spans that would otherwise not appear in MIR, so that the coverage instrumentor can extract them. When coverage is enabled, the MIR builder can insert these dummy statements as needed, to improve the accuracy of spans used by coverage mappings. Fixes #115468. --- ```@rustbot``` label +A-code-coverage
2023-12-09Auto merge of #118150 - roblabla:new-win7-targets, r=davidtwcobors-0/+135
Add new targets {x86_64,i686}-win7-windows-msvc This PR adds two new Tier 3 targets, x86_64-win7-windows-msvc and i686-win7-windows-msvc, that aim to support targeting Windows 7 after the `*-pc-windows-msvc` target drops support for it (slated to happen in 1.76.0). # Tier 3 target policy > At this tier, the Rust project provides no official support for a target, so we place minimal requirements on the introduction of targets. > > A proposed new tier 3 target must be reviewed and approved by a member of the compiler team based on these requirements. The reviewer may choose to gauge broader compiler team consensus via a [Major Change Proposal (MCP)](https://forge.rust-lang.org/compiler/mcp.html). > > A proposed target or target-specific patch that substantially changes code shared with other targets (not just target-specific code) must be reviewed and approved by the appropriate team for that shared code before acceptance. > > - A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.) This is me, `@roblabla` on github. > - Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target. I went with naming the target `x86_64-win7-windows-msvc`, inserting the `win7` in the vendor field (usually set to to `pc`). This is done to avoid ecosystem churn, as quite a few crates have `cfg(target_os = "windows")` or `cfg(target_env = "msvc")`, but nearly no `cfg(target_vendor = "pc")`. Since my goal is to be able to seamlessly swap to the `win7` target, I figured it'd be easier this way. > - Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it. I believe the naming is pretty explicit. > - If possible, use only letters, numbers, dashes and underscores for the name. Periods (`.`) are known to cause issues in Cargo. The name comforms to this requirement. > - Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. > - The target must not introduce license incompatibilities. > - Anything added to the Rust repository must be under the standard Rust license (`MIT OR Apache-2.0`). > - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the `tidy` tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements. > - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, `rustc` built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. > - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are *not* limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users. As far as I understand it, this target has exactly the same legal situation as the existing Tier 1 x86_64-pc-windows-msvc. > - Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. > - This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements. Understood. > - Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. This target supports the whole libstd surface, since it's essentially reusing all of the x86_64-pc-windows-msvc target. Understood. > - The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary. Wrote some documentation on how to build, test and cross-compile the target in the `platform-support` part. Hopefully it's enough to get started. > - Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via ``@`)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages. > - Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications. Understood. > - Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. > - In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. Understood. > If a tier 3 target stops meeting these requirements, or the target maintainers no longer have interest or time, or the target shows no signs of activity and has not built for some time, or removing the target would improve the quality of the Rust codebase, we may post a PR to remove it; any such PR will be CCed to the target maintainers (and potentially other people who have previously worked on the target), to check potential interest in improving the situation. Understood.
2023-12-09Auto merge of #3216 - eduardosm:fix-ptestnzc, r=RalfJungbors-36/+41
Fix x86 SSE4.1 ptestnzc Fixes ptestnzc by bringing back the original implementation of https://github.com/rust-lang/miri/pull/3214. `(op & mask) != 0 && (op & mask) == !ask` need to be calculated for the whole vector. It cannot be calculated for each element and then folded. For example, given * `op = [0b100, 0b010]` * `mask = [0b100, 0b110]` The correct result would be: * `op & mask = [0b100, 0b010]` Comparisons are done on the vector as a whole: * `all_zero = (op & mask) == [0, 0] = false` * `masked_set = (op & mask) == mask = false` * `!all_zero && !masked_set = true` correct result The previous method: * `op & mask = [0b100, 0b010]` Comparisons are done element-wise: * `all_zero = (op & mask) == [0, 0] = [true, true]` * `masked_set = (op & mask) == mask = [true, false]` * `!all_zero && !masked_set = [true, false]` After folding with AND, the final result would be `false`, which is incorrect.
2023-12-09Auto merge of #117873 - quininer:android-emutls, r=Amanieubors-28/+71
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2023-12-09Auto merge of #114136 - TennyZhuang:linked-list-retain, r=thomccbors-0/+93
add LinkedList::{retain,retain_mut} Implement #114135 The API is consistent with other collections.
2023-12-09Some types cannot show up as the type of a patternNadrieril-4/+3
2023-12-09Auto merge of #118763 - matthiaskrgr:rollup-mgyf5hp, r=matthiaskrgrbors-538/+1354
Rollup of 6 pull requests Successful merges: - #117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`) - #118502 (fix: correct the arg for 'suggest to use associated function syntax' diagnostic) - #118694 (Add instance evaluation and methods to read an allocation in StableMIR) - #118715 (privacy: visit trait def id of projections) - #118730 (recurse into refs when comparing tys for diagnostics) - #118736 (temporarily revert "ice on ambguity in mir typeck") r? `@ghost` `@rustbot` modify labels: rollup
2023-12-09Lower some forgotten coroutine spansMichael Goulet-2/+2
2023-12-09Lower spans for opaque duplicated lifetimes, const infer varsMichael Goulet-3/+3
2023-12-09Lower constness span in host paramMichael Goulet-0/+1
2023-12-09Don't warn an empty pattern unreachable if we're not sure the data is validNadrieril-654/+183
2023-12-09Track place validityNadrieril-30/+216
2023-12-09Detect cycles in `InhabitedPredicate::apply`Nadrieril-10/+31
This is for post-monomorphization cycles. These are only caught later (in drop elaboration for the example that I saw), so we need to handle them here. This issue wasn't noticed before because exhaustiveness only checked inhabitedness when `exhaustive_patterns` was on. The preceding commit now check inhabitedness always, which revealed the problem.
2023-12-09Correctly handle empty constructorsNadrieril-158/+212
- `ConstructorSet` knows about both empty and nonempty constructors; - If an empty constructor is present in the column, we output it in `split().present`.
2023-12-09Be precise about usefulness vs reachabilityNadrieril-94/+159
2023-12-09Test empty types betterNadrieril-502/+2606
2023-12-08Fix tidy ```ignore errorDavid Tolnay-2/+2
tidy error: /git/rust/compiler/rustc_ast_pretty/src/pprust/state.rs:1165: unexplained "```ignore" doctest; try one: * make the test actually pass, by adding necessary imports and declarations, or * use "```text", if the code is not Rust code, or * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or * use "```should_panic", if the code is expected to fail at run time, or * use "```no_run", if the code should type-check but not necessary linkable/runnable, or * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided. tidy error: /git/rust/compiler/rustc_ast_pretty/src/pprust/state.rs:1176: unexplained "```ignore" doctest; try one: * make the test actually pass, by adding necessary imports and declarations, or * use "```text", if the code is not Rust code, or * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or * use "```should_panic", if the code is expected to fail at run time, or * use "```no_run", if the code should type-check but not necessary linkable/runnable, or * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
2023-12-08Do not parenthesize exterior struct lit inside match guardsDavid Tolnay-75/+150
2023-12-08Delete special handling of some expr kinds from print_letDavid Tolnay-10/+2
In all four of Break, Closure, Ret, Yeet, the needs_par_as_let_scrutinee is guaranteed to return true because the .precedence().order() of those expr kinds is <= AssocOp::LAnd.precedence(). The relevant functions in rustc_ast::util::parser are: fn needs_par_as_let_scrutinee(order: i8) -> bool { order <= prec_let_scrutinee_needs_par() as i8 } fn prec_let_scrutinee_needs_par() -> usize { AssocOp::LAnd.precedence() } The .precedence().order() of Closure is PREC_CLOSURE (-40) and of Break, Ret, Yeet is PREC_JUMP (-30). The value of AssocOp::LAnd.precedence() is 6. So this commit causes no change in behavior, only potentially performance by doing a redundant call to contains_exterior_struct_lit in those four cases. This is fine because Break, Closure, Ret, Yeet should be exceedingly rare in the position of a let scrutinee.
2023-12-08Rearrange logic of needs_par computation in print_letDavid Tolnay-2/+5
True || needs_par_as_let_scrutinee(...) is always true.
2023-12-08Inline cond_needs_par into print_letDavid Tolnay-3/+8
2023-12-08Inline npals closureDavid Tolnay-2/+5
2023-12-08Add if_let_guard and let_chains pretty printer testsDavid Tolnay-1/+20
2023-12-08Add Bevy related test casesSantiago Pastorino-0/+97
2023-12-09Tweak `Mode`.Nicholas Nethercote-34/+38
- Add `use Mode::*` to avoid all the qualifiers. - Reorder the variants. The existing order makes no particular sense, which has bugged me for some time. I've chosen an order that makes sense to me.
2023-12-09Remove an unnecessary `into`.Nicholas Nethercote-1/+1
2023-12-09Tweak the `no-nuls.rs` test.Nicholas Nethercote-0/+0
The `empty!` macro calls should be outside the `cfg(FALSE)` function.
2023-12-09Eliminate `is_byte: bool` args in unescaping code.Nicholas Nethercote-21/+19
These don't really make sense since C string literals were added. This commit removes them in favour for `mode: Mode` args. `ascii_check` still has a `characters_should_be_ascii: bool` arg. Also, `characters_should_be_ascii` is renamed to be shorter.
2023-12-09Remove explicit `\n` and `\t` handling in `unescape_str_common`.Nicholas Nethercote-2/+0
The fallback `_` case works for these chars, no need to treat them specially.
2023-12-09Add some useful comments.Nicholas Nethercote-4/+8