about summary refs log tree commit diff
path: root/tests/ui
AgeCommit message (Collapse)AuthorLines
2025-08-15Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkovStuart Cook-24/+62
Change the desugaring of `assert!` for better error output In the desugaring of `assert!`, we now expand to a `match` expression instead of `if !cond {..}`. The span of incorrect conditions will point only at the expression, and not the whole `assert!` invocation. ``` error[E0308]: mismatched types --> $DIR/issue-14091.rs:2:13 | LL | assert!(1,1); | ^ expected `bool`, found integer ``` We no longer mention the expression needing to implement the `Not` trait. ``` error[E0308]: mismatched types --> $DIR/issue-14091-2.rs:15:13 | LL | assert!(x, x); | ^ expected `bool`, found `BytePos` ``` Now `assert!(val)` desugars to: ```rust match val { true => {}, _ => $crate::panic::panic_2021!(), } ``` Fix #122159.
2025-08-15Auto merge of #144591 - RalfJung:pattern-valtrees, r=BoxyUwUbors-2/+2
Patterns: represent constants as valtrees Const patterns are always valtrees now. Let's represent that in the types. We use `ty::Value` for this since it nicely packages value and type, and has some convenient methods. Cc `@Nadrieril` `@BoxyUwU`
2025-08-14Auto merge of #145407 - Kobzol:rollup-g6yhx82, r=Kobzolbors-196/+156
Rollup of 11 pull requests Successful merges: - rust-lang/rust#137872 (Include whitespace in "remove |" suggestion and make it hidden) - rust-lang/rust#144631 (Fix test intrinsic-raw_eq-const-bad for big-endian) - rust-lang/rust#145233 (cfg_select: Support unbraced expressions) - rust-lang/rust#145261 (Improve tracing in bootstrap) - rust-lang/rust#145324 (Rename and document `ONLY_HOSTS` in bootstrap) - rust-lang/rust#145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools) - rust-lang/rust#145379 (bootstrap: Support passing `--timings` to cargo) - rust-lang/rust#145397 (Rust documentation, use `rustc-dev-guide` :3) - rust-lang/rust#145398 (Use `default_field_values` in `Resolver`) - rust-lang/rust#145401 (cleanup: Remove useless `[T].iter().last()`) - rust-lang/rust#145403 (Adjust error message grammar to be less awkward) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-14mbe: Handle applying `macro_rules` derivesJosh Triplett-3/+217
Add infrastructure to apply a derive macro to arguments, consuming and returning a `TokenTree` only. Handle `SyntaxExtensionKind::MacroRules` when expanding a derive, if the macro's kinds support derive. Add tests covering various cases of `macro_rules` derives. Note that due to a pre-existing FIXME in `expand.rs`, derives are re-queued and some errors get emitted twice. Duplicate diagnostic suppression makes them not visible, but the FIXME should still get fixed.
2025-08-14mbe: Parse macro `derive` rulesJosh Triplett-6/+156
This handles various kinds of errors, but does not allow applying the derive yet. This adds the feature gate `macro_derive`.
2025-08-14Rollup merge of #145403 - shepmaster:grammar, r=estebankJakub Beránek-60/+60
Adjust error message grammar to be less awkward r? ``@estebank``
2025-08-14Rollup merge of #145233 - joshtriplett:cfg-select-expr, r=jieyouxuJakub Beránek-12/+38
cfg_select: Support unbraced expressions Tracking issue for `cfg_select`: rust-lang/rust#115585 When operating on expressions, `cfg_select!` can now handle expressions without braces. (It still requires braces for other things, such as items.) Expand the test coverage and documentation accordingly. --- I'm not sure whether deciding to extend `cfg_select!` in this way is T-lang or T-libs-api. I've labeled for both, with the request that both teams don't block on each other. :)
2025-08-14Rollup merge of #144631 - fneddy:fix_be_test_intrinsic_const_bad, ↵Jakub Beránek-8/+10
r=compiler-errors Fix test intrinsic-raw_eq-const-bad for big-endian The test fails on s390x and presumably other big-endian systems, due to print of raw values. To fix the tests remove the raw output values in the error note with normalize-stderr.
2025-08-14Rollup merge of #137872 - estebank:extra-vert, r=compiler-errorsJakub Beránek-116/+48
Include whitespace in "remove |" suggestion and make it hidden Tweak error rendering of patterns with an extra `|` on either end. Built on #137409. Only last commit is relevant. ? ``@compiler-errors``
2025-08-14Auto merge of #145085 - JonathanBrouwer:target_checking, r=jdonszelmannbors-2258/+2447
Rework target checking for built-in attributes This is a refactoring of target checking for built-in attributes. This PR has the following goals: - Only refactor the 80% of the attributes that are simple to target check. More complicated ones like `#[repr]` will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future. - No breaking changes. - This part of the codebase is not very well tested though, we can do a crater run if we want to be sure. - I've spotted quite a few weird situations (like I don't think an impl block should be deprecated?). We can propose fixing these to in a future PR Fixes https://github.com/rust-lang/rust/issues/143780 Fixes https://github.com/rust-lang/rust/issues/138510 I've split it in commits and left a description on some of the commits to help review. r? `@jdonszelmann`
2025-08-14Update autodiff tests for the new intrinsics implMarcelo Domínguez-0/+22
2025-08-14fixed diagnosticKivooeo-0/+83
2025-08-14Adjust error message grammar to be less awkwardJake Goulding-60/+60
2025-08-14Update uitestsJonathan Brouwer-2258/+2447
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-14Do not ICE on private type in field of unresolved structEsteban Küber-0/+30
2025-08-14resolve: Add one more test case for "binding is available in a different ↵Vadim Petrochenkov-2/+21
scope" help
2025-08-14it's not a borrow checker limitation :<lcnr-23/+23
2025-08-14fix alignment testEsteban Küber-1/+1
2025-08-14Auto merge of #144542 - sayantn:stabilize-sse4a-tbm, r=Amanieu,traviscrossbors-7/+1
Stabilize `sse4a` and `tbm` target features This PR stabilizes the feature flag `sse4a_target_feature` and `tbm_target_feature` (tracking issue rust-lang/rust#44839). # Public API The 2 `x86` target features `sse4a` and `tbm` Also, these were added in LLVM2.6 and LLVM3.4-rc1, respectively, and as the minimum LLVM required for rustc is LLVM19, we are safe in that front too! As all of the required tasks have been done (adding the target features to rustc, implementing their runtime detection in std_detect and implementing the associated intrinsics in core_arch), these target features can be stabilized now. The intrinsics were stabilized *long* ago, in 1.27.0 Reference PR: - https://github.com/rust-lang/reference/pull/1949 cc `@rust-lang/lang` `@rustbot` label I-lang-nominated r? lang
2025-08-14add regression testlcnr-0/+43
2025-08-14Add FnContext in parser for diagnosticxizheyin-46/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-08-14Add test suggest-self-in-bare-functionxizheyin-0/+87
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-08-14resolve prelude import at `build_reduced_graph` phaseLorrensP-2158466-18/+26
2025-08-14Print regions in `type_name`.Nicholas Nethercote-9/+13
Currently they are skipped, which is a bit weird, and it sometimes causes malformed output like `Foo<>` and `dyn Bar<, A = u32>`. Most regions are erased by the time `type_name` does its work. So all regions are now printed as `'_` in non-optional places. Not perfect, but better than the status quo. `c_name` is updated to trim lifetimes from MIR pass names, so that the `PASS_NAMES` sanity check still works. It is also renamed as `simplify_pass_type_name` and made non-const, because it doesn't need to be const and the non-const implementation is much shorter. The commit also renames `should_print_region` as `should_print_optional_region`, which makes it clearer that it only applies to some regions. Fixes #145168.
2025-08-14Rollup merge of #145372 - petrochenkov:noresmacpath, r=jackh726Guillaume Gomez-7/+23
resolve: Miscellaneous cleanups See individual commits. All noticed when reviewing recent PRs to name resolution.
2025-08-14Rollup merge of #145361 - xizheyin:145294, r=compiler-errorsGuillaume Gomez-0/+47
Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved Fixes rust-lang/rust#145294 I initially tried the desired suggestion in this issue, but since that suggestion occurs in the expected type, it is inappropriate to suggest for expected expressions (see other suggest methods in the same file). I believe that suppressing the incorrect suggestion is the more appropriate choice here. I opted for a slightly more general approach: when the expected type and actual type are the same ADT (e.g., both are Result in this example), we assume that code tend to compare the internal generic parameters(i.e. `Option<&str>` vs `Option<String>`, instead of `E = _` vs `Result<Option<String>>>`). When `E` is an unresolved infer type in the expected type (`_` in this example), we should not wrapp the actual type. Two commits show the difference. r? compiler
2025-08-14Rollup merge of #145323 - scrabsha:push-pqwvmznzzmpr, r=jdonszelmannGuillaume Gomez-24/+42
Port the `#[linkage]` attribute to the new attribute system r? `@jdonszelmann`
2025-08-14Rollup merge of #145250 - fmease:regr-test-for-attr-meta-ice, r=jdonszelmannGuillaume Gomez-0/+28
Add regression test for a former ICE involving helper attributes containing interpolated tokens Add regression test for rust-lang/rust#140612 from rust-lang/rust#140601 or rather rust-lang/rust#140859 that only added it to `stable` not `master`. Supersedes https://github.com/rust-lang/rust/pull/140584. r? `@jdonszelmann` or anyone
2025-08-14use ty::Value instead of manual pairs of types and valtreesRalf Jung-4/+2
2025-08-14pattern testing: store constants as valtreesRalf Jung-0/+2
2025-08-14PatKind: store constants as valtreesRalf Jung-2/+2
2025-08-14resolve: Improve code reuse in typo candidate collectionVadim Petrochenkov-6/+16
2025-08-14resolve: Do not show deprecated helper attributes in typo recommendationsVadim Petrochenkov-1/+7
Remove one FIXME, addressing it does not reduce the hacky-ness much, and the logic is going to be removed anyway together with the `legacy_derive_helpers` deprecation lint.
2025-08-14Add regression test for a former ICE involving helper attributes containing ↵León Orell Valerian Liehr-0/+28
interpolated tokens Co-authored-by: Jana Dönszelmann <jana@donsz.nl>
2025-08-13Auto merge of #144793 - petrochenkov:extprel3, r=davidtwcobors-18/+102
resolve: Split extern prelude into two scopes One scope for `extern crate` items and another for `--extern` options, with the former shadowing the latter. If in a single scope some things can overwrite other things, especially with ad hoc restrictions like `MacroExpandedExternCrateCannotShadowExternArguments`, then it's not really a single scope. So this PR splits `Scope::ExternPrelude` into two cleaner scopes. This is similar to how https://github.com/rust-lang/rust/pull/144131 splits module scope into two scopes for globs and non-globs, but simpler.
2025-08-14Stabilize `sse4a` and `tbm` target featuressayantn-7/+1
- remove some stabilized target features from `gate.rs`
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-24/+42
2025-08-13Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkovGuillaume Gomez-16/+86
Handle macros with multiple kinds, and improve errors (I recommend reviewing this commit-by-commit.) Switch to a bitflags `MacroKinds` to support macros with more than one kind Review everything that uses `MacroKind`, and switch anything that could refer to more than one kind to use `MacroKinds`. Add a new `SyntaxExtensionKind::MacroRules` for `macro_rules!` macros, using the concrete `MacroRulesMacroExpander` type, and have it track which kinds it can handle. Eliminate the separate optional `attr_ext`, now that a `SyntaxExtension` can handle multiple macro kinds. This also avoids the need to downcast when calling methods on `MacroRulesMacroExpander`, such as `get_unused_rule`. Integrate macro kind checking into name resolution's `sub_namespace_match`, so that we only find a macro if it's the right type, and eliminate the special-case hack for attributes. This allows detecting and report macro kind mismatches early, and more precisely, improving various error messages. In particular, this eliminates the case in `failed_to_match_macro` to check for a function-like invocation of a macro with no function-like rules. Instead, macro kind mismatches now result in an unresolved macro, and we detect this case in `unresolved_macro_suggestions`, which now carefully distinguishes between a kind mismatch and other errors. This also handles cases of forward-referenced attributes and cyclic attributes. ---- In this PR, I've minimally fixed up `rustdoc` so that it compiles and passes tests. This is just the minimal necessary fixes to handle the switch to `MacroKinds`, and it only works for macros that don't actually have multiple kinds. This will panic (with a `todo!`) if it encounters a macro with multiple kinds. rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros. I'd appreciate some help from a rustdoc expert on that. ---- r? ````````@petrochenkov````````
2025-08-13Rollup merge of #144761 - tgross35:cfg-outline-atomics, r=davidtwcoGuillaume Gomez-0/+1
aarch64: Make `outline-atomics` a known target feature This is a feature used by LLVM that is enabled for our `aarch64-linux` targets, which we would like to configure on in `std`. Thus, mark `outline-atomics` a known feature. It is left unstable for now.
2025-08-13Suppress wrapper suggestion when expected and actual ty are the same adt and ↵xizheyin-8/+0
the variant is unresolved Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-08-13Add test suggest-add-wrapper-issue-145294xizheyin-0/+55
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-08-13resolve: Improve diagnostics for ambiguities in extern preludeVadim Petrochenkov-10/+2
2025-08-13resolve: Split extern prelude into two scopesVadim Petrochenkov-18/+110
One for `--extern` options and another for `extern crate` items.
2025-08-13suggest using `pub(crate)` for E0364Makai-0/+8
2025-08-13add testlcnr-0/+17
2025-08-13rework `add_placeholder_from_predicate_note`lcnr-25/+35
2025-08-13also consider HR boundslcnr-0/+6
2025-08-13Auto merge of #144722 - ywxt:parallel-reproducibile, r=SparrowLiibors-52/+52
Fix parallel rustc not being reproducible due to unstable sorts of items Currently, A tuple `(DefId, SymbolName)` is used to determine the order of items in the final binary. However `DefId` is expected as non-deterministic, which leads to some not reproducible issues under parallel compilation. (See https://github.com/rust-lang/rust/issues/140425#issuecomment-3111802148) Theoretically, we don't need the sorting because the order of these items is already deterministic. However, codegen tests reply on the same order of items between in binary and source. So here we added a new option `codegen-source-order` to indicate whether sorting based on the order in source. For codegen tests, items are sorted according to the order in the source code, whereas in the normal path, no sorting is performed. Specially, for codegen tests, in preparation for parallel compilation potentially being enabled by default in the future, we use `Span` replacing `DefId` to make the order deterministic. This PR is purposed to fix rust-lang/rust#140425, but seemly works on rust-lang/rust#140413 too. This behavior hasn't added into any test until we have a test suit for the parallel frontend. (See https://github.com/rust-lang/rust/pull/143953) Related discussion: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fparallel-rustc/topic/Async.20closures.20not.20reproducible.28.23140425.29) https://github.com/rust-lang/rust/pull/144576 Update rust-lang/rust#113349 r? `@oli-obk` cc `@lqd` `@cramertj` `@matthiaskrgr` `@Zoxc` `@SparrowLii` `@bjorn3` `@cjgillot` `@joshtriplett`
2025-08-13fix scope of `super let` bindings within `if let`dianne-11/+11
They now use the enclosing temporary scope as their scope, regardless of which `ScopeData` was used to mark it.
2025-08-13add a test with incorrect `if let`-`super let` drop orderdianne-0/+112