about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2025-02-15Rollup merge of #136808 - chenyukang:yukang-fix-arg-list-error-129273, ↵Matthias Krüger-24/+79
r=estebank Try to recover from path sep error in type parsing Fixes #129273 Error using `:` in the argument list may mess up the parser. case `tests/ui/suggestions/struct-field-type-including-single-colon` also changed, seems it's the same meaning, should be OK. r? `@estebank`
2025-02-15Rollup merge of #136490 - Skepfyr:no-field-rest-pattern-attrs, r=compiler-errorsMatthias Krüger-0/+18
Do not allow attributes on struct field rest patterns Fixes #81282. This removes support for attributes on struct field rest patterns (the `..` bit) from the parser. Previously any attributes were being parsed but dropped from the AST, so didn't work and were deleted by rustfmt. This needs an equivalent change to the reference but I wanted to see how this PR is received first. The error message it produces isn't great, however it does match the error you get if you try to add attributes to .. in struct expressions atm, although I can understand wanting to do better given this was previously accepted. I think I could move attribute parsing back up to where it was and then emit a specific new error for this case, however I might need some guidance as this is the first time I've messed around inside the compiler. While this is technically breaking I don't think it's much of an issue: attributes in this position don't currently do anything and rustfmt outright deletes them, meaning it's incredibly unlikely to affect anyone. I have already made the equivalent change to *add* support for attributes (mostly) but the conversation in the linked issue suggested it would be more reasonable to just remove them (and pointed out it's much easier to add support later if we realise we need them).
2025-02-15Rollup merge of #127581 - fmease:fix-crate_name-validation, r=bjorn3Matthias Krüger-9/+76
Fix crate name validation Reject macro calls inside attribute `#![crate_name]` like in `#![crate_name = concat!("na", "me")]`. Prior to #117584, the result of the expansion (here: `"name"`) would actually be properly picked up by the compiler and used as the crate name. However since #117584 / on master, we extract the "value" (i.e., the *literal* string literal) of the `#![crate_name]` much earlier in the pipeline way before macro expansion and **skip**/**ignore** any `#![crate_name]`s "assigned to" a macro call. See also #122001. T-lang has ruled to reject `#![crate_name = MACRO!(...)]` outright very similar to other built-in attributes whose value we need early like `#![crate_type]`. See accepted FCP: https://github.com/rust-lang/rust/issues/122001#issuecomment-2023203182. Note that the check as implemented in this PR is even more "aggressive" compared to the one of `#![crate_type]` by running as early as possible in order to reject `#![crate_name = MACRO!(...)]` even in "non-normal" executions of `rustc`, namely on *print requests* (e.g., `--print=crate-name` and `--print=file-names`). If I were to move the validation step a bit further back close to the `#![crate_type]` one, `--print=crate-name` (etc.) would *not* exit fatally with an error in this kind of situation but happily report an incorrect crate name (i.e., the "crate name" as if `#![crate_name]` didn't exist / deduced from other sources like `--crate-name` or the file name) which would match the behavior on master. Again, see also #122001. I'm mentioning this explicitly because I'm not sure if it was that clear in the FCP'ed issue. I argue that my current approach is the most reasonable one. I know (from reading the code and from past experiments) that various print requests are still quite broken (mostly lack of validation). To the best of my knowledge, there's no print request whose output references/contains a crate *type*, so there's no "inherent need" to move `#![crate_type]`'s validation to happen earlier. --- Fixes #122001. https://github.com/rust-lang/rust/labels/relnotes: Compatibility. Breaking change.
2025-02-15Reject macro calls inside of `#![crate_name]`León Orell Valerian Liehr-0/+67
2025-02-15Move `#![crate_type]` UI tests into attributes directoryLeón Orell Valerian Liehr-3/+3
Gets rid of two top-level UI tests which is always great. Furthermore, move `need-crate-arg-ignore-tidy$x.rs` from `command/` to `invalid-compile-flags/`. `command/` concerns `std::process::Command` tests, not CLI tests.
2025-02-15Clean up rustc_session::output::{find,validate}_crate_nameLeón Orell Valerian Liehr-2/+2
2025-02-15Try to recover from path sep error in parseryukang-24/+79
2025-02-14Rollup merge of #137038 - maurer:tolerate-captures, r=nikicJubilee-1/+1
llvm: Tolerate captures in tests llvm/llvm-project@7e3735d1a1b85cea48feb45cb7c2b5d8eaa216ae introduces `captures` annotations. Adjust regexes to be tolerant of these. `@rustbot` label:+llvm-main
2025-02-14Rollup merge of #137037 - RalfJung:x86-sse2-abi, r=workingjubileeJubilee-1/+20
add x86-sse2 (32bit) ABI that requires SSE2 target feature This is the first commit of https://github.com/rust-lang/rust/pull/135408: The primary goal of this is to make SSE2 required for our i686 targets (at least for the ones that use Pentium 4 as their baseline), to ensure they cannot be affected by https://github.com/rust-lang/rust/issues/114479. This has been MCPd in https://github.com/rust-lang/compiler-team/issues/808, and is tracked in https://github.com/rust-lang/rust/issues/133611. We do this by defining a new ABI that these targets select, and making SSE2 required by the ABI (that's the first commit). That's kind of a hack, but it is the easiest way to make a target feature required via the target spec. In a follow-up change (https://github.com/rust-lang/rust/pull/135408), we can actually make use of SSE2 for the ABI, but that is running into some infrastructure issues. r? `@workingjubilee` try-job: aarch64-apple try-job: aarch64-gnu try-job: aarch64-gnu-debug try-job: test-various try-job: x86_64-gnu-nopt try-job: dist-i586-gnu-i586-i686-musl
2025-02-14Rollup merge of #137035 - compiler-errors:eagerly-mono-closures-after-norm, ↵Jubilee-0/+19
r=saethlin Normalize closure instance before eagerly monomorphizing it We were monomorphizing two versions of the closure (or in the original issue, coroutine) -- one with normalized captures and one with unnormalized captures. This led to a symbol collision. Fixes #137009 r? `@saethlin` or reassign
2025-02-14Rollup merge of #136971 - HypheX:patch1, r=WaffleLapkinJubilee-0/+37
Add a new check-pass UI test for returning `impl Fn(T) -> impl Trait` This PR closes #107883 by adding a ui test.
2025-02-14Normalize closure instance before eagerly monomorphizing itMichael Goulet-0/+19
2025-02-14llvm: Tolerate captures in testsMatthew Maurer-1/+1
llvm/llvm-project@7e3735d1a1b85cea48feb45cb7c2b5d8eaa216ae introduces `captures` annotations. Adjust regexes to be tolerant of these.
2025-02-14add x86-sse2 (32bit) ABI that requires SSE2 target featureRalf Jung-1/+20
2025-02-14Auto merge of #137030 - matthiaskrgr:rollup-267aumr, r=matthiaskrgrbors-863/+855
Rollup of 9 pull requests Successful merges: - #135778 (account for `c_enum_min_bits` in `multiple-reprs` UI test) - #136052 (Correct comment for FreeBSD and DragonFly BSD in unix/thread) - #136886 (Remove the common prelude module) - #136956 (add vendor directory to .gitignore) - #136958 (Fix presentation of purely "additive" replacement suggestion parts) - #136967 (Use `slice::fill` in `io::Repeat` implementation) - #136976 (alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr) - #137007 (Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`) - #137008 (Move code into `rustc_mir_transform`) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-14Rollup merge of #137007 - pvdrz:fix-aarch64-alloc-layout, r=compiler-errorsMatthias Krüger-0/+269
Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand` PR #136450 introduced a diff that includes a pointer-sized alloc. This doesn't cause any problems on the compiler test suite but it affects the test suite that ferrocene has for `aarch64-unknown-none` as the snapshot of the diff only includes a 32-bit alloc even though this should be a 64-bit alloc on `aarch64-unknown-none`. r? ``@compiler-errors``
2025-02-14Rollup merge of #136958 - compiler-errors:additive-replacmeent, r=estebankMatthias Krüger-861/+574
Fix presentation of purely "additive" replacement suggestion parts #127541 changes replacement suggestions to use the "diff" view always, which I think is really verbose in cases where a replacement snippet is a "superset" of the snippet that is being replaced. Consider: ``` LL - Self::Baz: Clone, LL + Self::Baz: Clone, T: std::clone::Clone ``` In this code, we suggest replacing `", "` with `", T: std::clone::Clone"`. This is a consequence of how the snippet is constructed. I believe that since the string that is being replaced is a subset of the replacement string, it's not providing much value to present this as a diff. Users should be able to clearly understand what's being suggested here using the `~` underline view we've been suggesting for some time now. Given that this affects ~100 tests out of the ~1000 UI tests affected, I expect this to be a pretty meaningful improvement of the fallout of #127541. --- In the last commit, this PR also "trims" replacement parts so that they are turned into their purely additive subset, if possible. See the diff for what this means. --- r? estebank
2025-02-14Rollup merge of #136886 - ehuss:remove-prelude-common, r=jhprattMatthias Krüger-1/+1
Remove the common prelude module This fixes the issues described in https://github.com/rust-lang/rust/issues/136102. Primarily, this resolves some issues with how the documentation for the prelude is generated: - It avoids showing "unstable" for macros in the prelude that are actually stable. - Avoids duplication of some pages due to the previous lack of `doc(no_inline)`. - Makes the different edition preludes consistent, and sets a pattern that can be used by future editions. We may need to rearrange these modules in the future if we decide to remove anything from the prelude again. If we do, I think we should look into a different solution that avoids the documentation problems. Closes https://github.com/rust-lang/rust/issues/136102
2025-02-14Rollup merge of #135778 - ferrocene:ja-gh135777, r=workingjubileeMatthias Krüger-1/+11
account for `c_enum_min_bits` in `multiple-reprs` UI test fixes #135777
2025-02-14Auto merge of #136575 - scottmcm:nsuw-math, r=nikicbors-5/+15
Set both `nuw` and `nsw` in slice size calculation There's an old note in the code to do this, and now that [LLVM-C has an API for it](https://github.com/llvm/llvm-project/blob/f0b8ff12519270adcfef93410abff76ab073476a/llvm/include/llvm-c/Core.h#L4403-L4408), we might as well. And it's been there since what looks like LLVM 17 https://github.com/llvm/llvm-project/commit/de9b6aa341d8951625d62ae3dac8670ebb3eb006 so doesn't even need to be conditional. (There's other places, like `RawVecInner` or `Layout`, that might want to do things like this too, but I'll leave those for a future PR.)
2025-02-14Add new ui test for returning an Fn trait that returns impl TraitXelph-0/+37
Change description from compiletest to regression test Co-authored-by: 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> Improve test name, location, and description Update tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs Co-authored-by: waffle <waffle.lapkin@gmail.com>
2025-02-14Auto merge of #136735 - scottmcm:transmute-nonnull, r=oli-obkbors-68/+121
`transmute` should also assume non-null pointers Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-269/+269
2025-02-14Consider add-prefix replacements tooMichael Goulet-327/+218
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-534/+356
2025-02-14Auto merge of #137010 - workingjubilee:rollup-g00c07v, r=workingjubileebors-2/+20
Rollup of 9 pull requests Successful merges: - #135439 (Make `-O` mean `OptLevel::Aggressive`) - #136460 (Simplify `rustc_span` `analyze_source_file`) - #136904 (add `IntoBounds` trait) - #136908 ([AIX] expect `EINVAL` for `pthread_mutex_destroy`) - #136924 (Add profiling of bootstrap commands using Chrome events) - #136951 (Use the right binder for rebinding `PolyTraitRef`) - #136981 (ci: switch loongarch jobs to free runners) - #136992 (Update backtrace) - #136993 ([cg_llvm] Remove dead error message) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-13Rollup merge of #136951 - compiler-errors:clause-binder, r=lqdJubilee-0/+18
Use the right binder for rebinding `PolyTraitRef` Fixes #136940 I committed a slightly different test which still demonstrates the issue.
2025-02-13Set both `nuw` and `nsw` in slice size calculationScott McMurray-5/+15
There's an old note in the code to do this, and now that LLVM-C has an API for it, we might as well.
2025-02-13Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`Christian Poveda-0/+269
2025-02-13Rollup merge of #136957 - Zalathar:counters, r=oli-obkJubilee-218/+221
coverage: Eliminate more counters by giving them to unreachable nodes When preparing a function's coverage counters and metadata during codegen, any part of the original coverage graph that was removed by MIR optimizations can be treated as having an execution count of zero. Somewhat counter-intuitively, if we give those unreachable nodes a _higher_ priority for receiving physical counters (instead of counter expressions), that ends up reducing the total number of physical counters needed. This works because if a node is unreachable, we don't actually create a physical counter for it. Instead that node gets a fixed zero counter, and any other node that would have relied on that physical counter in its counter expression can just ignore that term completely.
2025-02-13Rollup merge of #136950 - notriddle:notriddle/svg-example-buttons, ↵Jubilee-0/+26
r=GuillaumeGomez rustdoc: use better, consistent SVG icons for scraped examples ## Screenshots ![](https://github.com/user-attachments/assets/f305fb20-5ded-428a-b0d0-04e8b7762769) ![](https://github.com/user-attachments/assets/5b9bee5e-74b9-447b-a19a-49f32b6bf218) ![image](https://github.com/user-attachments/assets/d855a8c8-dc24-44f9-a067-1e0f0654c28a) ![image](https://github.com/user-attachments/assets/71bca54a-0562-480a-8989-938acc351307) ## Description This continues two ongoing projects - Replacing ascii art with real icons that don't look like syntax, are understandable to people who're familiar with desktop computers and smart devices, and aren't ugly. - Using labels and tooltips to clarify these icons, when the limits of popular iconography hit us. In this case, I've added tooltips, because, unfortunately, there's not room for always-visible labels. r? ``@GuillaumeGomez``
2025-02-13Rollup merge of #136928 - lcnr:method-lookup-check-wf, r=compiler-errorsJubilee-133/+330
eagerly prove WF when resolving fully qualified paths fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/161. This hopefully shouldn't impact perf. I do think we need to deal with at least part of the fallout here, opening for vibes. r? ``@compiler-errors``
2025-02-13Rollup merge of #136895 - maurer:fix-enum-discr, r=nikicJubilee-2/+2
debuginfo: Set bitwidth appropriately in enum variant tags Previously, we unconditionally set the bitwidth to 128-bits, the largest an enum would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit enumerators, so this would also have occasionally resulted in truncated data. LLVM added support for 128-bit enumerators in llvm/llvm-project#125578 That patchset trusts the constant to describe how wide the variant tag is, so the high 64-bits of zeros are considered potentially load-bearing. As a result, we went from emitting tags that looked like: DW_AT_discr_value (0xfe) (because `dwarf::BestForm` selected `data1`) to emitting tags that looked like: DW_AT_discr_value (<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ) This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which: 1. Is probably closer to our intentions in terms of describing the data. 2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools. 3. Will result in smaller debug information.
2025-02-13Rollup merge of #136869 - chenyukang:yukang-fix-133713-let-binding, r=estebankJubilee-0/+51
Fix diagnostic when using = instead of : in let binding Fixes #133713 r? ``@estebank``
2025-02-14fallout :skull_emoji:lcnr-133/+291
2025-02-14eagerly prove WF when resolving fully qualified pathslcnr-0/+39
2025-02-13adjust derive_errorlcnr-33/+96
2025-02-13Make `-O` mean `-C opt-level=3`clubby789-2/+2
2025-02-13Auto merge of #136965 - jhpratt:rollup-bsnqvmf, r=jhprattbors-156/+161
Rollup of 8 pull requests Successful merges: - #134999 (Add cygwin target.) - #136559 (Resolve named regions when reporting type test failures in NLL) - #136660 (Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types) - #136858 (Parallel-compiler-related cleanup) - #136881 (cg_llvm: Reduce visibility of all functions in the llvm module) - #136888 (Always perform discr read for never pattern in EUV) - #136948 (Split out the `extern_system_varargs` feature) - #136949 (Fix import in bench for wasm) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-13Rollup merge of #136948 - workingjubilee:split-off-extern-system-varargs, ↵Jacob Pratt-36/+31
r=compiler-errors Split out the `extern_system_varargs` feature After the stabilization PR was opened, `extern "system"` functions were added to `extended_varargs_abi_support`. This has a number of questions regarding it that were not discussed and were somewhat surprising. It deserves to be considered as its own feature, separate from `extended_varargs_abi_support`. Tracking issue: - https://github.com/rust-lang/rust/issues/136946
2025-02-13Rollup merge of #136888 - compiler-errors:never-read, r=NadrierilJacob Pratt-0/+16
Always perform discr read for never pattern in EUV Always perform a read of `!` discriminants to ensure that it's captured by closures in expr use visitor Fixes #136852 r? Nadrieril or reassign
2025-02-13Rollup merge of #136660 - compiler-errors:BikeshedGuaranteedNoDrop, r=lcnrJacob Pratt-101/+76
Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types This PR introduces a new, internal-only trait called `BikeshedGuaranteedNoDrop`[^1] to faithfully model the field check that used to be implemented manually by `allowed_union_or_unsafe_field`. https://github.com/rust-lang/rust/blob/942db6782f4a28c55b0b75b38fd4394d0483390f/compiler/rustc_hir_analysis/src/check/check.rs#L84-L115 Copying over the doc comment from the trait: ```rust /// Marker trait for the types that are allowed in union fields, unsafe fields, /// and unsafe binder types. /// /// Implemented for: /// * `&T`, `&mut T` for all `T`, /// * `ManuallyDrop<T>` for all `T`, /// * tuples and arrays whose elements implement `BikeshedGuaranteedNoDrop`, /// * or otherwise, all types that are `Copy`. /// /// Notably, this doesn't include all trivially-destructible types for semver /// reasons. /// /// Bikeshed name for now. ``` As far as I am aware, there's no new behavior being guaranteed by this trait, since it operates the same as the manually implemented check. We could easily rip out this trait and go back to using the manually implemented check for union fields, however using a trait means that this code can be shared by WF for `unsafe<>` binders too. See the last commit. The only diagnostic changes are that this now fires false-negatives for fields that are ill-formed. I don't consider that to be much of a problem though. r? oli-obk [^1]: Please let's not bikeshed this name lol. There's no good name for `ValidForUnsafeFieldsUnsafeBindersAndUnionFields`.
2025-02-13Rollup merge of #136559 - ↵Jacob Pratt-17/+33
compiler-errors:resolve-regions-for-type-test-failure, r=BoxyUwU Resolve named regions when reporting type test failures in NLL Just a improvement tweak to an error message that I broke out of a bigger PR that I had to close lol
2025-02-13Rollup merge of #134999 - Berrysoft:dev/new-cygwin-target, ↵Jacob Pratt-2/+5
r=chenyukang,workingjubilee Add cygwin target. This PR simply adds cygwin target together with msys2 target, based on ````@ookiineko```` 's (the account has been deleted) [work](https://github.com/ookiineko-cygport/rust) on cygwin target. My full work is here: https://github.com/rust-lang/rust/compare/master...Berrysoft:rust:dev/cygwin I have succeeded in building a new rustc for cygwin target, and eventually distributed a new version of [fish-shell](https://github.com/Berrysoft/fish-shell/releases) (rewritten by Rust) for MSYS2. I will open a new PR to fix std if this PR is accepted.
2025-02-12`transmute` should also assume non-null pointersScott McMurray-68/+121
Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-13Implement lint for definition site item shadowing tooMichael Goulet-19/+172
2025-02-13Add more testsMichael Goulet-0/+172
2025-02-13Rework collapse method to work correctly with more complex supertrait graphsMichael Goulet-0/+219
2025-02-13Implement shadowing lintMichael Goulet-0/+100
2025-02-13Implement RFC 3624 supertrait_item_shadowingMichael Goulet-0/+79