about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-12-01rust_analyzer_settings: force use of 'nightly' toolchainRalf Jung-0/+4
2024-12-01Auto merge of #133499 - nikic:no-backend-verify, r=Mark-Simulacrumbors-13/+10
Respect verify-llvm-ir option in the backend We are currently unconditionally verifying the LLVM IR in the backend (twice), ignoring the value of the verify-llvm-ir option. This has substantial compile-time impact for debug builds.
2024-12-01Auto merge of #133365 - compiler-errors:compare-impl-item, r=lcnrbors-228/+123
Make `compare_impl_item` into a query Turns `compare_impl_item` into a query (generalizing the existing query for `compare_impl_const`), and uses that in `Instance::resolve` to fail resolution when an implementation is incompatible with the trait it comes from. Fixes #119701 Fixes #121127 Fixes #121411 Fixes #129075 Fixes #129127 Fixes #129214 Fixes #131294
2024-11-30Auto merge of #133684 - RalfJung:rollup-j2tmrg7, r=RalfJungbors-68/+170
Rollup of 6 pull requests Successful merges: - #131698 (use stores of the correct size to set discriminants) - #133571 (Mark visionOS as supporting `std`) - #133655 (Eliminate print_expr_maybe_paren function from pretty printers) - #133667 (Remove unused code) - #133670 (bump hashbrown version) - #133673 (replace hard coded error id with `ErrorKind::DirectoryNotEmpty`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-30Rollup merge of #133673 - onur-ozkan:windows-fixme, r=KobzolRalf Jung-3/+1
replace hard coded error id with `ErrorKind::DirectoryNotEmpty` Resolves an internal bootstrap FIXME.
2024-11-30Rollup merge of #133670 - RalfJung:hashbrown, r=AmanieuRalf Jung-2/+2
bump hashbrown version This pulls in https://github.com/rust-lang/hashbrown/pull/586, in preparation for https://github.com/rust-lang/rust/issues/102575. Cc ``@Amanieu``
2024-11-30Rollup merge of #133667 - sunwxg:xiaoguang/remove-unused-code, r=clubby789Ralf Jung-1/+0
Remove unused code
2024-11-30Rollup merge of #133655 - dtolnay:maybeparen, r=lcnrRalf Jung-52/+104
Eliminate print_expr_maybe_paren function from pretty printers This PR is part of backporting Syn's expression precedence design into rustc. (See #133603 for other work on this.) In Syn, our version of `print_expr_cond_paren` is called `print_subexpression` and it is called from 19 places. Of those calls, 12 of them need a "custom" behavior for the `needs_paren` argument, whereas only 7 use a "standard" behavior resembling `print_subexpression($e, $e.precedence() < Precedence::$Variant, ...)`. In other words the behavior that rustc_ast_pretty's `print_expr_maybe_paren` implements is actually not what you want most of the time. The current usage you see in rustc is overuse. <details> <summary>Aside: am I confident about the correctness of Syn's parenthesization? Yes. Click for details.</summary> --- The behavior is constrained by the following pair of tests which both run over every Rust source file of rustc and the standard library and tools and test suites: - To rule out **false positives**: for every expression in every source file, print the expression, parse it back, and verify that not a single new parenthesis got added. Since these are expressions parsed from source code, not macro-generated syntax trees, we know they must never need automatic parenthesis insertion. Rustc's pretty printer does not pass this. Pseudocode: `assert(expr == parse(print(expr)))` - To rule out **false negatives**: for every expression in every source file, replace every Expr::Paren node in the syntax tree with just its contents, i.e. stripping the parentheses but otherwise preserving the syntax tree structure. Then print the stripped expression performing parenthesis insertion wherever needed, and reparse it. Verify that the reparsed expression has identical structure to the original, despite there being no parentheses in the original prior to printing, i.e. all the right parentheses got re-inserted by the printer to preserve the expression's structure. Rustc's pretty printer does not pass this. See https://github.com/dtolnay/syn/pull/1788 which reveals multiple rustc_ast_pretty bugs. Pseudocode: `assert(unparenthesize(expr) == unparenthesize(parse(print(unparenthesize(expr)))))` --- </details> If `print_expr_maybe_paren` is usually not correct, is there harm in keeping it for the minority of cases where it is correct? I think the answer is yes and Syn doesn't use any equivalent of this helper function. The problems with it are: - Having both `print_expr_maybe_paren` and `print_expr_cond_paren` applies counterproductive inertia against moving from the first to the second. When looking at a call site like `print_expr_maybe_paren(e, Precedence::$Variant, ...)` with parentheses not being inserted where they should be, anyone's first inclination would be to solve the bug by tweaking $Variant because that is the only knob that visibly appears in the function call. For example to pass "prec + 1", like tweaking the code to conditionally pass `Precedence::Prefix` instead of `Precedence::Cast`. Experience in Syn shows this is (almost?) never what you want the person to do. In a call `print_expr_cond_paren(e, e.precedence() < ExprPrecedence::$Variant, ...)` almost always the best fix involves one of: - Changing `e.precedence()`, e.g. to `fixup.leading_precedence(e)` and `fixup.trailing_precedence(e)` in cases of asymmetrical precedence (`(return 1) + 1` vs `1 + return 1`). - Changing `<` to `<=`, to handle associativity and other grammar restrictions like chained comparisons (which rustc gets wrong today). - Adding `||` and/or `&&` clauses to the condition. By using these 3 better knobs instead of $Variant, it upholds the property that any time we talk about precedence, it is always the precedence of some actual expression that our code is actively manipulating, instead of a value standing in for some imaginary precedence level that would exist between two consecutive [real levels](https://doc.rust-lang.org/1.83.0/reference/expressions.html#expression-precedence). For example consider that "`Cast` + 1" might be `Prefix` today, but only until some new Rust syntax ends up adding a level between those. - The `print_expr_maybe_paren` call sites look shorter, but they are not clearer. For myself, a function argument that says "does this subexpression need parenthesization" is a concrete thing that is easy to think about, while a function argument that is "what is the effective precedence level associated with this subexpression's placement inside its parent expression" is abstract and tricky to even state a precise meaning for. I expect that for someone less familiar with the pretty printer working on adding a new expression kind (like postfix match, recently), having every subexpression consistently printed using `print_expr_cond_paren` will be more beneficial, for the same reason, than having `print_expr_maybe_paren` available. r? ``@lcnr``
2024-11-30Rollup merge of #133571 - madsmtm:visionos-support-std, r=NoratriebRalf Jung-2/+2
Mark visionOS as supporting `std` Cargo's -Zbuild-std has recently started checking this field, which causes it to fail to compile even though we have full support for the standard library on these targets. [Example of failed build](https://github.com/rust-random/getrandom/actions/runs/12069033154/job/33655430622). Affected targets: `aarch64-apple-visionos` and `aarch64-apple-visionos-sim`. r? Noratrieb (because you've worked with `rustc` target metadata IIRC) ``@rustbot`` label O-visionos
2024-11-30Rollup merge of #131698 - the8472:remove-set-discriminant-hack, r=RalfJungRalf Jung-8/+61
use stores of the correct size to set discriminants Resolves an old HACK /FIXME. Note that I haven't worked much with codegen so I'm not sure if I'm using the functions correctly and I was surprised seeing out-of-range values being fed into `const_uint_big` but apparently they're wrapped implicitly? By making it explicit we can pass in-range values instead.
2024-11-30use stores of the correct size to set discriminantsThe 8472-8/+16
2024-11-30Auto merge of #133659 - jieyouxu:rollup-576gh4p, r=jieyouxubors-978/+2230
Rollup of 6 pull requests Successful merges: - #131551 (Support input/output in vector registers of PowerPC inline assembly) - #132515 (Fix and undeprecate home_dir()) - #132721 (CI: split x86_64-mingw job) - #133106 (changes old intrinsic declaration to new declaration) - #133496 (thread::available_parallelism for wasm32-wasip1-threads) - #133548 (Add `BTreeSet` entry APIs to match `HashSet`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-30Move refinement check out of compare_impl_itemMichael Goulet-9/+48
2024-11-30Make compare_impl_item into a queryMichael Goulet-228/+84
2024-11-30add tests for niches in pointersThe 8472-0/+45
2024-11-30Auto merge of #133658 - jieyouxu:rollup-rq7e0gk, r=jieyouxubors-255/+580
Rollup of 10 pull requests Successful merges: - #116161 (Stabilize `extended_varargs_abi_support`) - #132750 ([AIX] handle libunwind native_libs) - #133488 (tests: Add regression test for self referential structs with cow as last field) - #133569 (Bump `ruzstd` to 0.7.3) - #133585 (Do not call `extern_crate` on current trait on crate mismatch errors) - #133587 (Fix target_feature handling in freg of LoongArch inline assembly) - #133599 (Add `+forced-atomics` feature to esp32s2 no_std target) - #133620 (Simplify hir_typeck_pass_to_variadic_function) - #133623 (Improve span handling in `parse_expr_bottom`.) - #133625 (custom MIR: add doc comment for debuginfo) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-30Auto merge of #133671 - nikic:revert-cargo-update, r=lqdbors-0/+0
Revert "Auto merge of #133654 - weihanglo:update-cargo, r=weihanglo" This reverts commit 76f3ff605962d7046bc1537597ceed5e12325f54, reversing changes made to 1fc691e6ddc24506b5234d586a5c084eb767f1ad. The new pgo_works test fails when rust is built without profiling support, including in CI on x86_64-gnu-aux. See https://github.com/rust-lang/rust/pull/133499#issuecomment-2508901283 for how this happened.
2024-11-30replace hard coded error id with `ErrorKind::DirectoryNotEmpty`onur-ozkan-3/+1
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-11-30Revert "Auto merge of #133654 - weihanglo:update-cargo, r=weihanglo"Nikita Popov-0/+0
This reverts commit 76f3ff605962d7046bc1537597ceed5e12325f54, reversing changes made to 1fc691e6ddc24506b5234d586a5c084eb767f1ad. The new pgo_works test fails when rust is built without profiling support, including in CI on x86_64-gnu-aux.
2024-11-30bump hashbrown versionRalf Jung-2/+2
2024-11-30Remove unused codeXiaoguang Wang-1/+0
2024-11-30Rollup merge of #133548 - cuviper:btreeset-entry-api, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-2/+530
Add `BTreeSet` entry APIs to match `HashSet` The following methods are added, along with the corresponding `Entry` implementation. ```rust impl<T, A: Allocator + Clone> BTreeSet<T, A> { pub fn get_or_insert(&mut self, value: T) -> &T where T: Ord, {...} pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T where T: Borrow<Q> + Ord, Q: Ord, F: FnOnce(&Q) -> T, {...} pub fn entry(&mut self, value: T) -> Entry<'_, T, A> where T: Ord, {...} } ``` Tracking issue #133549 Closes https://github.com/rust-lang/rfcs/issues/1490
2024-11-30Rollup merge of #133496 - rust-wasi-web:wasi-available-parallelism, r=Amanieu许杰友 Jieyou Xu (Joe)-3/+13
thread::available_parallelism for wasm32-wasip1-threads The target has limited POSIX support and provides the `libc::sysconf` function which allows querying the number of available CPUs.
2024-11-30Rollup merge of #133106 - BLANKatGITHUB:intrinsic, r=RalfJung许杰友 Jieyou Xu (Joe)-596/+950
changes old intrinsic declaration to new declaration This pr is for issue #132735 It changes old `extern "intrinsic"` code block with new declaration. There are other blocks that use old declaration but as the changes needed in single block is quite large I do them in parts
2024-11-30Rollup merge of #132721 - MarcoIeni:mingw-split, r=Kobzol许杰友 Jieyou Xu (Joe)-7/+20
CI: split x86_64-mingw job try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2024-11-30Rollup merge of #132515 - kornelski:home_fix, r=jhpratt许杰友 Jieyou Xu (Joe)-18/+14
Fix and undeprecate home_dir() `home_dir()` has been deprecated for 6 years due to using `HOME` env var on Windows. It's been a long time, and having a perpetually buggy and deprecated function in the standard library is not useful. I propose fixing and undeprecating it. 6 years seems more than long enough to warn users against relying on this function. The change in behavior is minor, and it's more of a bug fix than breakage. The old behavior is unlikely to be useful, and even if anybody actually needed to specifically use the non-standard `HOME` on Windows, they can trivially mitigate this change by reading the env var themselves. ---- Use of `USERPROFILE` is in line with the `home` crate: https://github.com/rust-lang/cargo/blob/37bc5f0232a0bb72dedd2c14149614fd8cdae649/crates/home/src/windows.rs#L12 The `home` crate uses `SHGetKnownFolderPath` instead of `GetUserProfileDirectoryW`. AFAIK it doesn't make any difference in practice, because `SHGetKnownFolderPath` merely adds support for more kinds of folders, including virtual (non-filesystem) folders identified by a GUID, but the specific case of [`FOLDERID_Profile`](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid#FOLDERID_Profile) is documented as a FIXED folder (a regular filesystem path). Just in case, I've added a note to documentation that the use of `GetUserProfileDirectoryW` can change. I've used `CURRENT_RUSTC_VERSION` in a doccomment. `replace-version-placeholder` tool seems to perform a simple string replacement, so hopefully it'll get updated.
2024-11-30Rollup merge of #131551 - taiki-e:ppc-asm-vreg-inout, r=Amanieu许杰友 Jieyou Xu (Joe)-352/+703
Support input/output in vector registers of PowerPC inline assembly This extends currently clobber-only vector registers (`vreg`) support to allow passing `#[repr(simd)]` types as input/output. | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | -------------- | | PowerPC | `vreg` | `altivec` | `i8x16`, `i16x8`, `i32x4`, `f32x4` | | PowerPC | `vreg` | `vsx` | `f32`, `f64`, `i64x2`, `f64x2` | In addition to floats and `core::simd` types listed above, `core::arch` types and custom `#[repr(simd)]` types of the same size and type are also allowed. All allowed types and relevant target features are currently unstable. r? `@Amanieu` `@rustbot` label +O-PowerPC +A-inline-assembly
2024-11-30Rollup merge of #133625 - RalfJung:custom-mir-debug-info, r=compiler-errors许杰友 Jieyou Xu (Joe)-3/+71
custom MIR: add doc comment for debuginfo This is a revival of https://github.com/rust-lang/rust/pull/117015
2024-11-30Rollup merge of #133623 - nnethercote:parse_expr_bottom-spans, r=compiler-errors许杰友 Jieyou Xu (Joe)-21/+14
Improve span handling in `parse_expr_bottom`. `parse_expr_bottom` stores `this.token.span` in `lo`, but then fails to use it in many places where it could. This commit fixes that, and likewise (to a smaller extent) in `parse_ty_common`. r? ``@spastorino``
2024-11-30Rollup merge of #133620 - ↵许杰友 Jieyou Xu (Joe)-27/+69
dev-ardi:simplify-hir_typeck_pass_to_variadic_function, r=compiler-errors Simplify hir_typeck_pass_to_variadic_function r? ``@compiler-errors`` This reworks a bit how the diagnostic is generated so that it does the same as #133538 The `help` is useless now so I removed it
2024-11-30Rollup merge of #133599 - esp-rs:target/esp32s2-forced-atomics, r=Amanieu许杰友 Jieyou Xu (Joe)-0/+1
Add `+forced-atomics` feature to esp32s2 no_std target Similar to https://github.com/rust-lang/rust/pull/114499 but for the Xtensa backend. The ESP32-S2 doesn't have native atomic support, but can have atomic load/stores as part of the ISA with this LLVM codegen feature. Note: The current rev of LLVM that rustc is using doesn't contain the `+forced-atomics` feature for Xtensa, but I'm pushing this now to remove the patch from our fork in `esp-rs/rust`. r? ``@Amanieu`` because you reviewed the related RISC-V PR
2024-11-30Rollup merge of #133587 - taiki-e:loongarch-asm-freg, r=Amanieu许杰友 Jieyou Xu (Joe)-1/+146
Fix target_feature handling in freg of LoongArch inline assembly In LoongArch inline assembly, freg currently always accepts f32/f64 as input/output. https://github.com/rust-lang/rust/blob/9b4d7c6a40b328d212095c28670c629facf1557d/compiler/rustc_target/src/asm/loongarch.rs#L41 However, these types actually require f/d target features as in RISC-V. Otherwise, an (ugly) compile error will occur: https://godbolt.org/z/K61Gq1E9E f32/f64 without f: ``` error: couldn't allocate output register for constraint '{$f1}' --> <source>:12:11 | 12 | asm!("", in("$f1") x, lateout("$f1") y); | ^ ``` f64 with f but without d: ``` error: scalar-to-vector conversion failed, possible invalid constraint for vector type --> <source>:19:11 | 19 | asm!("", in("$f1") x, lateout("$f1") y); | ^ ``` cc ``@heiher`` r? ``@Amanieu`` ``@rustbot`` label +O-LoongArch +A-inline-assembly
2024-11-30Rollup merge of #133585 - estebank:issue-133563, r=jieyouxu许杰友 Jieyou Xu (Joe)-76/+241
Do not call `extern_crate` on current trait on crate mismatch errors When we encounter an error caused by traits/types of different versions of the same crate, filter out the current crate when collecting spans to add to the context so we don't call `extern_crate` on the `DefId` of the current crate, which is meaningless and ICEs. Produced output with this filter: ``` error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied --> y.rs:13:19 | 13 | check_trait::<foo::Struct>(); | ^^^^^^^^^^^ the trait `Trait` is not implemented for `foo::Struct` | note: there are multiple different versions of crate `foo` in the dependency graph --> y.rs:7:1 | 4 | extern crate foo; | ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate 5 | 6 | pub struct Struct; | ----------------- this type implements the required trait 7 | pub trait Trait {} | ^^^^^^^^^^^^^^^ this is the required trait | ::: x.rs:4:1 | 4 | pub struct Struct; | ----------------- this type doesn't implement the required trait 5 | pub trait Trait {} | --------------- this is the found trait = note: two types coming from two different versions of the same crate are different types even if they look the same = help: you can use `cargo tree` to explore your dependency tree note: required by a bound in `check_trait` --> y.rs:10:19 | 10 | fn check_trait<T: Trait>() {} | ^^^^^ required by this bound in `check_trait` ``` Fix #133563.
2024-11-30Rollup merge of #133569 - paolobarbolini:ruzstd-0.7.3, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-2/+2
Bump `ruzstd` to 0.7.3 This upgrades `ruzstd` to a version not affected by [RUSTSEC-2024-0400](https://rustsec.org/advisories/RUSTSEC-2024-0400.html)
2024-11-30Rollup merge of #133488 - Enselic:recurse-2, r=BoxyUwU许杰友 Jieyou Xu (Joe)-0/+19
tests: Add regression test for self referential structs with cow as last field Making compilation pass for this code was retroactively stabilized via FCP in 1.79. The code does not compile in 1.78. See https://github.com/rust-lang/rust/issues/129541 for details. Closes #107481
2024-11-30Rollup merge of #132750 - daltenty:daltenty/libs, r=jieyouxu许杰友 Jieyou Xu (Joe)-1/+5
[AIX] handle libunwind native_libs AIX should follow a similar path here to other libunwind platforms, with regards to system vs in-tree libunwind and the native lib search directories. Having the right native lib search directories here is also required to get the correct default library search paths, due to some quirks of the AIX linker.
2024-11-30Rollup merge of #116161 - Soveu:varargs2, r=cjgillot许杰友 Jieyou Xu (Joe)-124/+12
Stabilize `extended_varargs_abi_support` I think that is everything? If there is any documentation regarding `extern` and/or varargs to correct, let me know, some quick greps suggest that there might be none. Tracking issue: https://github.com/rust-lang/rust/issues/100189
2024-11-30Auto merge of #133654 - weihanglo:update-cargo, r=weihanglobors-0/+0
Update cargo 8 commits in 4c39aaff66862cc0da52fe529aa1990bb8bb9a22..3908f64086a3d7b9af8d87b4da2bd100776c3e61 2024-11-25 16:36:17 +0000 to 2024-11-29 17:32:44 +0000 - chore(deps): update msrv (rust-lang/cargo#14867) - fix(fix): Migrate cargo script manifests across editions (rust-lang/cargo#14864) - feat(toml): Allow adding/removing from cargo scripts (rust-lang/cargo#14857) - Add future-incompat warning against keywords in cfgs and add raw-idents (rust-lang/cargo#14671) - test(build-std): download deps first (rust-lang/cargo#14861) - test(pgo): ensure PGO works (rust-lang/cargo#14859) - git-fetch-with-cli: Set `GIT_DIR` for bare repository compatibility (rust-lang/cargo#14860) - fix(build-std): always link to std when testing proc-macros (rust-lang/cargo#14850)
2024-11-29Eliminate rustc_hir_pretty's print_expr_maybe_parenDavid Tolnay-21/+17
2024-11-29Eliminate rustc_ast_pretty's print_expr_maybe_parenDavid Tolnay-31/+87
2024-11-29Update cargoWeihang Lo-0/+0
2024-11-29Auto merge of #133533 - BoxyUwU:bump-boostrap, r=jieyouxu,Mark-Simulacrumbors-924/+675
Bump boostrap compiler to new beta Currently failing due to something about the const stability checks and `panic!`. I'm not sure why though since I wasn't able to see any PRs merged in the past few days that would result in a `cfg(bootstrap)` that shouldn't be removed. cc `@RalfJung` #131349
2024-11-29Add a commentDavid Tenty-0/+3
2024-11-29Cargo patchBoxy-2/+9
2024-11-29Auto merge of #133588 - flip1995:clippy-subtree-update, r=Manishearthbors-652/+1965
Clippy subtree update r? `@Manishearth`
2024-11-29simplify how the `hir_typeck_pass_to_variadic_function` diagnostic is createdOrion Gonzalez-27/+69
2024-11-29Move the `crate-loading` test to use `diff` outputEsteban Küber-76/+152
2024-11-29Use rmake `diff` output in testEsteban Küber-13/+46
2024-11-29Fix tests that rely on LLVM IR verificationNikita Popov-10/+2
Pass -Z verify-llvm-ir to tests that rely on it, to make sure they pass regardless of the value of verify-llvm-ir in config.toml. Also remove the 109681.rs test, because it is a duplicat of common-linkage-non-zero-init.rs.
2024-11-29Auto merge of #133634 - matthiaskrgr:rollup-v7m4j2k, r=matthiaskrgrbors-212/+281
Rollup of 7 pull requests Successful merges: - #131323 (Support `clobber_abi` in AVR inline assembly) - #131718 ([rustdoc] Change impl items indent) - #133565 (chore: fix 404 status URL) - #133575 (Fix typo in RELEASES.md) - #133577 (Document s390x machine access via community cloud) - #133584 (Update more 2024 tests to remove -Zunstable-options) - #133592 (Misc: better instructions for envrc, ignore `/build` instead of `build/`) r? `@ghost` `@rustbot` modify labels: rollup