about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2024-03-22Auto merge of #122852 - compiler-errors:raw-ptr, r=lcnrbors-112/+80
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability` Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout. r? lcnr cc rust-lang/types-team#124
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-40/+40
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-66/+66
2024-03-22Rollup merge of #122839 - compiler-errors:predicate-polarity, r=lcnrMatthias Krüger-6/+6
Split out `PredicatePolarity` from `ImplPolarity` Because having to deal with a third `Reservation` level in all the trait solver code is kind of weird. r? `@lcnr` or `@oli-obk`
2024-03-22Rollup merge of #122195 - jieyouxu:impl-return-note, r=fmeaseMatthias Krüger-0/+1
Note that the caller chooses a type for type param ``` error[E0308]: mismatched types --> $DIR/return-impl-trait.rs:23:5 | LL | fn other_bounds<T>() -> T | - - | | | | | expected `T` because of return type | | help: consider using an impl return type: `impl Trait` | expected this type parameter ... LL | () | ^^ expected type parameter `T`, found `()` | = note: expected type parameter `T` found unit type `()` = note: the caller chooses the type of T which can be different from () ``` Tried to see if "expected this type parameter" can be replaced, but that goes all the way to `rustc_infer` so seems not worth the effort and can affect other diagnostics. Revives #112088 and #104755.
2024-03-22fix(bootstrap/dist): use versioned dirs when vendoringBernardo Meurer Costa-0/+1
Currently, if you attempt to run ui tests in a vendored build, you will see this failure ``` ---- [ui] tests/ui/issues/issue-21763.rs stdout ---- diff of stderr: 8 = note: required because it appears within the type `(Rc<()>, Rc<()>)` 9 = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` 10 note: required because it appears within the type `hashbrown::map::HashMap<Rc<()>, Rc<()>, RandomState>` - --> $HASHBROWN_SRC_LOCATION + --> /rust/deps/hashbrown/src/map.rs:190:12 12 note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` 13 --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL 14 note: required by a bound in `foo` ``` This happend because the code that attempts to remap `HASHBROWN_SRC_LOCATION` expects it to be under `hashbrown-$version`, which is the case in a normal cargo registry, but not when vendor, where by default crates may not have the version in their directory name. This change passes `--versioned-dirs` to `cargo vendor` to enforce that every crate includes the version in the subdir name, which fixes the ui test and brings `--enable-vendor` builds closer to normal ones.
2024-03-22Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelixbors-0/+2
"Handle" calls to upstream monomorphizations in compiler_builtins This is pretty cooked, but I think it works. compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints. I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it. If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-22tests/ui: Add a directory for warnings, add a testMichael Baikov-1/+1
2024-03-22Fix clippyMichael Goulet-6/+6
2024-03-22And the tools tooMichael Goulet-71/+44
2024-03-22Make RawPtr take Ty and Mutbl separatelyMichael Goulet-2/+2
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-34/+32
2024-03-22Eagerly convert some ctors to use their specialized ctorsMichael Goulet-7/+4
2024-03-22Merge from rustcRalf Jung-1637/+5005
2024-03-22Preparing for merge from rustcRalf Jung-1/+1
2024-03-22Codegen const panic messages as function callsMark Rousskov-2/+10
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
2024-03-22Auto merge of #122869 - matthiaskrgr:rollup-0navj4l, r=matthiaskrgrbors-17/+92
Rollup of 9 pull requests Successful merges: - #121619 (Experimental feature postfix match) - #122370 (Gracefully handle `AnonConst` in `diagnostic_hir_wf_check()`) - #122537 (interpret/allocation: fix aliasing issue in interpreter and refactor getters a bit) - #122542 (coverage: Clean up marker statements that aren't needed later) - #122800 (Add `NonNull::<[T]>::is_empty`.) - #122820 (Stop using `<DefId as Ord>` in various diagnostic situations) - #122847 (Suggest `RUST_MIN_STACK` workaround on overflow) - #122855 (Fix Itanium mangling usizes) - #122863 (add more ice tests ) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-22Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkovMatthias Krüger-17/+92
Experimental feature postfix match This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement. It is entirely implemented in the parser, so it should be relatively easy to remove if needed. This PR is split in to 5 commits to ease review. 1. The implementation of the feature & gating. 2. Add a MatchKind field, fix uses, fix pretty. 3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix. 4. Add new MatchSource to HIR for Clippy & other HIR consumers
2024-03-22Update (doc) commentsLeón Orell Valerian Liehr-8/+8
Several (doc) comments were super outdated or didn't provide enough context. Some doc comments shoved everything in a single paragraph without respecting the fact that the first paragraph should be a single sentence because rustdoc treats these as item descriptions / synopses on module pages.
2024-03-22Rename AstConv to HIR ty loweringLeón Orell Valerian Liehr-38/+26
This includes updating astconv-related items and a few local variables.
2024-03-21rustdoc-search: compressed bitmap to sort, then load descMichael Howell-37/+393
This adds a bit more data than "pure sharding" by including information about which items have no description at all. This way, it can sort the results, then truncate, then finally download the description. With the "e" bitmap: 2380KiB Without the "e" bitmap: 2364KiB
2024-03-22Rollup merge of #122845 - flip1995:clippy-subtree-update, r=matthiaskrgrMatthias Krüger-1047/+4182
Clippy subtree update r? ``@Manishearth``
2024-03-22Rollup merge of #122838 - ↵Matthias Krüger-2/+3
workingjubilee:less-catholic-blessings-to-prevent-incremental-protests, r=matthiaskrgr Avoid noop rewrite of issues.txt Fixes #122834 r? ```@matthiaskrgr```
2024-03-22Rollup merge of #122831 - onur-ozkan:less-verbose-fail-logs, r=clubby789Matthias Krüger-7/+15
make failure logs less verbose Resolves #122706 Logs without verbose flag: ![image](https://github.com/rust-lang/rust/assets/39852038/f2fc2d35-0954-44b0-bedc-045afedaabe8) Logs with verbose flag: ![image](https://github.com/rust-lang/rust/assets/39852038/b9308655-ad31-4527-a1be-5a62a78ac469) I decided to exclude command from the log since it's already included in verbose mode. cc ```@Nilstrieb```
2024-03-21Merge commit '9d6f41691ed9dbfaec2a2df2661c42451f2fe0d3' into ↵Philipp Krones-1047/+4182
clippy-subtree-update
2024-03-21Avoid noop rewrite of issues.txtJubilee Young-2/+3
This can trigger incremental rebuilds since incr doesn't realize nothing changed.
2024-03-21Allow `llvm.x86.sse2.pause` instrinsic to be called without SSE2Eduardo Sánchez Muñoz-6/+43
The instrinsic is compiled to a `pause` instruction, which behaves like a no-op when SSE2 is not available. https://www.felixcloutier.com/x86/pause.html
2024-03-21make failure logs less verboseonur-ozkan-7/+15
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-6/+17
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-21Rollup merge of #122799 - estebank:issue-122569, r=fee1-deadMatthias Krüger-1/+3
Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix #122569.
2024-03-21Rollup merge of #122795 - alexcrichton:fix-wasm-beta-bootstrap, ↵Matthias Krüger-2/+9
r=Mark-Simulacrum Inherit `RUSTC_BOOTSTRAP` when testing wasm This is implemented with the freshly-released Wasmtime 19 and should prevent beta breakage from wasm tests that was observed and fixed in #122640 again.
2024-03-21Rollup merge of #122696 - royb3:riscv32ima, r=petrochenkovMatthias Krüger-1/+7
Add bare metal riscv32 target. I asked in the embedded Rust matrix if it would be OK to clone a PR to add another riscv32 configuration. The riscv32ima in this case. ``````@MabezDev`````` was open to this suggestion as a maintainer for the Riscv targets. I now took https://github.com/rust-lang/rust/pull/117958/ for inspiration and added/edited the appropriate files. # [Tier 3 target policy](https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#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.) The target being added is using riscv32 as a basis, with added extensions. The riscv32 targets already have a maintainer and are named in the description file. > * 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. > * 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. > * If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo. Name is derived from the extensions used in the target. > * 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. Same conditions apply compared to other riscv32 targets. > * Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0). Same conditions apply compared to other riscv32 targets. > * 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. Same conditions apply compared to other riscv32 targets. > * 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. Same conditions apply compared to other riscv32 targets. > * "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. Same conditions apply compared to other riscv32 targets. > * 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. Same conditions apply compared to other riscv32 targets. > * 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 is build on top of existing riscv32 targets and inherits these implementations. > * 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. The documentation of this target is shared along with targets that target riscv32 with a different configuration of extensions. > * 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. I now understand, apologies for the mention before. > * 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. I now understand, apologies for the link to a similar PR before. > * 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. This should not cause issues, as the target has similarities to other configurations of the riscv32 targets. > * Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. This should not cause issues, as the target has similarities to other configurations of the riscv32 targets.
2024-03-21Auto merge of #121123 - compiler-errors:item-assumptions, r=oli-obkbors-5/+5
Split an item bounds and an item's super predicates This is the moral equivalent of #107614, but instead for predicates this applies to **item bounds**. This PR splits out the item bounds (i.e. *all* predicates that are assumed to hold for the alias) from the item *super predicates*, which are the subset of item bounds which share the same self type as the alias. ## Why? Much like #107614, there are places in the compiler where we *only* care about super-predicates, and considering predicates that possibly don't have anything to do with the alias is problematic. This includes things like closure signature inference (which is at its core searching for `Self: Fn(..)` style bounds), but also lints like `#[must_use]`, error reporting for aliases, computing type outlives predicates. Even in cases where considering all of the `item_bounds` doesn't lead to bugs, unnecessarily considering irrelevant bounds does lead to a regression (#121121) due to doing extra work in the solver. ## Example 1 - Trait Aliases This is best explored via an example: ``` type TAIT<T> = impl TraitAlias<T>; trait TraitAlias<T> = A + B where T: C; ``` The item bounds list for `Tait<T>` will include: * `Tait<T>: A` * `Tait<T>: B` * `T: C` While `item_super_predicates` query will include just the first two predicates. Side-note: You may wonder why `T: C` is included in the item bounds for `TAIT`? This is because when we elaborate `TraitAlias<T>`, we will also elaborate all the predicates on the trait. ## Example 2 - Associated Type Bounds ``` type TAIT<T> = impl Iterator<Item: A>; ``` The `item_bounds` list for `TAIT<T>` will include: * `Tait<T>: Iterator` * `<Tait<T> as Iterator>::Item: A` But the `item_super_predicates` will just include the first bound, since that's the only bound that is relevant to the *alias* itself. ## So what This leads to some diagnostics duplication just like #107614, but none of it will be user-facing. We only see it in the UI test suite because we explicitly disable diagnostic deduplication. Regarding naming, I went with `super_predicates` kind of arbitrarily; this can easily be changed, but I'd consider better names as long as we don't block this PR in perpetuity.
2024-03-21Auto merge of #121587 - ShoyuVanilla:fix-issue-121267, r=TaKO8Kibors-1/+4
Fix bad span for explicit lifetime suggestions Fixes #121267 Current explicit lifetime suggestions are not showing correct spans for some lifetimes - e.g. elided lifetime generic parameters; This should be done correctly regarding elided lifetime kind like the following code https://github.com/rust-lang/rust/blob/43fdd4916d19f4004e23d422b5547637ad67ab21/compiler/rustc_resolve/src/late/diagnostics.rs#L3015-L3044
2024-03-20Add a testBen Kimock-0/+2
2024-03-21Auto merge of #122803 - jhpratt:rollup-nmgs79k, r=jhprattbors-26/+23
Rollup of 8 pull requests Successful merges: - #122545 (Ignore paths from expansion in `unused_qualifications`) - #122729 (Relax SeqCst ordering in standard library.) - #122740 (use more accurate terminology) - #122749 (make `type_flags(ReError) & HAS_ERROR`) - #122764 (coverage: Remove incorrect assertions from counter allocation) - #122765 (Add `usize::MAX` arg tests for Vec) - #122776 (Rename `hir::Let` into `hir::LetExpr`) - #122786 (compiletest: Introduce `remove_and_create_dir_all()` helper) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-21Fix bad span for explicit lifetime suggestionShoyu Vanilla-1/+4
Move verbose logic to a function Minor renaming
2024-03-20Rollup merge of #122786 - Enselic:remove_and_create_dir_all, r=onur-ozkanJacob Pratt-15/+12
compiletest: Introduce `remove_and_create_dir_all()` helper The code let _ = fs::remove_dir_all(&dir); create_dir_all(&dir).unwrap(); is duplicated in 7 places. Let's introduce a helper.
2024-03-20Rollup merge of #122776 - GuillaumeGomez:rename-hir-let, r=oli-obkJacob Pratt-11/+11
Rename `hir::Let` into `hir::LetExpr` As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). r? `````@Zalathar`````
2024-03-21Replace closures with `_` when suggesting fully qualified path for method callEsteban Küber-1/+3
``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix #122569.
2024-03-21Auto merge of #122772 - nikic:update-llvm-22, r=cuviperbors-0/+0
Update to LLVM 18.1.2 Fixes https://github.com/rust-lang/rust/issues/122476. Also contains fixes for https://github.com/Rahix/avr-hal/issues/505 and https://github.com/llvm/llvm-project/issues/83362. r? `@cuviper`
2024-03-20Inherit `RUSTC_BOOTSTRAP` when testing wasmAlex Crichton-2/+9
This is implemented with the freshly-released Wasmtime 19 and should prevent beta breakage from wasm tests that was observed and fixed in #122640 again.
2024-03-20compiletest: Introduce remove_and_create_dir_all() helperMartin Nordholts-15/+12
The code let _ = fs::remove_dir_all(&dir); create_dir_all(&dir).unwrap(); is duplicated in 7 places. Let's introduce a helper.
2024-03-20compiletest: mir_dump_dir.as_path() -> &mir_dump_dirMartin Nordholts-1/+1
2024-03-20Bless test fallout (duplicate diagnostics)Michael Goulet-5/+5
2024-03-20When comparing SVG tests against their blessed version, ignore the first lineEsteban Küber-5/+14
`anstyle_svg` has some weird non-determinism in the width parameter, which makes tests blessed in one environment to fail in another. This is the *only* non-determinism detected so far, so we modify the diff check to ignore the first line of the SVG. In order for a test to fail/be updated by `--bless`, a different part of the file needs to also have changed.
2024-03-20Update target.rs alloc.rs event.rs simd.rsRoboSchmied-4/+4
fix typos
2024-03-20Make tidy error code parsing robust against commentsOli Scherer-13/+30
2024-03-20Use the more informative generic type inference failure error on method ↵Oli Scherer-1/+1
calls on raw pointers
2024-03-20Rename `hir::Let` into `hir::LetExpr`Guillaume Gomez-11/+11