about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2025-03-15Auto merge of #138379 - estebank:macro-backtrace-note, r=petrochenkovbors-463/+4
Do not suggest using `-Zmacro-backtrace` for builtin macros For macros that are implemented on the compiler, or that are annotated with `rustc_diagnostic_item`, which have arbitrary implementations from the point of view of the user and might as well be intrinsics, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros like `panic!` and `format!`. This PR adds a field to every `Span`'s `ExpnData` stating whether it comes from a builtin macro. This is determined by the macro being annotated with either `#[rustc_builtin_macro]` or `#[rustc_diagnostic_item]`. An alternative to using these attributes that already exist for other uses would be to introduce another attribute like `#[rustc_no_backtrace]` to have finer control on which macros are affected (for example, an error within `vec![]` now doesn't mention the backtrace, but one could make the case that it should). Ideally, instead of carrying this information in the `ExpnData` we'd instead try to query the `DefId` of the macro (that is already stored) to see if it is annotated in some way, but we do not have access to the `TyCtxt` from `rustc_errors`. r? `@petrochenkov`
2025-03-15Rollup merge of #138518 - yotamofek:pr/hir-lint-typo, r=compiler-errorsLeón Orell Valerian Liehr-12/+12
Fix typo in hir lowering lint diag
2025-03-15Rollup merge of #138482 - nnethercote:fix-hir-printing, r=compiler-errorsLeón Orell Valerian Liehr-1/+73
Fix HIR printing of parameters HIR pretty printing does the wrong thing for anonymous parameters, and there is no test coverage for it. This PR remedies both of those things. r? ``@lcnr``
2025-03-15Rollup merge of #138460 - xizheyin:issue-138319, r=petrochenkovLeón Orell Valerian Liehr-0/+71
Pass struct field HirId when check_expr_struct_fields Fixes #138319 r? compiler cc ``@Mark-Simulacrum``
2025-03-15Rollup merge of #138056 - heiher:loong64v1.1-features, r=petrochenkovLeón Orell Valerian Liehr-16/+23
rustc_target: Add target features for LoongArch v1.1 This patch adds new target features for LoongArch v1.1: * div32 * lam-bh * lamcas * ld-seq-sa * scq
2025-03-14Fix typo in hir lowering lint diagYotam Ofek-12/+12
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-463/+4
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-14Rollup merge of #137619 - Pyr0de:issue_137249, r=fmeaseLeón Orell Valerian Liehr-0/+19
Provide helpful diagnostics for shebang lookalikes When `[` is not found after a `#!`, a note will be added to the exisiting error ``` error: expected `[`, found `/` --> src/main.rs:2:3 | 2 | #!/usr/bin/env -S cargo +nightly -Zscript | ^ expected `[` | = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file ``` Fixes #137249 r? `@fmease`
2025-03-14Rollup merge of #134720 - malezjaa:feat/crate-type-valid-values, r=jieyouxuLeón Orell Valerian Liehr-6/+12
Display valid crate types in error message for --crate-type flag This PR improves the error message for the --crate-type flag. When an invalid crate type is provided, the compiler will now show a list of valid options. ### Before ![image](https://github.com/user-attachments/assets/4922e4e5-eeca-40cd-ac1c-1c6319a81aee) ### After ![image](https://github.com/user-attachments/assets/67ea1f35-aa41-4e4f-8691-47c273d0cff9) I based the implementation on `OutputType::shorthands_display` Closes #70183
2025-03-14Show valid crate types when the user passes unknown `--crate-type` valuemalezjaa-6/+12
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2025-03-14Auto merge of #138480 - jhpratt:rollup-y3b8wu5, r=jhprattbors-13/+36
Rollup of 16 pull requests Successful merges: - #136001 (Overhaul examples for PermissionsExt) - #136230 (Reword incorrect documentation about SocketAddr having varying layout) - #136892 (Sync Fuchsia target spec with clang Fuchsia driver) - #136911 (Add documentation URL to selected jobs) - #137870 ( Improve HashMap docs for const and static initializers) - #138179 (Add `src/tools/x` to the main workspace) - #138389 (use `expect` instead of `allow`) - #138396 (Enable metrics and verbose tests in PR CI) - #138398 (atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance) - #138432 (fix: remove the check of lld not supporting `@response-file)` - #138434 (Visit `PatField` when collecting lint levels) - #138441 (update error message) - #138442 (EUV: fix place of deref pattern's interior's scrutinee) - #138457 (Remove usage of legacy scheme paths on RedoxOS) - #138461 (Remove an outdated line from a test comment) - #138466 (Remove myself from libs review) Failed merges: - #138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-14Pass precise HirId when calling check_stabilityxizheyin-0/+71
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-14Rollup merge of #138461 - WaffleLapkin:indate-comment, r=ehussJacob Pratt-1/+0
Remove an outdated line from a test comment They *used* to not work, however this was fixed in the PR that added the test. I forgot to remove this line or possibly lost its removal while rebasing. r? `@ehuss`
2025-03-14Rollup merge of #138442 - dianne:deref-pat-euv-fix, r=compiler-errorsJacob Pratt-12/+15
EUV: fix place of deref pattern's interior's scrutinee The place previously used here was that of the temporary holding the reference returned by `Deref::deref` or `DerefMut::deref_mut`. However, since the inner pattern of `deref!(inner)` expects the deref-target type itself, this would ICE when that type was inspected (e.g. by the EUV case for slice patterns). This adds a deref projection to fix that. Since current in-tree consumers of EUV (upvar inference and clippy) don't care about Rvalues, the place could be simplified to `self.cat_rvalue(pat.hir_id, self.pat_ty_adjusted(subpat)?)` to save some cycles. I personally find EUV to be a bit fragile, so I've opted for pedantic correctness. Maybe a `HACK` comment would suffice though? Fixes #125059 r? `@compiler-errors`
2025-03-14Rollup merge of #138434 - compiler-errors:lint-level-pat-field, r=jieyouxuJacob Pratt-0/+21
Visit `PatField` when collecting lint levels Fixes #138428 Side-note, I vaguely skimmed over the other nodes we could be visiting here and it doesn't *seem* to me that we're missing anything, though I may be mistaken given recent(?) support for attrs in where clauses(??). Can be fixed in a follow-up PR.
2025-03-14Auto merge of #138157 - scottmcm:inline-more-tiny-things, r=oli-obkbors-169/+351
Allow more top-down inlining for single-BB callees This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them. Fixes #138136 ~~Draft as it's built atop #138135, which adds a mir-opt test that's a nice demonstration of this. To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
2025-03-14rustc_target: Add target features for LoongArch v1.1WANG Rui-16/+23
2025-03-14Auto merge of #138391 - scottmcm:SSA-discriminants, r=WaffleLapkinbors-28/+30
Don't `alloca` just to look at a discriminant Today we're making LLVM do a bunch of extra work when you match on trivial stuff like `Option<bool>` or `ControlFlow<u8>`. This PR changes that so that simple types like `Option<u32>` or `Result<(), Box<Error>>` can stay as `OperandValue::ScalarPair` and we can still read the discriminant from them, rather than needing to write them into memory to have a `PlaceValue` just to get the discriminant out. Fixes #137503
2025-03-14Fix HIR param pretty printing some more.Nicholas Nethercote-2/+2
Anonymous params are currently represented with `kw::Empty`, so handle that properly. (Subsequent commits will get rid of the `kw::Empty`.)
2025-03-14Handle `_` properly in a couple of places.Nicholas Nethercote-4/+4
Currently (PatKind::Wild` (i.e. `_`) gets turned by `lower_fn_params_to_names` into an empty identifier, which means it is printed incorrectly by HIR pretty printing. And likewise for `lower_fn_params_to_names`, which affects some error messages. This commit fixes them. This requires a slight tweak in a couple of places to continue using parameter numbers in some error messages. And it improves the output of `tests/ui/typeck/cyclic_type_ice.rs`: `/* _ */` is a better suggestion than `/* */`.
2025-03-14Add a pretty printing test for fn params.Nicholas Nethercote-0/+72
Note that multiple parts of the output are incorrect. The following commits will fix this.
2025-03-13Remove an outdated line from a test commentWaffle Lapkin-1/+0
They *used* to not work, however this was fixed in the PR that added the test. I forgot to remove this line or possibly lost its removal while rebasing.
2025-03-13Rollup merge of #138399 - Bryanskiy:delegation-extern-fn, r=petrochenkovMatthias Krüger-0/+49
Delegation: allow foreign fns `reuse` In example: ```rust unsafe extern "C" { fn foo(); } reuse foo as bar; ``` Desugaring before: ```rust fn bar() { foo() //~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block } ``` after: ```rust unsafe extern "C" fn bar() { foo() } ``` Fixes https://github.com/rust-lang/rust/issues/127412 r? `@petrochenkov`
2025-03-13Rollup merge of #138126 - compiler-errors:rtn-for-sugg, r=oli-obkMatthias Krüger-0/+53
Add an opt-out in pretty printing for RTN rendering Today, we render RPITIT types like `impl Sized { T::method(..) }` when RTN is enabled. This is very useful for diagnostics, since it's often not clear what the `impl Sized` type means by itself, and it makes it clear that that's an RPITIT that can be bounded using RTN syntax. See #115624. However, since we don't distinguish types that are rendered for the purposes of printing messages vs suggestions, this representation leaks into suggestions and turns into code that can't be parsed. This PR adds a new `with_types_for_suggestion! {}` and `with_types_for_signature! {}` options to the pretty printing architecture to make it clear that we're rendering a type for code suggestions. This can be applied later as we find that we need it.
2025-03-13Provide helpful diagnostics for shebang lookalikesPyrode-0/+19
2025-03-13Auto merge of #138450 - matthiaskrgr:rollup-4im25vf, r=matthiaskrgrbors-4/+39
Rollup of 6 pull requests Successful merges: - #137816 (attempt to support `BinaryFormat::Xcoff` in `naked_asm!`) - #138109 (make precise capturing args in rustdoc Json typed) - #138343 (Enable `f16` tests for `powf`) - #138356 (bump libc to 0.2.171 to fix xous) - #138371 (Update compiletest's `has_asm_support` to match rustc) - #138404 (Cleanup sysroot locating a bit) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-13Delegation: allow foreign fns `reuse`Bryanskiy-0/+49
2025-03-13Rollup merge of #138404 - bjorn3:sysroot_handling_cleanup, ↵Matthias Krüger-1/+1
r=petrochenkov,jieyouxu Cleanup sysroot locating a bit All commits should preserve existing behavior.
2025-03-13Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-arg, ↵Matthias Krüger-3/+3
r=aDotInTheVoid,compiler-errors make precise capturing args in rustdoc Json typed close #137616 This PR includes below changes. - Add `rustc_hir::PreciseCapturingArgKind` which allows the query system to return a arg's data. - Add `rustdoc::clean::types::PreciseCapturingArg` and change to use it. - Add `rustdoc-json-types::PreciseCapturingArg` and change to use it. - Update `tests/rustdoc-json/impl-trait-precise-capturing.rs`. - Bump `rustdoc_json_types::FORMAT_VERSION`.
2025-03-13Rollup merge of #137816 - folkertdev:naked-asm-xcoff, r=NoratriebMatthias Krüger-0/+35
attempt to support `BinaryFormat::Xcoff` in `naked_asm!` Fixes https://github.com/rust-lang/rust/issues/137219 So, the inline assembly support for xcoff is extremely limited. The LLVM [XCOFFAsmParser](https://github.com/llvm/llvm-project/blob/1b25c0c4da968fe78921ce77736e5baef4db75e3/llvm/lib/MC/MCParser/XCOFFAsmParser.cpp) does not support many of the attributes that LLVM itself emits, and that should exist based on [the assembler docs](https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf). It also does accept some that should not exist based on those docs. So, I've tried to do the best I can given those limitations. At least it's better than emitting the directives for elf and having that fail somewhere deep in LLVM. Given that inline assembly for this target is incomplete (under `asm_experimental_arch`), I think that's OK (and again I don't see how we can do better given the limitations in LLVM). r? ```@Noratrieb``` (given that you reviewed https://github.com/rust-lang/rust/pull/136637) It seems reasonable to ping the [`powerpc64-ibm-aix` target maintainers](https://doc.rust-lang.org/rustc/platform-support/aix.html), hopefully they have thoughts too: ```@daltenty``` ```@gilamn5tr```
2025-03-13Rollup merge of #138346 - folkertdev:naked-asm-windows-endef, r=ChrisDentonMatthias Krüger-24/+48
naked functions: on windows emit `.endef` without the symbol name tracking issue: https://github.com/rust-lang/rust/issues/90957 fixes https://github.com/rust-lang/rust/issues/138320 The `.endef` directive does not take the name as an argument. Apparently the LLVM x86_64 parser does accept this, but on i686 it's rejected. In general `i686` does some special name mangling stuff, so it's good to include it in the naked function tests. r? ````@ChrisDenton```` (because windows)
2025-03-13Rollup merge of #138162 - ehuss:library-2024, r=cuviperMatthias Krüger-12/+25
Update the standard library to Rust 2024 This updates the standard library to Rust 2024. This includes the following notable changes: - Macros are updated to use new expression fragment specifiers. This PR includes a test to illustrate the changes, primarily allowing `const {...}` expressions now. - Some tests show a change in MIR drop order. We do not believe this will be an observable change ([see zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/268952-edition/topic/standard.20library.20migration/near/500972873)). Fixes https://github.com/rust-lang/rust/issues/133081
2025-03-13EUV: fix place of deref pattern's interior's scrutineedianne-12/+15
The place previously used here was that of the temporary holding the reference returned by `Deref::deref` or `DerefMut::deref_mut`. However, since the inner pattern of `deref!(inner)` expects the deref-target type itself, this would ICE when that type was inspected (e.g. by the EUV case for slice patterns). This adds a deref projection to fix that. Since current in-tree consumers of EUV (upvar inference and clippy) don't care about Rvalues, the place could be simplified to `self.cat_rvalue(pat.hir_id, self.pat_ty_adjusted(subpat)?)` to save some cycles. I personally find EUV to be a bit fragile, so I've opted for pedantic correctness. Maybe a `HACK` comment would suffice though?
2025-03-12Allow more top-down inlining for single-BB calleesScott McMurray-169/+351
This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
2025-03-13Auto merge of #138249 - compiler-errors:auto-self, r=lcnrbors-28/+3
Do not register `Self: AutoTrait` when confirming auto trait (in old solver) Every built-in auto impl for a trait goal like `Ty: Auto` immediately registers another obligation of `Ty: Auto` as one of its nested obligations, leading to us stressing the cycle detection machinery a lot more than we need to. This is because all traits have a `Self: Trait` predicate. To fix this, remove the call to `impl_or_trait_obligations` in `vtable_auto_impl`, since auto traits do not have where clauses. r? lcnr
2025-03-13Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearthbors-107/+216
Rollup of 12 pull requests Successful merges: - #134076 (Stabilize `std::io::ErrorKind::InvalidFilename`) - #137504 (Move methods from Map to TyCtxt, part 4.) - #138175 (Support rmeta inputs for --crate-type=bin --emit=obj) - #138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs) - #138280 (fix ICE in pretty-printing `global_asm!`) - #138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js) - #138331 (Use `RUSTC_LINT_FLAGS` more) - #138357 (merge `TypeChecker` and `TypeVerifier`) - #138394 (remove unnecessary variant) - #138403 (Delegation: one more ICE fix for `MethodCall` generation) - #138407 (Delegation: reject C-variadics) - #138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-13Visit PatField when collecting lint levelsMichael Goulet-0/+21
2025-03-12Add an opt-out in pretty printing for RTN renderingMichael Goulet-0/+53
2025-03-12Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgrbors-123/+91
Rollup of 7 pull requests Successful merges: - #137314 (change definitely unproductive cycles to error) - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`) - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr) - #138331 (Use `RUSTC_LINT_FLAGS` more) - #138345 (Some autodiff cleanups) - #138387 (intrinsics: remove unnecessary leading underscore from argument names) - #138390 (fix incorrect tracing log) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-12Rollup merge of #138409 - xingxue-ibm:use-sigaction, r=compiler-errorsManish Goregaokar-24/+3
Use sa_sigaction instead of sa_union.__su_sigaction for AIX Revert test cases to use `sa_sigaction` instead of `sa_union.__su_sigaction`, now that the `libc` crate implementation for AIX defines `sa_sigaction` as a direct member of `struct sigaction`, aligning it with implementations on other similar platforms. ([[AIX] Use sa_sigaction instead of the union](https://github.com/rust-lang/libc/pull/4250)).
2025-03-12Rollup merge of #138407 - Bryanskiy:delegation-variadic, r=petrochenkovManish Goregaokar-11/+47
Delegation: reject C-variadics The explanation is contained in attached issues. Fixes https://github.com/rust-lang/rust/issues/127443 Fixes https://github.com/rust-lang/rust/issues/127413 r? `@petrochenkov`
2025-03-12Rollup merge of #138403 - Bryanskiy:delegation-ice-2, r=petrochenkovManish Goregaokar-0/+34
Delegation: one more ICE fix for `MethodCall` generation self-explanatory Fixes https://github.com/rust-lang/rust/issues/138362 r? `@petrochenkov`
2025-03-12Rollup merge of #138357 - lcnr:goodbye-TypeVerifier-rarw, r=compiler-errorsManish Goregaokar-8/+8
merge `TypeChecker` and `TypeVerifier` Stacked on top of #138354. Best reviewed commit by commit. r? `@compiler-errors`
2025-03-12Rollup merge of #138280 - folkertdev:mir-dump-asm-const, r=compiler-errorsManish Goregaokar-0/+18
fix ICE in pretty-printing `global_asm!` fixes https://github.com/rust-lang/rust/issues/138260 since https://github.com/rust-lang/rust/pull/137180, `global_asm!` gets a fake body, that the pretty printing logic did not know what to do with. based on [#t-compiler/help > tests for MIR pretty printing](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tests.20for.20MIR.20pretty.20printing) I created `tests/ui/unpretty/mir` which seemed as good a place as any for a test. If there is a better place, let me know. try-job: test-various try-job: x86_64-apple-2
2025-03-12Rollup merge of #138259 - compiler-errors:disentangle-ribs, r=BoxyUwUManish Goregaokar-64/+74
Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs In #137617, the `ConstParamTy` rib was adjusted to act kinda like the `ForwardGenericParamBan`. However, this means that it no longer served its purpose banning generics from *parent items*. Although we still are checking for param type validity using the `ConstParamTy_` trait, which means that we weren't accepting code we shouldn't, I think it's a bit strange for us not to be rejecting code like this during *resolution* and instead letting these malformed const generics leak into the type system: ```rust trait Foo<T> { fn bar<const N: T>() {} } ``` This PR does a few things: 1. Introduce a `ForwardGenericParamBanReason` enum, and start using the `ForwardGenericParamBan` rib to ban forward-declared params in const tys when `generic_const_parameter_types` is enabled. 2. Start using the `ConstParamTy` rib to ban *all* generics when `generic_const_parameter_types` is disabled. 3. Improve the diagnostics for both of the cases above, and for forward-declared params in parameter defaults too :3 r? `@BoxyUwU` or reassign
2025-03-12Rollup merge of #138175 - sam-mccall:binobj, r=nnethercoteManish Goregaokar-0/+32
Support rmeta inputs for --crate-type=bin --emit=obj This already works for --emit=metadata, but is possible anytime we're not linking. Tests: - `rmeta_bin` checks we're not changing --emit=link (already passes) - `rmeta_bin-pass` tests the new behavior for --emit=obj (would fail today) and also --emit=metadata which isn't changing
2025-03-12Rollup merge of #137314 - lcnr:cycles-with-unknown-kind, r=compiler-errorsMatthias Krüger-123/+91
change definitely unproductive cycles to error builds on top of #136824 by adding a third variant to `PathKind` for paths which may change to be coinductive in the future but must not be so right now. Most notably, impl where-clauses of not yet coinductive traits. With this, we can change cycles which are definitely unproductive to a proper error. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/114. This does not affect stable as we keep these cycles as ambiguous during coherence. r? ````````@compiler-errors```````` ````````@nikomatsakis````````
2025-03-12Disentangle ForwardGenericParamBan and ConstParamTy ribsMichael Goulet-64/+74
2025-03-12Make opts.maybe_sysroot non-optionalbjorn3-1/+1
build_session_options always uses materialize_sysroot anyway.
2025-03-12Use sa_sigaction instead of sa_union.__su_sigaction for AIX.Xing Xue-24/+3