rust/tests
Matthias Krüger 7ab385e2e1
Rollup merge of #139854 - fmease:modern-diag-for-lt-in-ty, r=davidtwco
Improve parse errors for stray lifetimes in type position

While technically & syntactically speaking lifetimes do begin[^1] types in type contexts (this essentially excludes generic argument lists) and require a following `+` to form a complete type (`'a +` denotes a bare trait object type), the likelihood that a user meant to write a lifetime-prefixed bare trait object type in *modern* editions (Rust ≥2021) when placing a lifetime into a type context is incredibly low (they would need to add at least three tokens to turn it into a *semantically* well-formed TOT: `'a` → `dyn 'a + Trait`).

Therefore let's *lie* in modern editions (just like in PR https://github.com/rust-lang/rust/pull/131239, a precedent if you will) by stating "*expected type, found lifetime*" in such cases which is a lot more a approachable, digestible and friendly compared to "*lifetime in trait object type must be followed by `+`*" (as added in PR https://github.com/rust-lang/rust/pull/69760).

I've also added recovery for "ampersand-less" reference types (e.g., `'a ()`, `'a mut Ty`) in modern editions because it was trivial to do and I think it's not unlikely to occur in practice.

Fixes #133413.

[^1]: For example, in the context of decl macros, this implies that a lone `'a` always matches syntax fragment `ty` ("even if" there's a later macro matcher expecting syntax fragment `lifetime`). Rephrased, lifetimes (in type contexts) *commit* to the type parser.
2025-04-17 00:16:22 +02:00
..
assembly Auto merge of #136926 - wesleywiser:stabilize_dwarf-version, r=petrochenkov 2025-04-16 06:38:00 +00:00
auxiliary tests: use minicore more 2025-02-24 09:26:54 +00:00
codegen Rollup merge of #139718 - folkertdev:unsafe-attributes-earlier-editions, r=fmease 2025-04-13 23:57:40 -04:00
codegen-units Remove -Zinline-in-all-cgus and clean up CGU partitioning tests 2025-01-27 23:48:47 -05:00
coverage Update the minimum external LLVM to 19 2025-04-05 11:44:38 -07:00
coverage-run-rustdoc Update coverage-run-rustdoc output 2025-03-28 10:35:53 +01:00
crashes Normalize ADT fields in find_tails_for_unsizing 2025-04-14 16:51:00 +00:00
debuginfo replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
incremental UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
mir-opt Rollup merge of #139767 - compiler-errors:www, r=oli-obk 2025-04-14 18:15:32 +02:00
pretty Fix HIR pretty-printing of fns with just a variadic arg. 2025-04-15 10:41:10 +10:00
run-make Auto merge of #136926 - wesleywiser:stabilize_dwarf-version, r=petrochenkov 2025-04-16 06:38:00 +00:00
rustdoc replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
rustdoc-gui Add regression test for #139282 2025-04-07 17:28:46 +02:00
rustdoc-js rustdoc-search: add unbox flag to Result aliases 2025-04-11 11:36:40 -07:00
rustdoc-js-std rustdoc-search: add unbox flag to Result aliases 2025-04-11 11:36:40 -07:00
rustdoc-json rustdoc-json: Add test for #[automatically_derived] attribute 2025-03-31 20:42:49 +00:00
rustdoc-ui Auto merge of #138603 - xizheyin:issue-137405, r=chenyukang 2025-04-14 13:33:44 +00:00
ui Rollup merge of #139854 - fmease:modern-diag-for-lt-in-ty, r=davidtwco 2025-04-17 00:16:22 +02:00
ui-fulldeps Rollup merge of #139760 - petrochenkov:noerrpat2, r=jieyouxu 2025-04-13 23:57:41 -04:00
COMPILER_TESTS.md