about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-11-03Rollup merge of #132521 - klensy:times, r=compiler-errorsJubilee-16/+10
replace manual time convertions with std ones, comptime time format parsing First commit replaces few manual time conversions with std ones, second makes parsing of time format at compiletime.
2024-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-28/+20
2024-11-03Yeet effects featureMichael Goulet-2/+3
2024-11-03Gate checking ~const bounds on const_trait_implMichael Goulet-10/+4
2024-11-03Auto merge of #132555 - matthiaskrgr:rollup-2d79661, r=matthiaskrgrbors-39/+47
Rollup of 15 pull requests Successful merges: - #129329 (Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`) - #131377 (Add LowerExp and UpperExp implementations to NonZero) - #132393 (Docs: added brief colon explanation) - #132437 (coverage: Regression test for inlining into an uninstrumented crate) - #132499 (unicode_data.rs: show command for generating file) - #132503 (better test for const HashMap; remove const_hash leftovers) - #132511 (stabilize const_arguments_as_str) - #132520 (NFC add known bug nr to test) - #132522 (make codegen help output more consistent) - #132523 (Added regression test for generics index out of bounds) - #132528 (Use `*_opt` typeck results fns to not ICE in fallback suggestion) - #132537 (PassWrapper: adapt for llvm/llvm-project@5445edb5d) - #132540 (Do not format generic consts) - #132543 (add and update some crashtests) - #132550 (compiler: Continue introducing rustc_abi to the compiler) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-03make time format parsing compiletimeklensy-3/+3
2024-11-03replace manual time convertions with std onesklensy-13/+7
2024-11-03Auto merge of #132514 - Zalathar:print-target-cpus, r=jieyouxubors-90/+92
Port most of `--print=target-cpus` to Rust The logic and formatting needed by `--print=target-cpus` has historically been carried out in C++ code. Originally it used `printf` to write directly to the console, but later it switched over to writing to a `std::ostringstream` and then passing its buffer to a callback function pointer. This PR replaces that C++ code with a very simple function that writes a list of CPU names to a `&RustString`, with the rest of the logic and formatting being handled by ordinary safe Rust code.
2024-11-03Rollup merge of #132550 - ↵Matthias Krüger-28/+30
workingjubilee:rustc-abi-selects-borrowck-for-mono-sans, r=compiler-errors compiler: Continue introducing rustc_abi to the compiler Some crates have not heard of rustc_abi before, so arrange introductions. Encourage some crates to go further and leave rustc_target behind: it was no good for them.
2024-11-03Rollup merge of #132540 - compiler-errors:gc, r=calebcartwrightMatthias Krüger-0/+6
Do not format generic consts We introduced **nightly support** for generic const items in #113522, but formatting of consts was not modified. Making them format *correctly* is hard, so let's just bail formatting them so we don't accidentally strip their generics and where clauses. This is essentially no-op formatting for generic const items. r? `````@calebcartwright````` or `````@ytmimi`````
2024-11-03Rollup merge of #132537 - durin42:llvm-20-prelinklto, r=DianQKMatthias Krüger-7/+6
PassWrapper: adapt for llvm/llvm-project@5445edb5d As with ab5583ed1e75869b765a90386dac9119992f8ed7, we had been explicitly passing defaults whose type have changed. Rather than do an ifdef, we simply rely on the defaults. ````@rustbot```` label: +llvm-main
2024-11-03Rollup merge of #132528 - compiler-errors:fallback-sugg-opt, r=jieyouxuMatthias Krüger-3/+4
Use `*_opt` typeck results fns to not ICE in fallback suggestion Self-explanatory. Fixes #132517.
2024-11-03Rollup merge of #132522 - senekor:consistenst-codegen-help, r=compiler-errorsMatthias Krüger-1/+1
make codegen help output more consistent The output of `rustc -C help` generally has one option per line. There was one exception because of a (presumably) forgotten line continuation escape.
2024-11-03Auto merge of #132419 - durin42:llvm-20-type-test-thing, r=cuviperbors-3/+3
PassWrapper: adapt for llvm/llvm-project@b01e2a8b5620466c3b A boolean turned into an enum. None matches the old behavior of false, so we pass that. `@rustbot` label: +llvm-main
2024-11-03Auto merge of #132526 - bjorn3:sync_cg_clif-2024-11-02, r=bjorn3bors-264/+165
Subtree sync for rustc_codegen_cranelift The highlight this time is an update to Cranelift 0.113, r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-11-02compiler: Add rustc_abi to _sanitizersJubilee Young-6/+6
2024-11-02compiler: Add rustc_abi to _monomorphizeJubilee Young-1/+2
2024-11-02compiler: Replace rustc_target with _abi in _trait_selectionJubilee Young-9/+9
2024-11-02compiler: Replace rustc_target with _abi in _hirJubilee Young-5/+6
2024-11-02compiler: Replace rustc_target with _abi in _borrowckJubilee Young-7/+7
2024-11-02Auto merge of #125579 - Noratrieb:print-host, r=davidtwcobors-142/+144
Add `--print host-tuple` to print host target tuple People often parse `-vV` output to get to the host tuple, which is annoying to do. It's easier to just get it directly. I called it "host-tuple" instead of "host" because it's clearer that it's just the target name. I'm open to different names, but I think this one is fine. a quick GitHub search for `'^host` reveals many instances of people doing the parsing, for example: https://github.com/japaric/xargo/blob/68e0ca57cd90837fe02f262f074182f9cfeb6227/README.md?plain=1#L369 https://github.com/taiki-e/setup-cross-toolchain-action/blob/0e38473b0c562d6db19a98d3ec20a80f7ac189ae/main.sh#L96 https://github.com/taiki-e/cargo-llvm-cov/blob/8a3553b86551eabf9c30c060b1f72a5bbccb98c6/README.md?plain=1#L625 https://github.com/SiliconLabs/cpc-nvm3/blob/43f3ec39709b30700ef7f39d91fa647974323bf1/do.sh#L35 needs a compiler FCP. I could also do an MCP but I think just an FCP here makes the most sense.
2024-11-02Add `--print host-triple`Noratrieb-0/+3
People often parse `-vV` output to get to the host triple, which is annoying to do. It's easier to just get it directly.
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-142/+141
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-11-02Do not format generic constsMichael Goulet-0/+6
2024-11-02Auto merge of #132147 - estebank:long-types-2, r=davidtwcobors-30/+195
Tweak E0277 output when a candidate is available *Follow up to #132086.* Go from ``` error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied --> src/main.rs:7:50 | 7 | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> { | ^^^^^^^^^^^^^^^^^^^^^^ the trait `chumsky::private::ParserSealed<'_, &str, (), chumsky::extra::Full<EmptyErr, (), ()>>` is not implemented for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>`, which is required by `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` | = help: the trait `chumsky::private::ParserSealed<'_, &'a str, ((), ()), chumsky::extra::Full<EmptyErr, (), ()>>` is implemented for `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>` = help: for that trait implementation, expected `((), ())`, found `()` = note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>` note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>` --> src/main.rs:5:16 | 5 | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {} | ^^^^^^^^^^^^^^^^ ^ ---------------------- unsatisfied trait bound introduced here = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt' = note: consider using `--verbose` to print the full type name to the console = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt' = note: consider using `--verbose` to print the full type name to the console ``` to ``` error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied --> src/main.rs:7:50 | 7 | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> { | ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound ... 11 | ws.then(parser.map(|_| ())) | --------------------------- return type was inferred to be `Then<Ignored<..., ...>, ..., ..., ..., ...>` here | = help: the trait `ParserSealed<'_, &_, (), Full<_, _, _>>` is not implemented for `Then<Ignored<..., ...>, ..., ..., ..., ...>` but trait `ParserSealed<'_, &'a _, ((), ()), Full<_, _, _>>` is implemented for it = help: for that trait implementation, expected `((), ())`, found `()` = note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>` note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>` --> src/main.rs:5:16 | 5 | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {} | ^^^^^^^^^^^^^^^^ ^ ---------------------- unsatisfied trait bound introduced here = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-df9d52be87eada65.long-type-1337037744507305372.txt' = note: consider using `--verbose` to print the full type name to the console ``` * Remove redundant wording * Introduce trait diff highlighting logic and use it * Fix incorrect "long type written to path" logic (can be split off) * Point at tail expression in more cases in E0277 * Avoid long primary span labels in E0277 by moving them to a `help` Fix #132013. There are individual commits that can be their own PR. If the review load is too big, happy to split them off.
2024-11-02PassWrapper: adapt for llvm/llvm-project@5445edb5dAugie Fackler-7/+6
As with ab5583ed1e75869b765a90386dac9119992f8ed7, we had been explicitly passing defaults whose type have changed. Rather than do an ifdef, we simply rely on the defaults. @rustbot label: +llvm-main
2024-11-02PassWrapper: adapt for ↵Augie Fackler-3/+3
llvm/llvm-project@b01e2a8b5620466c3b80cc6f049efbc90b9d103a We don't see a reason to explicitly pass the default here, so just use the default instead of explicitly passing it and needing an ifdef. @rustbot label: +llvm-main
2024-11-02Use opt functions to not ICE in fallback suggestionMichael Goulet-3/+4
2024-11-02Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into ↵bjorn3-264/+165
sync_cg_clif-2024-11-02
2024-11-02Port most of `LLVMRustPrintTargetCPUs` to RustZalathar-76/+70
2024-11-02Use a dedicated safe wrapper for `LLVMRustGetHostCPUName`Zalathar-15/+23
2024-11-02make codegen help output more consistentRemo Senekowitsch-1/+1
The output of `rustc -C help` generally has one option per line. There was one exception because of a (presumably) forgotten line continuation escape.
2024-11-02Rollup merge of #132488 - compiler-errors:more-fixmes-bye, r=jieyouxuMatthias Krüger-1/+0
Remove or fix some more `FIXME(async_closure)` Self-explanatory
2024-11-02Rollup merge of #132466 - cjgillot:opaque-late, r=compiler-errorsMatthias Krüger-3/+20
Account for late-bound depth when capturing all opaque lifetimes. Fixes https://github.com/rust-lang/rust/issues/132429 r? ````@compiler-errors````
2024-11-02Rollup merge of #132453 - Urgau:non_local_defs-impl-mod-transparent, r=jieyouxuMatthias Krüger-2/+8
Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. ``````@rustbot`````` label +L-non_local_definitions Fixes *(after beta-backport)* #132427 cc ``````@leighmcculloch`````` r? ``````@jieyouxu``````
2024-11-02Rollup merge of #131037 - madsmtm:move-llvm-target-versioning, r=petrochenkovMatthias Krüger-165/+271
Move versioned Apple LLVM targets from `rustc_target` to `rustc_codegen_ssa` Fully specified LLVM targets contain the OS version on macOS/iOS/tvOS/watchOS/visionOS, and this version depends on the deployment target environment variables like `MACOSX_DEPLOYMENT_TARGET`, `IPHONEOS_DEPLOYMENT_TARGET` etc. We would like to move this to later in the compilation pipeline, both because it feels impure to access environment variables when fetching target information, but mostly because we need access to more information from https://github.com/rust-lang/rust/pull/130883 to do https://github.com/rust-lang/rust/issues/118204. See also https://github.com/rust-lang/rust/pull/129342#issuecomment-2335156119 for some discussion. The first and second commit does the actual refactor, it should be a non-functional change, the third commit adds diagnostics for invalid deployment targets, which are now possible to do because we have access to the session. Tested with the same commands as in https://github.com/rust-lang/rust/pull/130435. r? ``````@petrochenkov``````
2024-11-02Remove or fix some FIXME(async_closure)Michael Goulet-1/+0
2024-11-02Account for negative bounds in E0277 note and suggestionEsteban Küber-1/+8
Do not suggest `#[derive(Copy)]` when we wanted a `!Copy` type. Do not say "`Copy` is not implemented for `T` but `Copy` is". Do not talk about `Trait` having no implementations when `!Trait` was desired.
2024-11-02On long E0277 primary span label, move it to a `help`Esteban Küber-0/+5
Long span labels don't read well.
2024-11-02Point at tail expression on rpit E0277Esteban Küber-11/+28
``` error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}: Coroutine` is not satisfied --> $DIR/gen_block_is_coro.rs:6:13 | LL | fn foo() -> impl Coroutine<Yield = u32, Return = ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}` LL | gen { yield 42 } | ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}` here ``` The secondary span label is new.
2024-11-02Use `short_ty_string`Esteban Küber-1/+3
2024-11-02Fix type shortening writing to fileEsteban Küber-3/+18
Make sure that we append to the file for long ty paths. Do not write the same type more than once. Shorten the calculated width a bit.
2024-11-02Trim output of E0277 in some casesEsteban Küber-2/+18
Remove default note for "trait is not implemented" in favor of the more colorful diff output from the previous commit. Removes duplicated output.
2024-11-02Add trait diff highlighting logic and use it in E0277Esteban Küber-13/+116
When a trait is not implemented for a type, but there *is* an `impl` for another type or different trait params, we format the output to use highlighting in the same way that E0308 does for types. The logic accounts for 3 cases: - When both the type and trait in the expected predicate and the candidate are different - When only the types are different - When only the trait generic params are different For each case, we use slightly different formatting and wording.
2024-11-01Auto merge of #132470 - GuillaumeGomez:rollup-1a1mkmp, r=GuillaumeGomezbors-144/+319
Rollup of 14 pull requests Successful merges: - #131829 (Remove support for `-Zprofile` (gcov-style coverage instrumentation)) - #132369 (style-guide: Only use the new binop heuristic for assignments) - #132383 (Implement suggestion for never type fallback lints) - #132413 (update offset_of! docs to reflect the stabilization of nesting) - #132438 (Remove unncessary option for default rust-analyzer setting) - #132439 (Add `f16` and `f128` to `invalid_nan_comparison`) - #132444 (rustdoc: Directly use rustc_abi instead of reexports) - #132445 (Cleanup attributes around unchecked shifts and unchecked negation in const) - #132448 (Add missing backtick) - #132450 (Show actual MIR when MIR building forgot to terminate block) - #132451 (remove some unnecessary rustc_allow_const_fn_unstable) - #132455 (make const_alloc_layout feature gate only about functions that are already stable) - #132456 (Move remaining inline assembly test files into asm directory) - #132459 (feat(byte_sub_ptr): unstably add ptr::byte_sub_ptr) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-02Rollup merge of #132450 - bjorn3:better_mir_errors, r=jieyouxuGuillaume Gomez-28/+41
Show actual MIR when MIR building forgot to terminate block This makes it significantly easier to debug bugs of this kind.
2024-11-02Rollup merge of #132439 - tgross35:f16-f128-nan-lint, r=jieyouxuGuillaume Gomez-1/+4
Add `f16` and `f128` to `invalid_nan_comparison` Currently `f32_nan` and `f64_nan` are used to provide the `invalid_nan_comparison` lint. Since we have `f16_nan` and `f128_nan`, hook these up so the new float types get the same lints.
2024-11-02Rollup merge of #132383 - compiler-errors:never-type-fallback-sugg, ↵Guillaume Gomez-24/+266
r=WaffleLapkin Implement suggestion for never type fallback lints r? ```@WaffleLapkin``` Just opening this up for vibes; it's not done yet. I'd still like to make this suggestable in a few more cases before merge: - [x] Try to annotate `_` -> `()` - [x] Try to annotate local variables if they're un-annotated: `let x = ...` -> `let x: () = ...` - [x] Try to annotate the self type of a `Trait::method()` -> `<() as Trait>::method()`. The only other case we may want to suggest is a missing turbofish, like `f()` -> `f::<()>()`. That may be possible, but seems overly annoying. This partly addresses https://github.com/rust-lang/rust/issues/132358; the other half of fixing that would be to make the error message a bit better, perhaps just special casing the `?` operator 🤔 I don't think I'll do that part.
2024-11-02Rollup merge of #131829 - Zalathar:goodbye-zprofile, r=chenyukangGuillaume Gomez-91/+8
Remove support for `-Zprofile` (gcov-style coverage instrumentation) Tracking issue: #42524 MCP: https://github.com/rust-lang/compiler-team/issues/798 --- This PR removes the unstable `-Zprofile` flag, which enables ”gcov-style” coverage instrumentation, along with its associated `-Zprofile-emit` configuration flag. (The profile flag predates and is almost entirely separate from the stable `-Cinstrument-coverage` flag.) Notably, the `-Zprofile` flag: - Is largely untested in-tree, having only one run-make test that does not check whether its output is correct or useful. - Has no known maintainer. - Has seen no push towards stabilization. - Has at least one severe regression reported in 2022 that apparently remains unaddressed. - #100125 - Is confusingly named, since it appears to be more about coverage than performance profiling, and has nothing to do with PGO. - Is fundamentally limited by relying on counters auto-inserted by LLVM, with no knowledge of Rust beyond debuginfo.
2024-11-01Auto merge of #132276 - compiler-errors:enforce-fx-in-mir, r=fee1-deadbors-37/+77
Double-check conditional constness in MIR To prevent any unchecked `~const` bounds from leaking through during MIR lowering. If this check fails, it will eventually just delay a bug, but for now it reports errors. That error reporting may be redundant if we're calling it from code that already doesn't allow `~const` (i.e. when the `effects` and `const_trait_impl` gates are disabled), but I don't think it's that big of a deal. edit: This also makes sure that we issue a const stability error if we encounter *any* function with const conditions when `const_trait_impl` is not enabled. This ensures that that feature remains airtight.