about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-07-20compiler: Never debug_assert in codegenJubilee Young-65/+57
The gains in performance are not worth the costs in correctness. This is partly because the gains are zero and the costs are unknown.
2024-07-19Auto merge of #127968 - fmease:upd-jsondocck-directive-style, r=GuillaumeGomezbors-1090/+1095
Update jsondocck directives to follow ui_test-style Context: Comment chain in #125813. Follow-up to #126788. Use the same temporary approach of "double parsing" until we figure out how we want to support compiletest/ui_test directive "add-ons" for child test runners like HtmlDocCk and JsonDocCk. I didn't touch much of jsondocck because I want to refactor it some other time (for robustness, maintainability and better diagnostics; basically by following a similar design of my WIP HtmlDocCk-next, cc #125780). r? `@GuillaumeGomez`
2024-07-19Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgrbors-212/+744
Rollup of 6 pull requests Successful merges: - #127295 (CFI: Support provided methods on traits) - #127814 (`C-cmse-nonsecure-call`: improved error messages) - #127949 (fix: explain E0120 better cover cases when its raised) - #127966 (Use structured suggestions for unconstrained generic parameters on impl blocks) - #127976 (Lazy type aliases: Diagostics: Detect bivariant ty params that are only used recursively) - #127978 (Avoid ref when using format! for perf) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-19Rollup merge of #127978 - nyurik:lib-refs, r=workingjubileeMatthias Krüger-6/+6
Avoid ref when using format! for perf Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-19Rollup merge of #127976 - fmease:lta-cyclic-bivariant-param-better-err, ↵Matthias Krüger-50/+50
r=compiler-errors Lazy type aliases: Diagostics: Detect bivariant ty params that are only used recursively Follow-up to errs's #127871. Extends the logic to cover LTAs, too, not just ADTs. This change only takes effect with the next-gen solver enabled as cycle errors like the one we have here are fatal in the old solver. That's my explanation anyways. r? compiler-errors
2024-07-19Rollup merge of #127966 - oli-obk:structured_diag, r=compiler-errorsMatthias Krüger-56/+39
Use structured suggestions for unconstrained generic parameters on impl blocks I did not deduplicate with `UnusedGenericParameter`, because in contrast to type declarations, just using a generic parameter in an impl isn't enough, it must be used with the right variance and not just as part of a projection.
2024-07-19Rollup merge of #127949 - princess-entrapta:master, r=tgross35Matthias Krüger-8/+16
fix: explain E0120 better cover cases when its raised Fixes https://github.com/rust-lang/rust/issues/98996 Wording change on the explain of E0120 as requested
2024-07-19Rollup merge of #127814 - folkertdev:c-cmse-nonsecure-call-error-messages, ↵Matthias Krüger-55/+569
r=oli-obk `C-cmse-nonsecure-call`: improved error messages tracking issue: #81391 issue for the error messages (partially implemented by this PR): #81347 related, in that it also deals with CMSE: https://github.com/rust-lang/rust/pull/127766 When using the `C-cmse-nonsecure-call` ABI, both the arguments and return value must be passed via registers. Previously, when violating this constraint, an ugly LLVM error would be shown. Now, the rust compiler itself will print a pretty message and link to more information.
2024-07-19Rollup merge of #127295 - maurer:default-impl-cfi, r=estebankMatthias Krüger-37/+64
CFI: Support provided methods on traits Provided methods currently don't get type erasure performed on them because they are not in an `impl` block. If we are instantiating a method that is an associated item, but *not* in an impl block, treat it as a provided method instead.
2024-07-19LTA: Diag: Detect bivariant ty params that are only used recursivelyLeón Orell Valerian Liehr-50/+50
2024-07-19Avoid ref when using format! for perfYuri Astrakhan-6/+6
Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.
2024-07-19Auto merge of #127969 - matthiaskrgr:rollup-nhxmwhn, r=matthiaskrgrbors-313/+324
Rollup of 7 pull requests Successful merges: - #112328 (Feat. adding ext that returns change_time) - #126199 (Add `isqrt` to `NonZero<uN>`) - #127856 (interpret: add sanity check in dyn upcast to double-check what codegen does) - #127934 (Improve error when a compiler/library build fails in `checktools.sh`) - #127960 (Cleanup dll/exe filename calculations in `run_make_support`) - #127963 (Fix display of logo "border") - #127967 (Disable run-make/split-debuginfo test for RISC-V 64) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-19Rollup merge of #127967 - ↵Matthias Krüger-0/+2
joshua-zivkovic:joshua-zivkovic/disable-split-debuginfo, r=jieyouxu Disable run-make/split-debuginfo test for RISC-V 64 Together with `@Hoverbear,` we've been improving the state of the riscv64gc-unknown-linux-gnu target. This is in relation to https://github.com/rust-lang/rust/pull/125220 where `tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs` was disabled for RISC-V 64 in that another test, `tests/run-make/split-debuginfo` also needs to be disabled due to https://github.com/llvm/llvm-project/issues/56642 and the changes made in https://github.com/rust-lang/rust/pull/120518. This test appears to be a host test, not a target test, so it isn't seen failing in https://github.com/rust-lang/rust/pull/126641, however, we are in the process of testing host tools for riscv64-gc-unknown-linux-gnu so this test has now been noticed to be a problem.
2024-07-19Rollup merge of #127963 - GuillaumeGomez:fix-logo-display, r=notriddleMatthias Krüger-1/+0
Fix display of logo "border" Before: ![Screenshot from 2024-07-19 13-32-17](https://github.com/user-attachments/assets/381bb9c8-0ae0-408b-8476-9785ef1b5fd4) After: ![Screenshot from 2024-07-19 13-37-46](https://github.com/user-attachments/assets/19cdb71f-3912-4fcd-95de-99b9f86a8293) r? `@notriddle`
2024-07-19Rollup merge of #127960 - jieyouxu:minor-rmake-cleanup, r=fmeaseMatthias Krüger-30/+6
Cleanup dll/exe filename calculations in `run_make_support` Use `std::env::consts` constants since now we have access to them (unlike in Makefiles!) ^^ cc `@bzEq` (this is one of the places in our test suites that tries to compute e.g. dylib extension; using `std::env::consts::DLL_EXTENSION` should correctly return `a` for AIX) r? `@fmease` (thank you for the suggestion in https://github.com/rust-lang/rust/pull/127760#discussion_r1678079698, this also improves correctness for the support library!) try-job: aarch64-apple try-job: armhf-gnu try-job: test-various try-job: x86_64-msvc try-job: x86_64-gnu-llvm-18
2024-07-19Rollup merge of #127934 - Kobzol:checktools-better-error, r=onur-ozkanMatthias Krüger-0/+4
Improve error when a compiler/library build fails in `checktools.sh` Suggested by ``@RalfJung`` [here](https://github.com/rust-lang/rust/issues/127869#issuecomment-2235829643). `x86_64-gnu-tools` should take ~45 minutes, let's see if this doesn't regress it. r? ``@onur-ozkan``
2024-07-19Rollup merge of #127856 - RalfJung:interpret-cast-sanity, r=oli-obkMatthias Krüger-237/+228
interpret: add sanity check in dyn upcast to double-check what codegen does For dyn receiver calls, we already have two codepaths: look up the function to call by indexing into the vtable, or alternatively resolve the DefId given the dynamic type of the receiver. With debug assertions enabled, the interpreter does both and compares the results. (Without debug assertions we always use the vtable as it is simpler.) This PR does the same for dyn trait upcasts. However, for casts *not* using the vtable is the easier thing to do, so now the vtable path is the debug-assertion-only path. In particular, there are cases where the vtable does not contain a pointer for upcasts but instead reuses the old pointer: when the supertrait vtable is a prefix of the larger vtable. We don't want to expose this optimization and detect UB if people do a transmute assuming this optimization, so we cannot in general use the vtable indexing path. r? ``@oli-obk``
2024-07-19Rollup merge of #126199 - ivan-shrimp:nonzero_isqrt, r=tgross35Matthias Krüger-45/+63
Add `isqrt` to `NonZero<uN>` Implements [#70887 (comment)](https://github.com/rust-lang/rust/issues/116226#issuecomment-2144225174), with the following signature: ```rust impl NonZero<uN> { const fn isqrt(self) -> Self; } ``` Unintended benefits include one fewer panicking branch in `ilog2` for LLVM to optimize away, and one fewer `assume_unchecked` as `NonZero` already does that. The fast path for `self == 1` is dropped, but the current implementation is very slow anyways compared to hardware. Performance improvements can always come later. (I didn't add the function to `NonZero<iN>`, since _every_ existing `NonZero` method is non-panicking, and it might be nice to leave it that way.)
2024-07-19Rollup merge of #112328 - juliusl:pr/windows-add-change-time, r=ChrisDentonMatthias Krüger-0/+21
Feat. adding ext that returns change_time Addresses #112327
2024-07-19Update all rustdoc-json/ tests to use the new styleLeón Orell Valerian Liehr-1043/+1043
2024-07-19Update jsondocck directives to follow ui_test-styleLeón Orell Valerian Liehr-47/+52
2024-07-19Use structured suggestions for unconstrained generic parameters on impl blocksOli Scherer-56/+39
2024-07-19Auto merge of #127957 - matthiaskrgr:rollup-1u5ivck, r=matthiaskrgrbors-146/+490
Rollup of 6 pull requests Successful merges: - #127350 (Parser: Suggest Placing the Return Type After Function Parameters) - #127621 (Rewrite and rename `issue-22131` and `issue-26006` `run-make` tests to rmake) - #127662 (When finding item gated behind a `cfg` flag, point at it) - #127903 (`force_collect` improvements) - #127932 (rustdoc: fix `current` class on sidebar modnav) - #127943 (Don't allow unsafe statics outside of extern blocks) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-19fix: explain E0120 better cover cases when its raisedPrincess Entrapta-8/+16
2024-07-19Disable run-make/split-debuginfo test for RISC-V 64Joshua Zivkovic-0/+2
Due to https://github.com/rust-lang/rust/pull/120518
2024-07-19Improve error when a compiler/library build fails in `checktools.sh`Jakub Beránek-0/+4
2024-07-19Fix display of logo "border"Guillaume Gomez-1/+0
2024-07-19improve safety commentivan-shrimp-1/+1
2024-07-19run_make_support: cleanup dll/exe filename calculations许杰友 Jieyou Xu (Joe)-30/+6
2024-07-19Auto merge of #127956 - tgross35:rollup-8ten7pk, r=tgross35bors-281/+1904
Rollup of 7 pull requests Successful merges: - #121533 (Handle .init_array link_section specially on wasm) - #127825 (Migrate `macos-fat-archive`, `manual-link` and `archive-duplicate-names` `run-make` tests to rmake) - #127891 (Tweak suggestions when using incorrect type of enum literal) - #127902 (`collect_tokens_trailing_token` cleanups) - #127928 (Migrate `lto-smoke-c` and `link-path-order` `run-make` tests to rmake) - #127935 (Change `binary_asm_labels` to only fire on x86 and x86_64) - #127953 ([compiletest] Search *.a when getting dynamic libraries on AIX) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-19add `NonZero<uN>::isqrt`ivan-shrimp-45/+63
2024-07-19Rollup merge of #127943 - compiler-errors:no-unsafe, r=spastorinoMatthias Krüger-2/+35
Don't allow unsafe statics outside of extern blocks This PR fixes a regression where we allowed `unsafe static` items in top-level modules (i.e. outside of `unsafe extern` blocks). It's harder IMO to integrate this into the `check_item_safety` function, so I opted to just put this check on the `static` item itself. Beta version of this lives at #127944. r? ```@oli-obk``` or ```@spastorino```
2024-07-19Rollup merge of #127932 - notriddle:notriddle/current, r=GuillaumeGomezMatthias Krüger-3/+9
rustdoc: fix `current` class on sidebar modnav | Before | After | | -- | -- | | ![image](https://github.com/user-attachments/assets/35866be8-5a58-41eb-9169-b2bb403fe7cd) | ![image](https://github.com/user-attachments/assets/89b087ea-82bf-49f5-9c87-20162880eb32)
2024-07-19Rollup merge of #127903 - nnethercote:force_collect-improvements, r=petrochenkovMatthias Krüger-43/+47
`force_collect` improvements Yet more cleanups relating to `cfg_attr` processing. r? ````@petrochenkov````
2024-07-19Rollup merge of #127662 - estebank:gate-span, r=TaKO8KiMatthias Krüger-25/+122
When finding item gated behind a `cfg` flag, point at it Previously we would only mention that the item was gated out, and opportunisitically mention the feature flag name when possible. We now point to the place where the item was gated, which can be behind layers of macro indirection, or in different modules. ``` error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-cross-crate.rs:18:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out --> $DIR/auxiliary/cfged_out.rs:6:13 | LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ note: the item is gated here --> $DIR/auxiliary/cfged_out.rs:5:5 | LL | #[cfg(FALSE)] | ^^^^^^^^^^^^^ ```
2024-07-19Rollup merge of #127621 - Oneirical:hypnotest-show, r=jieyouxuMatthias Krüger-34/+62
Rewrite and rename `issue-22131` and `issue-26006` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc try-job: i686-mingw
2024-07-19Rollup merge of #127350 - veera-sivarajan:bugfix-126311, r=lcnrMatthias Krüger-39/+215
Parser: Suggest Placing the Return Type After Function Parameters Fixes #126311 This PR suggests placing the return type after the function parameters when it's misplaced after a `where` clause. This also tangentially improves diagnostics for cases like [this](https://github.com/veera-sivarajan/rust/blob/86d6f1312a77997ef994240e716288d61a343a6d/tests/ui/parser/issues/misplaced-return-type-without-where-issue-126311.rs#L1C1-L1C28) and adds doc comments for `parser::AllowPlus`.
2024-07-19Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwUbors-540/+850
Represent type-level consts with new-and-improved `hir::ConstArg` ### Summary This is a step toward `min_generic_const_exprs`. We now represent all const generic arguments using an enum that differentiates between const *paths* (temporarily just bare const params) and arbitrary anon consts that may perform computations. This will enable us to cleanly implement the `min_generic_const_args` plan of allowing the use of generics in paths used as const args, while disallowing their use in arbitrary anon consts. Here is a summary of the salient aspects of this change: - Add `current_def_id_parent` to `LoweringContext` This is needed to track anon const parents properly once we implement `ConstArgKind::Path` (which requires moving anon const def-creation outside of `DefCollector`). - Create `hir::ConstArgKind` enum with `Path` and `Anon` variants. Use it in the existing `hir::ConstArg` struct, replacing the previous `hir::AnonConst` field. - Use `ConstArg` for all instances of const args. Specifically, use it instead of `AnonConst` for assoc item constraints, array lengths, and const param defaults. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at https://github.com/rust-lang/rust/issues/127009. ### Followup items post-merge - Use `ConstArgKind::Path` for all const paths, not just const params. - Fix (no github dont close this issue) #127009 - If a path in generic args doesn't resolve as a type, try to resolve as a const instead (do this in rustc_resolve). Then remove the special-casing from `rustc_ast_lowering`, so that all params will automatically be lowered as `ConstArgKind::Path`. - (?) Consider making `const_evaluatable_unchecked` a hard error, or at least trying it in crater r? `@BoxyUwU`
2024-07-19Rollup merge of #127953 - bzEq:aix-compiletest-dylib-suffix, r=jieyouxuTrevor Gross-0/+2
[compiletest] Search *.a when getting dynamic libraries on AIX AIX uses `.a` as dylib suffix. Support it in compiletest.
2024-07-19Rollup merge of #127935 - tgross35:binary_asm_labels-x86-only, r=estebank,UrgauTrevor Gross-26/+77
Change `binary_asm_labels` to only fire on x86 and x86_64 In <https://github.com/rust-lang/rust/pull/126922>, the `binary_asm_labels` lint was added which flags labels such as `0:` and `1:`. Before that change, LLVM was giving a confusing error on x86/x86_64 because of an incorrect interpretation. However, targets other than x86 and x86_64 never had the error message and have not been a problem. This means that the lint was causing code that previously worked to start failing (e.g. `compiler_builtins`), rather than only providing a more clear messages where there has always been an error. Adjust the lint to only fire on x86 and x86_64 assembly to avoid this regression. Also update the help message. Fixes: https://github.com/rust-lang/rust/issues/127821
2024-07-19Rollup merge of #127928 - Oneirical:anatesthetic-sleep, r=KobzolTrevor Gross-33/+53
Migrate `lto-smoke-c` and `link-path-order` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-07-19Rollup merge of #127902 - ↵Trevor Gross-98/+155
nnethercote:collect_tokens_trailing_token-cleanups, r=petrochenkov `collect_tokens_trailing_token` cleanups More cleanups I made while understanding the code for processing `cfg_attr`, to fix test failures in #124141. r? `@petrochenkov`
2024-07-19Rollup merge of #127891 - estebank:enum-type-sugg, r=estebankTrevor Gross-79/+1508
Tweak suggestions when using incorrect type of enum literal More accurate suggestions when writing wrong style of enum variant literal: ``` error[E0533]: expected value, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-expr.rs:18:14 | LL | let e3 = E::Empty3; | ^^^^^^^^^ not a value | help: you might have meant to create a new value of the struct | LL | let e3 = E::Empty3 {}; | ++ ``` ``` error[E0533]: expected value, found struct variant `E::V` --> $DIR/struct-literal-variant-in-if.rs:10:13 | LL | if x == E::V { field } {} | ^^^^ not a value | help: you might have meant to create a new value of the struct | LL | if x == (E::V { field }) {} | + + ``` ``` error[E0618]: expected function, found enum variant `Enum::Unit` --> $DIR/suggestion-highlights.rs:15:5 | LL | Unit, | ---- enum variant `Enum::Unit` defined here ... LL | Enum::Unit(); | ^^^^^^^^^^-- | | | call expression requires function | help: `Enum::Unit` is a unit enum variant, and does not take parentheses to be constructed | LL - Enum::Unit(); LL + Enum::Unit; | ``` ``` error[E0599]: no variant or associated item named `tuple` found for enum `Enum` in the current scope --> $DIR/suggestion-highlights.rs:36:11 | LL | enum Enum { | --------- variant or associated item `tuple` not found for this enum ... LL | Enum::tuple; | ^^^^^ variant or associated item not found in `Enum` | help: there is a variant with a similar name | LL | Enum::Tuple(/* i32 */); | ~~~~~~~~~~~~~~~~; | ``` Tweak "field not found" suggestion when giving struct literal for tuple struct type: ``` error[E0560]: struct `S` has no field named `x` --> $DIR/nested-non-tuple-tuple-struct.rs:8:19 | LL | pub struct S(f32, f32); | - `S` defined here ... LL | let _x = (S { x: 1.0, y: 2.0 }, S { x: 3.0, y: 4.0 }); | ^ field does not exist | help: `S` is a tuple struct, use the appropriate syntax | LL | let _x = (S(/* f32 */, /* f32 */), S { x: 3.0, y: 4.0 }); | ~~~~~~~~~~~~~~~~~~~~~~~
2024-07-19Rollup merge of #127825 - Oneirical:self-testeem, r=jieyouxuTrevor Gross-36/+73
Migrate `macos-fat-archive`, `manual-link` and `archive-duplicate-names` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc try-job: aarch64-apple
2024-07-19Rollup merge of #121533 - ratmice:wasm_init_fini_array, r=nnethercoteTrevor Gross-9/+36
Handle .init_array link_section specially on wasm Given that wasm-ld now has support for [.init_array](https://github.com/llvm/llvm-project/blob/8f2bd8ae68883592a333f4bdbed9798d66e68630/llvm/lib/MC/WasmObjectWriter.cpp#L1852), it appears we can easily implement that section by falling through to the normal path rather than taking the typical custom_section path for wasm. The wasm-ld appears to have a bunch of limitations. Only one static with the `link_section` in a crate or else you hit the fatal error in the link above "only one .init_array section fragment supported". They do not get merged. You can still call multiple constructors by setting it to an array. ``` unsafe extern "C" fn ctor() { println!("foo"); } #[used] #[link_section = ".init_array"] static FOO: [unsafe extern "C" fn(); 2] = [ctor, ctor]; ``` Another issue appears to be that if crate *A* depends on crate *B*, but *A* doesn't call any symbols from *B* and *B* doesn't `#[export_name = ...]` any symbols, then crate *B*'s constructor will not be called. The workaround to this is to provide an exported symbol in crate *B*.
2024-07-19Update the `binary_asm_label` documentationTrevor Gross-9/+23
Disable a test that now only passes on x86 and make the link point to the new (open) LLVM bug.
2024-07-19Overhaul comments in `collect_tokens_trailing_token`.Nicholas Nethercote-75/+129
Adding details, clarifying lots of little things, etc. In particular, the commit adds details of an example. I find this very helpful, because it's taken me a long time to understand how this code works.
2024-07-19Make `Parser::num_bump_calls` 0-indexed.Nicholas Nethercote-6/+11
Currently in `collect_tokens_trailing_token`, `start_pos` and `end_pos` are 1-indexed by `replace_ranges` is 0-indexed, which is really confusing. Making them both 0-indexed makes debugging much easier.
2024-07-19Move `inner_attr` code downwards.Nicholas Nethercote-10/+10
This puts it just before the `replace_ranges` initialization, which makes sense because the two variables are closely related.
2024-07-19Remove `final_attrs` local variable.Nicholas Nethercote-4/+2
It's no shorter than `ret.attrs()`, and `ret.attrs()` is used multiple times earlier in the function.