summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-11-21Enforce that raw lifetime identifiers must be valid raw identifiersMichael Goulet-4/+20
(cherry picked from commit 9785c7cf94f5e30742f886764f2d25b6a4da66e8)
2024-11-14Only disable cache if predicate has opaques within itMichael Goulet-21/+45
(cherry picked from commit 49153739fd01d82ed999c763fd2771cb837d7dd2)
2024-11-14Reject raw lifetime followed by \' as wellMichael Goulet-1/+11
(cherry picked from commit 1990f1560801ca3f9e6a3286e58204aa329ee037)
2024-11-07Revert "Avoid nested replacement ranges" from #129346.Nicholas Nethercote-7/+21
It caused a test regression in the `cfg_eval.rs` crate. (The bugfix in #129346 was in a different commit; this commit was just a code simplification.) (cherry picked from commit 981dc02eaf876a25b95581411e841ba664dc9e97)
2024-11-07Also treat `impl` definition parent as transparent regarding modulesUrgau-2/+8
(cherry picked from commit 37db36594838d85f72e2282e73707071e80e31c0)
2024-11-01Mark `simplify_aggregate_to_copy` mir-opt as unsound许杰友 Jieyou Xu (Joe)-1/+3
Co-authored-by: DianQK <dianqk@dianqk.net> (cherry picked from commit 10b8ba4ecb19ac2eb7be97a1a1eb1ffae9fec534)
2024-10-17Also use outermost const-anon for impl items in `non_local_defs` lintUrgau-3/+7
(cherry picked from commit b5e91a00c89a065f618693873ad7074a13ad6b90)
2024-10-14replace placeholder versionJosh Stone-14/+14
2024-10-13Rollup merge of #131086 - printfn:update-unicode-width, r=Mark-SimulacrumMatthias Krüger-2/+2
Update unicode-width to 0.2.0 I updated the [`unicode-width`](https://github.com/unicode-rs/unicode-width) dependency to 0.2.0. See the changelog [here](https://github.com/unicode-rs/unicode-width?tab=readme-ov-file#changelog). None of the changes seem to affect rustc.
2024-10-12Rollup merge of #131626 - matthiaskrgr:dont_string, r=lqdTrevor Gross-4/+4
remove a couple of redundant String to String conversion
2024-10-12Rollup merge of #131334 - heiher:loong-sanitizers, r=Mark-SimulacrumTrevor Gross-3/+18
Enable sanitizers for loongarch64-unknown-* Enable sanitizers for `loongarch64-unknown-linux-{gnu,musl,ohos}` targets.
2024-10-12Rollup merge of #131120 - tgross35:stabilize-const_option, r=RalfJungTrevor Gross-2/+0
Stabilize `const_option` This makes the following API stable in const contexts: ```rust impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } ``` The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <https://github.com/rust-lang/rust/issues/67441>
2024-10-12Update unicode-width to 0.2.0printfn-2/+2
2024-10-12Stabilize `const_option`Trevor Gross-2/+0
This makes the following API stable in const contexts: impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <https://github.com/rust-lang/rust/issues/67441>
2024-10-12Rollup merge of #131599 - compiler-errors:storage, r=lcnrMatthias Krüger-43/+42
Shallowly match opaque key in storage Using a full eq on the key *and* the hidden type means that in cases where we first ambiguously register a `?t` hidden type then constrain that `?t` to be a type that doesn't actually satisfy its bounds, we end up with bogus entries in the opaque type storage. We should commit to the type in the storage if it's registered. r? lcnr
2024-10-12Rollup merge of #131567 - ↵Matthias Krüger-0/+33
CastilloDel:reject-unstable-with-accepted-features, r=jieyouxu Emit an error for unstable attributes that reference already stable features Closes https://github.com/rust-lang/rust/issues/129814
2024-10-12Rollup merge of #131277 - ↵Matthias Krüger-1/+2
ismailarilik:handle-potential-query-instability-lint-for-clippy, r=xFrednet Handle `clippy` cases of `rustc::potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`src/tools/clippy/clippy_lints/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/src/tools/clippy/clippy_lints/src/lib.rs#L30) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447
2024-10-12Rollup merge of #131239 - VulnBandit:trait-vulnerability, r=lcnrMatthias Krüger-35/+37
Don't assume traits used as type are trait objs in 2021 edition Fixes #127548 When you use a trait as a type, the compiler automatically assumes you meant to use a trait object, which is not always the case. This PR fixes the bug where you don't need a trait object, so the error message was changed to: ``` error[E0782]: expected a type, found a trait ``` Also fixes some ICEs: Fixes https://github.com/rust-lang/rust/issues/120241 Fixes https://github.com/rust-lang/rust/issues/120482 Fixes https://github.com/rust-lang/rust/issues/125512
2024-10-12Rollup merge of #128784 - tdittr:check-abi-on-fn-ptr, r=compiler-errorsMatthias Krüger-15/+82
Check ABI target compatibility for function pointers Tracking issue: https://github.com/rust-lang/rust/issues/130260 Related tracking issue: #87678 Compatibility of an ABI for a target was previously only performed on function definitions and `extern` blocks. This PR adds it also to function pointers to be consistent. This might have broken some of the `tests/ui/` depending on the platform, so a try run seems like a good idea. Also this might break existing code, because we now emit extra errors. Does this require a crater run? # Example ```rust // build with: --target=x86_64-unknown-linux-gnu // These raise E0570 extern "thiscall" fn foo() {} extern "thiscall" { fn bar() } // This did not raise any error fn baz(f: extern "thiscall" fn()) { f() } ``` # Open Questions * [x] Should this report a future incompatibility warning like #87678 ? * [ ] Is this the best place to perform the check?
2024-10-12remove a couple of redundant String to String conversionMatthias Krüger-4/+4
2024-10-12Rollup merge of #131605 - DianQK:llvm-const-int, r=the8472Trevor Gross-0/+13
`LLVMConstInt` only allows integer types See https://github.com/llvm/llvm-project/blob/llvmorg-19.1.1/llvm/lib/IR/Core.cpp#L1535-L1546. r? the8472
2024-10-12Rollup merge of #131596 - RalfJung:interp-result-must-use, r=jieyouxuTrevor Gross-0/+1
mark InterpResult as must_use This was forgotten in https://github.com/rust-lang/rust/pull/130885
2024-10-12Rollup merge of #131590 - matthiaskrgr:clones3, r=compiler-errorsTrevor Gross-2/+2
yeet some clones
2024-10-12Rollup merge of #130870 - surechen:fix_130791, r=compiler-errorsTrevor Gross-0/+18
Add suggestion for removing invalid path sep `::` in fn def Add suggestion for removing invalid path separator `::` in function definition. for example: `fn invalid_path_separator::<T>() {}` fixes #130791
2024-10-12`LLVMConstInt` only allows integer typesDianQK-0/+13
2024-10-12Shallowly match opaque key in storageMichael Goulet-43/+42
2024-10-12mark InterpResult as must_useRalf Jung-0/+1
2024-10-12yeet some clonesMatthias Krüger-2/+2
2024-10-12Emit an error for unstable attributes that reference already stable featuresCastilloDel-0/+33
Add missing error annotations and .stderr file Acknowledge comments
2024-10-11Rollup merge of #131565 - Urgau:non_local_def-rm-deprecate, r=compiler-errorsTrevor Gross-5/+0
Remove deprecation note in the `non_local_definitions` lint This PR removes the edition deprecation note emitted by the `non_local_definitions` lint. Specifically this part: ``` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363> ``` because it [didn't make the cut](https://github.com/rust-lang/rust/issues/120363#issuecomment-2407833300) for the 2024 edition. `@rustbot` label +L-non_local_definitions
2024-10-11Rollup merge of #131546 - surechen:fix_129833, r=jieyouxuTrevor Gross-1/+9
Make unused_parens's suggestion considering expr's attributes. For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`, the suggestion's span should contains the attributes, or the suggestion will remove them. fixes #129833
2024-10-11Rollup merge of #131310 - taiki-e:msp430-clobber-abi, r=AmanieuTrevor Gross-0/+10
Support clobber_abi in MSP430 inline assembly This supports `clobber_abi` which is one of the requirements of stabilization mentioned in #93335. Refs: Section 3.2 "Register Conventions" in [MSP430 Embedded Application Binary Interface](https://www.ti.com/lit/an/slaa534a/slaa534a.pdf) cc ``@cr1901`` r? ``@Amanieu`` ``@rustbot`` label +O-msp430
2024-10-11Rollup merge of #124874 - jedbrown:float-mul-add-fast, r=saethlinTrevor Gross-1/+34
intrinsics fmuladdf{32,64}: expose llvm.fmuladd.* semantics Add intrinsics `fmuladd{f32,f64}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc). --- This topic has been discussed a few times on Zulip and was suggested, for example, by `@workingjubilee` in [Effect of fma disabled](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Effect.20of.20fma.20disabled/near/274179331).
2024-10-12Make unused_parens's suggestion considering expr's attributessurechen-1/+9
For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`, the suggestion's span should contains the attributes, or the suggestion will remove them. fixes #129833
2024-10-11Rollup merge of #131552 - durin42:llvm-20-getOrInsertDeclaration, r=cuviperTrevor Gross-6/+19
RustWrapper: adapt for rename of Intrinsic::getDeclaration llvm/llvm-project@fa789dffb1e12c2aece0187aeacc48dfb1768340 renamed getDeclaration to getOrInsertDeclaration. `@rustbot` label: +llvm-main
2024-10-11Rollup merge of #131543 - Zalathar:goodbye-llvm-17, r=petrochenkovTrevor Gross-16/+7
coverage: Remove code related to LLVM 17 In-tree LLVM is 19, and the minimum external LLVM was increased to 18 in #130487.
2024-10-11intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semanticsJed Brown-1/+34
Add intrinsics `fmuladd{f16,f32,f64,f128}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic MIRI support is included for f32 and f64. The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc).
2024-10-11Remove deprecation note in the `non_local_definitions` warningUrgau-5/+0
2024-10-11RustWrapper: adapt for rename of Intrinsic::getDeclarationAugie Fackler-6/+19
llvm/llvm-project@fa789dffb1e12c2aece0187aeacc48dfb1768340 renamed getDeclaration to getOrInsertDeclaration. @rustbot label: +llvm-main
2024-10-11Auto merge of #131547 - matthiaskrgr:rollup-ui4p744, r=matthiaskrgrbors-23/+29
Rollup of 6 pull requests Successful merges: - #129079 (Create `_imp__` symbols also when doing ThinLTO) - #131208 (ABI: Pass aggregates by value on AIX) - #131394 (fix(rustdoc): add space between struct fields and their descriptions) - #131519 (Use Default visibility for rustc-generated C symbol declarations) - #131541 (compiletest: Extract auxiliary-crate properties to their own module/struct) - #131542 (next-solver: remove outdated FIXMEs) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-11Don't assume traits used as type are trait objsVulnBandit-35/+37
2024-10-11Rollup merge of #131542 - lcnr:new-solver-fixmes, r=compiler-errorsMatthias Krüger-15/+6
next-solver: remove outdated FIXMEs r? `@compiler-errors`
2024-10-11Rollup merge of #131519 - davidlattimore:intrinsics-default-vis, r=UrgauMatthias Krüger-4/+3
Use Default visibility for rustc-generated C symbol declarations Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail. This is based on https://github.com/rust-lang/rust/pull/123994. Issue https://github.com/rust-lang/rust/issues/123427 When I changed `default-hidden-visibility` to `default-visibility` in https://github.com/rust-lang/rust/pull/130005, I updated all places in the code that used `default-hidden-visibility`, replicating the hidden-visibility bug to also happen for protected visibility. Without this change, trying to build rustc with `-Z default-visibility=protected` fails with a link error.
2024-10-11Rollup merge of #131208 - mustartt:aix-call-abi, r=davidtwcoMatthias Krüger-3/+13
ABI: Pass aggregates by value on AIX On AIX we pass aggregates byval. Adds new ABI for AIX for powerpc64. https://github.com/llvm/llvm-project/blob/313ad85dfa40a18f2edefd7ce2edc0528d5a554a/clang/lib/CodeGen/Targets/PPC.cpp#L216 Fixes the following 2 testcases on AIX: ``` tests/ui/abi/extern/extern-pass-TwoU16s.rs tests/ui/abi/extern/extern-pass-TwoU8s.rs ```
2024-10-11Rollup merge of #129079 - Zoxc:thinlto_imp_symbols, r=wesleywiserMatthias Krüger-1/+7
Create `_imp__` symbols also when doing ThinLTO When generating a rlib crate on Windows we create `dllimport` / `_imp__` symbols for each global. This effectively makes the rlib contain an import library for itself and allows them to both be dynamically and statically linked. However when doing ThinLTO we do not generate these and thus we end up with missing symbols. Microsoft's `link` can fix these up (and emits warnings), but `lld` seems to currently be unable to. This PR also does this generation for ThinLTO avoiding those issues with `lld` and also avoids the warnings on `link`. This is an workaround for https://github.com/rust-lang/rust/issues/81408. cc `@lqd`
2024-10-11Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiserbors-605/+32
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * https://github.com/rust-lang/rust/issues/49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-11coverage: Remove code related to LLVM 17Zalathar-16/+7
2024-10-11remove outdated FIXMEslcnr-15/+6
2024-10-11Rollup merge of #131498 - Urgau:transparent-const-anons, r=lcnrMatthias Krüger-31/+59
Consider outermost const-anon in `non_local_def` lint This PR change the logic for finding the parent of the `impl` definition in the `non_local_definitions` lint to consider multiple level of const-anon items, instead of only one currently. I also took the opportunity to cleanup the related code. cc ``@traviscross`` Fixes https://github.com/rust-lang/rust/issues/131474
2024-10-11Consider outermost const-anon in non_local_def lintUrgau-31/+59