about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-12-31Rollup merge of #134949 - compiler-errors:froms, r=jieyouxuStuart Cook-45/+45
Convert some `Into` impls into `From` impls From the [`From`](https://doc.rust-lang.org/std/convert/trait.From.html) docs: > One should always prefer implementing `From` over [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) because implementing `From` automatically provides one with an implementation of [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) thanks to the blanket implementation in the standard library. > > Only implement [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) when targeting a version prior to Rust 1.41 and converting to a type outside the current crate. `From` was not able to do these types of conversions in earlier versions because of Rust’s orphaning rules. See [Into](https://doc.rust-lang.org/std/convert/trait.Into.html) for more details. Some of these impls are likely from before 1.41, and then some others were probably just mistakes. Building nightly rust is definitely not supported on 1.41, so let's modernize these impls :D
2024-12-31Rollup merge of #134941 - workingjubilee:rustc-abi-normal, r=NoratriebStuart Cook-0/+32
compiler: Add a statement-of-intent to `rustc_abi` This just documents the most basic idea of what the crate is even for in my view, rather than leaving that strewn about GitHub issues, PR reviews, and Zulip streams. In particular, I hope to make it clearer what code should go in `rustc_abi` and what should not, which is of immediate relevance to contributors. I considered going even further and explaining ideas like "ABI compatibility", prologues, and so on. However, because of the cross-cutting nature of ABI, I think such explanations should probably live in the place for cross-cutting documents: the rustc dev guide. This is only meant to be a quick "by the way".
2024-12-31Rollup merge of #134934 - Noname-Official:patch-1, r=saethlinStuart Cook-6/+6
Fix typos
2024-12-31Rollup merge of #134933 - compiler-errors:async-fn-future-sized, r=lqdStuart Cook-3/+20
Make sure we check the future type is `Sized` in `AsyncFn*` Fixes #134817
2024-12-31Rollup merge of #134932 - RalfJung:arm-float-abi, r=workingjubileeStuart Cook-103/+258
explicitly set float ABI for all ARM targets We currently always set the `FloatABIType` field in the LLVM target machine to `Default`, which means LLVM infers the ARM float ABI (hard vs soft) from the LLVM target triple. This causes problems such as having to set the LLVM triple to `*-gnueabi` for our `musleabi` targets to ensure they get correctly inferred as soft-float targets. It also means rustc doesn't really know which float ABI ends up being used, which is a blocker for https://github.com/rust-lang/rust/pull/134794. So I think we should stop doing that and instead explicitly control that value. That's what this PR implements. See [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fwg-llvm/topic/Softfloat.20ABI.2C.20hardfloat.20instructions) for more context. Best reviewed commit-by-commit. I hope I got all those `llvm_floatabi` values right...
2024-12-31Convert some Into impls into From implsMichael Goulet-45/+45
2024-12-31Make sure we check the future type is Sized in AsyncFn*Michael Goulet-3/+20
2024-12-30Auto merge of #134757 - RalfJung:const_swap, r=scottmcmbors-50/+35
stabilize const_swap libs-api FCP passed in https://github.com/rust-lang/rust/issues/83163. However, I only just realized that this actually involves an intrinsic. The intrinsic could be implemented entirely with existing stable const functionality, but we choose to make it a primitive to be able to detect more UB. So nominating for `@rust-lang/lang` to make sure they are aware; I leave it up to them whether they want to FCP this. While at it I also renamed the intrinsic to make the "nonoverlapping" constraint more clear. Fixes #83163
2024-12-30compiler: Add a statement-of-intent to `rustc_abi`Jubilee Young-0/+32
2024-12-30musleabi* targets: we no longer need to set gnueabi* for LLVM now that we ↵Ralf Jung-25/+6
set the float ABI explicitly
2024-12-30explicitly set float ABI for all ARM targetsRalf Jung-64/+150
2024-12-30add llvm_floatabi field to target spec that controls FloatABITypeRalf Jung-4/+67
2024-12-30Fix typosNoName-6/+6
2024-12-30Auto merge of #134914 - lqd:polonius-next-episode-5, r=jackh726bors-210/+189
A couple datalog/borrowck cleanups As discussed on zulip, here's a chill one in between slightly more interesting PRs: - I hadn't noticed there still were a couple of datalog-related modules outside of their dedicated `polonius` module (go to horn-clause jail, bonk!). - there somehow was both a `diags` module and a `diagnostics` module. - a couple other tiny things being renamed -- let me know what you think. As requested I've tried to have somewhat granular commits to ease review, but the last two or three could be squashed together, since they're all related to the `diags` module (but moving its contents is less tedious to check in its own commit). r? `@jackh726`
2024-12-30rustc_llvm: expose FloatABIType target machine parameterRalf Jung-14/+39
2024-12-30Auto merge of #134885 - RalfJung:arm-soft-float, r=workingjubileebors-2/+2
make -Csoft-float have an effect on all ARM targets See the discussion [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fwg-llvm/topic/Softfloat.20ABI.2C.20hardfloat.20instructions): apparently `-float-abi=soft` is how one can force "use soffloat ABI but hardware FP instructions" on ARM-32. Our version of that is `-Csoft-float` but I made that one a NOP on all targets except for ARM eabihf (see https://github.com/rust-lang/rust/pull/129897)... which now make experimentation on what we actually want to do here a lot harder. So, let's unlock the flag on all ARM targets while we are still figuring out our long-term plans here. Cc `@workingjubilee`
2024-12-30rename `diags` fieldRémy Rakic-19/+26
2024-12-30clean up `BorrowckDiags`Rémy Rakic-23/+13
- rename it to what it does, buffer diagnostics - remove single-use functions - use derives
2024-12-30merge `diags` module into `diagnostics`Rémy Rakic-149/+142
it's a more natural place for diagnostics-related structures and functions
2024-12-30move `facts` module to polonius legacy moduleRémy Rakic-22/+17
this is specific to the old datalog implementation and wasn't noticed in the previous module move
2024-12-30simplify `add_extra_drop_facts`Rémy Rakic-25/+20
this is mostly to remove imports of the polonius legacy module also what is going on in this function, what the...
2024-12-30move `location` module to polonius legacy moduleRémy Rakic-11/+11
this is specific to the old datalog implementation and wasn't noticed in the previous module move
2024-12-30fix a couple nitsRémy Rakic-7/+6
- remove unneeded type ascription - fix variable name - fix typo in comment - fix `var_origins` var and function name: these are `VarInfos`
2024-12-30Auto merge of #134866 - osiewicz:write-rlib-bufwriter, r=bjorn3bors-2/+5
rustc_codegen_ssa: Buffer file writes in link_rlib This makes this step take ~25ms on my machine (M3 Max 64GB) for Zed repo instead of ~150ms (on editor crate). Additionally it takes down the time needed for a clean cargo build of ripgrep from ~6.1s to 5.9s. This change is mostly relevant for dev builds of crates with multiple large CGUs. I imagine it could be quite relevant for dev scenarios on Windows, but sadly I have no way to measure that myself.
2024-12-30Auto merge of #134670 - lqd:polonius-next-episode-4, r=jackh726bors-128/+498
Compute liveness constraints in location-sensitive polonius This continues the location-sensitive prototype. In this episode, we build the liveness constraints. Reminder of the approach we're taking: we need variance data to create liveness edges in the forward/backward/both directions (respectively in the cases of covariance, contravariance, invariance) in the localized constraint graph. This PR: - introduces the holder for that, and for the liveness data in the correct shape: the transpose of what we're using today, "live regions per points". - records use/drop live region variance during tracing - records regular live region variance at the end of liveness - records the correctly shaped live region per point matrix - uses all of the above to compute the liveness constraints (There's still technically one tiny part of the liveness owl left to do, but I'll leave it for a future PR: we also need to disable the NLL optimization that avoids computing liveness for locals whose types contain a region outliving a free region -- the existing constraints make it effectively live at all points; this doesn't work under polonius) r? `@jackh726` cc `@matthewjasper`
2024-12-29Auto merge of #134901 - matthiaskrgr:rollup-b0wwuht, r=matthiaskrgrbors-1/+1
Rollup of 4 pull requests Successful merges: - #134870 (Fix sentence fragment in `pin` module docs) - #134884 (Fix typos) - #134892 (Added codegen test for elidings bounds check when indexes are manually checked) - #134894 (Document how to run the split Docker pipelines) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-29review fixes: Adjust whitespacePiotr Osiewicz-0/+3
2024-12-29Rollup merge of #134884 - calciumbe:patch1, r=jieyouxuMatthias Krüger-1/+1
Fix typos Hello, I fix some typos in docs and comments. Thank you very much.
2024-12-29Auto merge of #134765 - Noratrieb:linux-none-cant-unwind-silly, r=jieyouxubors-2/+3
Improve default target options for x86_64-unknown-linux-none Without a standard library, we cannot unwind, so it should be panic=abort by default. Additionally, it does not have std because while it is Linux, it cannot use libc, which std uses today for Linux. Using PIE by default may be surprising to users, as shown in #134763, so I've documented it explicitly. I'm not sure if we want to count that as fixing the issue or not. cc `@morr0ne,` as you added the target (and are the maintainer), and `@Noratrieb,` who reviewed that PR (:D).
2024-12-29address review commentsRémy Rakic-7/+24
- add a FIXME when looking for the region variance of unexpected regions - drive-by: fix a doc comment link - drive-by: simplify the variance match using exported variants instead
2024-12-29liveness constraints: draw the rest of the owlRémy Rakic-71/+180
2024-12-29finish filling polonius contextRémy Rakic-8/+40
transpose liveness matrix and record live regions at the end of MIR typeck
2024-12-29improve `bit_set` assertionRémy Rakic-1/+6
it missed the index and bounds info
2024-12-29record variance of regular live regionsRémy Rakic-3/+21
2024-12-29record variance of use/drop live regionsRémy Rakic-6/+12
records the variance of: - use live types - drop live generic args
2024-12-29add variance recordingRémy Rakic-0/+126
Following the Generalizer's structure, relating e.g. a type with itself will allow tracking the variance wrt the contained regions.
2024-12-29introduce polonius contextRémy Rakic-47/+104
This context struct will hold data to help creating localized constraints: - the live regions, with the shape matching a CFG walk, indexed per point - the variance of these live regions, represented as the direction we'll add the appropriate We also add this structure to the mir typeck to record liveness data, and make it responsible for localized constraint creation.
2024-12-29fix: typoscalciumbe-1/+1
Signed-off-by: calciumbe <192480234+calciumbe@users.noreply.github.com>
2024-12-29Rollup merge of #134869 - clubby789:cc-bump, r=jieyouxuStuart Cook-2/+2
Bump compiler cc Fixes #134657 Pulls in https://github.com/rust-lang/cc-rs/pull/1330 try-job: x86_64-msvc
2024-12-29make -Csoft-float have an effect on all ARM targetsRalf Jung-2/+2
2024-12-29Auto merge of #134627 - estebank:issue-133252, r=jackh726bors-2/+8
Avoid ICE in borrowck Provide a fallback in `best_blame_constraint` when `find_constraint_paths_between_regions` doesn't have a result. This code is due a rework to avoid the letf-over `unwrap()`, but avoids the ICE caused by the repro. Fix #133252.
2024-12-29Bump compiler ccclubby789-2/+2
2024-12-29rustc_codegen_ssa: Buffer file writes in link_rlibPiotr Osiewicz-5/+5
This makes this step take ~25ms on my machine (M3 Max 64GB) for Zed repo instead of ~150ms. Additionally it takes down the time needed for a clean cargo build of ripgrep from ~6.1s to 5.9s. This change is mostly relevant for crates with multiple large CGUs.
2024-12-28Auto merge of #131244 - clubby789:match-branches-unreachable, r=DianQKbors-9/+39
Consider empty-unreachable otherwise branches in MatchBranchSimplification Fixes #131219
2024-12-28Rollup merge of #134832 - tgross35:update-builtins, r=tgross35Stuart Cook-2/+2
Update `compiler-builtins` to 0.1.140 Nothing significant here, just syncing the following small changes: - https://github.com/rust-lang/compiler-builtins/pull/727 - https://github.com/rust-lang/compiler-builtins/pull/730 - https://github.com/rust-lang/compiler-builtins/pull/736 - https://github.com/rust-lang/compiler-builtins/pull/737
2024-12-28Rollup merge of #134737 - estebank:deive-lint-default-fields-base, ↵Stuart Cook-0/+188
r=compiler-errors Implement `default_overrides_default_fields` lint Detect when a manual `Default` implementation isn't using the existing default field values and suggest using `..` instead: ``` error: `Default` impl doesn't use the declared default field values --> $DIR/manual-default-impl-could-be-derived.rs:14:1 | LL | / impl Default for A { LL | | fn default() -> Self { LL | | A { LL | | y: 0, | | - this field has a default value ... | LL | | } | |_^ | = help: use the default values in the `impl` with `Struct { mandatory_field, .. }` to avoid them diverging over time note: the lint level is defined here --> $DIR/manual-default-impl-could-be-derived.rs:5:9 | LL | #![deny(default_overrides_default_fields)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` r? `@compiler-errors` This is a simpler version of #134441, detecting the simpler case when a field with a default should have not been specified in the manual `Default::default()`, instead using `..` for it. It doesn't provide any suggestions, nor the checks for "equivalences" nor whether the value used in the imp being used would be suitable as a default field value.
2024-12-27Rollup merge of #134834 - dtolnay:unnamedcall, r=compiler-errorsDavid Tolnay-2/+10
Skip parenthesis around tuple struct field calls The pretty-printer previously did not distinguish between named vs unnamed fields when printing a function call containing a struct field. It would print the call as `(self.fun)()` for a named field which is correct, and `(self.0)()` for an unnamed field which is redundant. This PR changes function calls of tuple struct fields to print without parens. **Before:** ```rust struct Tuple(fn()); fn main() { let tuple = Tuple(|| {}); (tuple.0)(); } ``` **After:** ```rust struct Tuple(fn()); fn main() { let tuple = Tuple(|| {}); tuple.0(); } ```
2024-12-27Rollup merge of #134833 - dtolnay:leftmostwithdot, r=compiler-errorsDavid Tolnay-11/+31
Skip parenthesis if `.` makes statement boundary unambiguous There is a rule in the parser that statements and match-arms never end in front of a `.` or `?` token (except when the `.` is really `..` or `..=` or `...`). So some of the leading subexpressions that need parentheses inserted when followed by some other operator like `-` or `+`, do not need parentheses when followed by `.` or `?`. Example: ```rust fn main() { loop {}.to_string() + ""; match () { _ => loop {}.to_string() + "", }; } ``` `-Zunpretty=expanded` before: ```console #![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; fn main() { (loop {}).to_string() + ""; match () { _ => (loop {}).to_string() + "", }; } ``` After: ```console #![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; fn main() { loop {}.to_string() + ""; match () { _ => loop {}.to_string() + "", }; } ```
2024-12-27Rollup merge of #134827 - compiler-errors:borrowck-nits, r=lqdDavid Tolnay-6/+7
Some random region tweaks Remove a redundant function and add an assertion that I think is useful
2024-12-27Rollup merge of #134823 - chloefeal:fix, r=tgross35,dtolnayDavid Tolnay-4/+4
Fix typos This PR focuses on correcting typos and improving clarity in documentation files. Thank you.