about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-12-16Rollup merge of #134372 - jieyouxu:disable-flaky-test, r=NoratriebMatthias Krüger-0/+4
Disable `tests/ui/associated-consts/issue-93775.rs` on windows msvc This test seems to be quite flaky. See: - https://github.com/rust-lang/rust/issues/132111 - https://github.com/rust-lang/rust/issues/133432
2024-12-16Rollup merge of #134369 - antonok-edm:refering-referring, r=jieyouxuMatthias Krüger-6/+6
Update spelling of "referring" I noticed that `referring` was spelled incorrectly in the output of `unexpected 'cfg' condition name` warnings; it looks like it was also incorrectly spelled in a doc comment. I've update both instances.
2024-12-16Rollup merge of #134357 - Urgau:fn-ptr-134345, r=compiler-errorsMatthias Krüger-0/+16
Fix `trimmed_def_paths` ICE in the function ptr comparison lint This PR fixes an ICE with `trimmed_def_paths` ICE in the function ptr comparison lint, specifically when pretty-printing user types but then not using the resulting pretty-printing. Fixes #134345 r? `@saethlin`
2024-12-16Rollup merge of #134342 - matthiaskrgr:tests1512, r=compiler-errorsMatthias Krüger-0/+176
crashes: more tests try-job: aarch64-apple try-job: x86_64-msvc try-job: x86_64-gnu
2024-12-16Rollup merge of #134314 - compiler-errors:default-struct-value-const, r=estebankMatthias Krüger-18/+35
Make sure to use normalized ty for unevaluated const in default struct value This cleans up the way that we construct the `mir::Const::Unevaluated` for default struct values. We were previously using `from_unevaluated`, which doesn't normalize the type, and is really only used for inline assembly. Other codepaths (such as `ExprKind::NamedConst`) use the type from the body. Also, let's stop using `literal_operand`, which also is really not meant for calls other than for literal comparisons in pattern lowering. Also move all of the tests to a separate subdirectory so they don't need to have the same prefix on all the test files. Fixes #134298 r? estebank or reassign
2024-12-16Disable `tests\ui\associated-consts\issue-93775.rs` on windows msvc许杰友 Jieyou Xu (Joe)-0/+4
This test seems to be quite flaky. See: - https://github.com/rust-lang/rust/issues/132111 - https://github.com/rust-lang/rust/issues/133432
2024-12-15spell "referring" correctlyAnton Lazarev-6/+6
2024-12-15Fix trimmed_def_paths ICE in the function ptr comparison lintUrgau-0/+16
2024-12-15Auto merge of #131808 - jdonszelmann:hir-attributes, r=oli-obk,petrochenkovbors-3/+1
Hir attributes This PR needs some explanation, it's somewhat large. - This is step one as described in https://github.com/rust-lang/compiler-team/issues/796. I've added a new `hir::Attribute` which is a lowered version of `ast::Attribute`. Right now, this has few concrete effects, however every place that after this PR parses a `hir::Attribute` should later get a pre-parsed attribute as described in https://github.com/rust-lang/compiler-team/issues/796 and transitively https://github.com/rust-lang/rust/issues/131229. - an extension trait `AttributeExt` is added, which is implemented for both `ast::Attribute` and `hir::Atribute`. This makes `hir::Attributes` mostly compatible with code that used to parse `ast::Attribute`. All its methods are also added as inherent methods to avoid having to import the trait everywhere in the compiler. - Incremental can not not hash `ast::Attribute` at all.
2024-12-15Auto merge of #134349 - jieyouxu:rollup-zqn0jox, r=jieyouxubors-4/+13
Rollup of 4 pull requests Successful merges: - #134111 (Fix `--nocapture` for run-make tests) - #134329 (Add m68k_target_feature) - #134331 (bootstrap: make ./x test error-index work) - #134339 (Pass `TyCtxt` to early diagostics decoration) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-15Add hir::AttributeJonathan Dönszelmann-3/+1
2024-12-16Rollup merge of #134339 - Urgau:tcx-in-early-diag, r=jieyouxu许杰友 Jieyou Xu (Joe)-3/+3
Pass `TyCtxt` to early diagostics decoration This PR pass a `TyCtxt` to the early diagnostics decoration code so that diagnostics code that take advantage of (a very limited but still useful) `TyCtxt` in their note, help, suggestions, ... This is particulary useful for #133221 which wants to get the crate name of a `DefId`, which is possible with `tcx.crate_name(...)`. I highly recommend reviewing this PR commit by commit. r? `@jieyouxu`
2024-12-16Rollup merge of #134329 - taiki-e:m68k-target-feature, r=workingjubilee许杰友 Jieyou Xu (Joe)-1/+10
Add m68k_target_feature This adds the following unstable target features (tracking issue: https://github.com/rust-lang/rust/issues/134328): - isa-68000 - isa-68010 - isa-68020 - isa-68030 - isa-68040 - isa-68060 - isa-68881 - isa-68882 The feature names and implied features are match with [definitions in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/M68k/M68k.td#L21-L57). isa-68881 and isa-68882 are FPU ISA features. isa-68881 is needed to support input/output in floating-point regs in inline assembly. isa-68020 is needed to implement https://github.com/taiki-e/atomic-maybe-uninit/pull/28 more robustly. cc `@glaubitz` `@ricky26` (designated developers of [m68k-unknown-linux-gnu](https://doc.rust-lang.org/nightly/rustc/platform-support/m68k-unknown-linux-gnu.html#designated-developers)) r? workingjubilee `@rustbot` label +O-motorola68k +A-target-feature
2024-12-15Auto merge of #133417 - RalfJung:aarch64-float-abi, r=workingjubileebors-0/+24
reject aarch64 target feature toggling that would change the float ABI ~~Stacked on top of https://github.com/rust-lang/rust/pull/133099. Only the last two commits are new.~~ The first new commit lays the groundwork for separately controlling whether a feature may be enabled or disabled. The second commit uses that to make it illegal to *disable* the `neon` feature (which is only possible via `-Ctarget-feature`, and so the new check just adds a warning). Enabling the `neon` feature remains allowed on targets that don't disable `neon` or `fp-armv8`, which is all our built-in targets. This way, the entire PR is not a breaking change. Fixes https://github.com/rust-lang/rust/issues/131058 for hardfloat targets (together with https://github.com/rust-lang/rust/pull/133102 which fixed it for softfloat targets). Part of https://github.com/rust-lang/rust/issues/116344.
2024-12-15crashes: more testsMatthias Krüger-0/+176
2024-12-15Improve check-cfg Cargo macro diagnostic with crate nameUrgau-3/+3
2024-12-15Auto merge of #134117 - DianQK:gep-i8, r=oli-obkbors-0/+59
Modifies the index instruction from `gep [0 x %Type]` to `gep %Type` Fixes #133979. This PR modifies the index instruction from `gep [0 x %Type]` to `gep %Type`, which is the same with pointer offset calculation. This will help LLVM calculate various formats of GEP instructions. According to [[RFC] Replacing getelementptr with ptradd](https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699), we ultimately aim to canonicalize everything to `gep i8`. Based on the results from https://github.com/rust-lang/rust/pull/134117#issuecomment-2531717076, I think we still need to investigate some missing optimizations, so this PR is just a small step forward. r? compiler
2024-12-15Simplify the GEP instruction for indexDianQK-0/+59
2024-12-15Rollup merge of #134313 - compiler-errors:no-itib-def-id, r=oli-obkStuart Cook-0/+10
Don't make a def id for `impl_trait_in_bindings` The def collector is awkward, so for now just wrap let statements in a new `ImplTraitContext::InBinding` which tells `visit_ty` not to make a def id for the type. This will not generalize to other ITIB cases, like if we allow them in turbofishes (e.g. `foo::<impl Fn()>(|| {})`). Fixes #134307 r? oli-obk
2024-12-15Rollup merge of #133633 - jyn514:hide-linker-args, r=bjorn3,jyn514Stuart Cook-8/+52
don't show the full linker args unless `--verbose` is passed the linker arguments can be *very* long, especially for crates with many dependencies. often they are not useful. omit them unless the user specifically requests them. split out from https://github.com/rust-lang/rust/pull/119286. fixes https://github.com/rust-lang/rust/issues/109979. r? `@bjorn3` try-build: i686-mingw
2024-12-15Add m68k_target_featureTaiki Endo-1/+10
2024-12-15Auto merge of #134258 - bjorn3:no_public_specialization, r=petrochenkovbors-4/+14
Remove support for specializing ToString outside the standard library This is the only trait specializable outside of the standard library. Before stabilizing specialization we will probably want to remove support for this. It was originally made specializable to allow a more efficient ToString in libproc_macro back when this way the only way to get any data out of a TokenStream. We now support getting individual tokens, so proc macros no longer need to call it as often.
2024-12-14don't show the full linker args unless `--verbose` is passedjyn-8/+52
the linker arguments can be *very* long, especially for crates with many dependencies. some parts of them are not very useful. unless specifically requested: - omit object files specific to the current invocation - fold rlib files into a single braced argument (in shell expansion format) this shortens the output significantly without removing too much information.
2024-12-15Auto merge of #134318 - matthiaskrgr:rollup-jda0jkx, r=matthiaskrgrbors-28/+489
Rollup of 7 pull requests Successful merges: - #132939 (Suggest using deref in patterns) - #133293 (Updates Solaris target information, adds Solaris maintainer) - #133392 (Fix ICE when multiple supertrait substitutions need assoc but only one is provided) - #133986 (Add documentation for anonymous pipe module) - #134022 (Doc: Extend for tuples to be stabilized in 1.85.0) - #134259 (Clean up `infer_return_ty_for_fn_sig`) - #134264 (Arbitrary self types v2: Weak & NonNull diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Rollup merge of #134264 - adetaylor:weak-and-nonnull, r=compiler-errorsMatthias Krüger-0/+72
Arbitrary self types v2: Weak & NonNull diagnostics This builds on top of #134262 which is more urgent to review and merge first. I'll likely rebase this PR once that lands. This is the first part of the diagnostic enhancements planned for Arbitrary Self Types v2. Various types can be used as method receivers, such as `Rc<>`, `Box<>` and `Arc<>`. The arbitrary self types v2 work allows further types to be made method receivers by implementing the Receiver trait. With that in mind, it may come as a surprise to people when certain common types do not implement Receiver and thus cannot be used as a method receiver. The RFC for arbitrary self types v2 therefore proposes emitting specific lint hints for these cases: * `NonNull` * `Weak` * Raw pointers The code already emits a hint for this third case, in that it advises folks that the `arbitrary_self_types_pointers` feature may meet their need. This PR adds diagnostic hints for the `Weak` and `NonNull` cases. Tracking issue #44874 r? `@wesleywiser`
2024-12-14Rollup merge of #133392 - compiler-errors:object-sup, r=lcnrMatthias Krüger-12/+39
Fix ICE when multiple supertrait substitutions need assoc but only one is provided Dyn traits must have all of their associated types constrained either by: 1. writing them in the dyn trait itself as an associated type bound, like `dyn Iterator<Item = u32>`, 2. A supertrait bound, like `trait ConstrainedIterator: Iterator<Item = u32> {}`, then you may write `dyn ConstrainedIterator` which doesn't need to mention `Item`. However, the object type lowering code did not consider the fact that there may be multiple supertraits with different substitutions, so it just used the associated type's *def id* as a key for keeping track of which associated types are missing: https://github.com/rust-lang/rust/blob/1fc691e6ddc24506b5234d586a5c084eb767f1ad/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs#L131 This means that we can have missing associated types when there are mutliple supertraits with different substitutions and only one of them is constrained, like: ```rust trait Sup<T> { type Assoc: Default; } impl<T: Default> Sup<T> for () { type Assoc = T; } impl<T: Default, U: Default> Dyn<T, U> for () {} trait Dyn<A, B>: Sup<A, Assoc = A> + Sup<B> {} ``` The above example allows you to name `<dyn Dyn<i32, u32> as Sup<u32>>::Assoc` even though it is not possible to project since it's neither constrained by a manually written projection bound or a supertrait bound. This successfully type-checks, but leads to a codegen ICE since we are not able to project the associated type. This PR fixes the validation for checking that a dyn trait mentions all of its associated type bounds. This is theoretically a breaking change, since you could technically use that `dyn Dyn<A, B>` type mentionedin the example above without actually *projecting* to the bad associated type, but I don't expect it to ever be relevant to a user since it's almost certainly a bug. This is corroborated with the crater results[^crater], which show no failures[^unknown]. Crater: https://github.com/rust-lang/rust/pull/133392#issuecomment-2508769703 Fixes #133388 [^crater]: I cratered this originally with #133397, which is a PR that is stacked on top, then re-ran crater with just the failures from that PR. [^unknown]: If you look at the crater results, it shows all of the passes as "unknown". I believe this is a crater bug, since looking at the results manually shows them as passes.
2024-12-14Rollup merge of #132939 - uellenberg:suggest-deref, r=oli-obkMatthias Krüger-16/+378
Suggest using deref in patterns Fixes #132784 This changes the following code: ```rs use std::sync::Arc; fn main() { let mut x = Arc::new(Some(1)); match x { Some(_) => {} None => {} } } ``` to output ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | LL | match x { | - this expression has type `Arc<Option<{integer}>>` ... LL | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | LL | match *x { | ~~ ``` instead of ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | 4 | match x { | - this expression has type `Arc<Option<{integer}>>` 5 | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` ``` This makes it more obvious that a Deref is available, and gives a suggestion on how to use it in order to fix the issue at hand.
2024-12-14Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵bors-1626/+1330
r=davidtwco,RalfJung Bounds-check with PtrMetadata instead of Len in MIR Rather than emitting `Len(*_n)` in array index bounds checks, emit `PtrMetadata(copy _n)` instead -- with some asterisks for arrays and `&mut` that need it to be done slightly differently. We're getting pretty close to removing `Len` entirely, actually. I think just one more PR after this (for slice drop shims). r? mir
2024-12-14Arbitrary self types v2: Weak, NonNull hintsAdrian Taylor-0/+72
Various types can be used as method receivers, such as Rc<>, Box<> and Arc<>. The arbitrary self types v2 work allows further types to be made method receivers by implementing the Receiver trait. With that in mind, it may come as a surprise to people when certain common types do not implement Receiver and thus cannot be used as a method receiver. The RFC for arbitrary self types v2 therefore proposes emitting specific lint hints for these cases: * NonNull * Weak * Raw pointers The code already emits a hint for this third case, in that it advises folks that the `arbitrary_self_types_pointers` feature may meet their need. This PR adds diagnostic hints for the Weak and NonNull cases.
2024-12-14Auto merge of #134305 - matthiaskrgr:rollup-bja3lsz, r=matthiaskrgrbors-23/+324
Rollup of 6 pull requests Successful merges: - #133221 (Add external macros specific diagnostics for check-cfg) - #133386 (Update linux_musl base to dynamically link the crt by default) - #134191 (Make some types and methods related to Polonius + Miri public) - #134227 (Update wasi-sdk used to build WASI targets) - #134279 ((Re-)return adjustment target if adjust kind is never-to-any) - #134295 (Encode coroutine-closures in SMIR) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Don't make a def id for impl_trait_in_bindingsMichael Goulet-0/+10
2024-12-14Make sure to use normalized ty for unevaluated const for default struct valueMichael Goulet-0/+17
2024-12-14Move default-field-values tests into a subdirectoryMichael Goulet-18/+18
2024-12-14Rollup merge of #134295 - compiler-errors:smir-async-closure, r=oli-obkMatthias Krüger-0/+102
Encode coroutine-closures in SMIR Fixes #134246 r? oli-obk
2024-12-14Rollup merge of #134279 - jieyouxu:return-adjustment-target, r=compiler-errorsMatthias Krüger-8/+51
(Re-)return adjustment target if adjust kind is never-to-any This PR fixes #134162 where we ICE'd on ```rs fn main() { struct X; let _ = [X] == [panic!(); 2]; } ``` In https://github.com/rust-lang/rust/pull/121208#discussion_r1494187622, there was a change ```diff - if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { - let reported = self.dcx().span_delayed_bug( - expr.span, - "expression with never type wound up being adjusted", - ); - return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] { - target.to_owned() - } else { - Ty::new_error(self.tcx(), reported) - }; - } + if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { + self.dcx() + .span_bug(expr.span, "expression with never type wound up being adjusted"); + } ``` It turned out returning the adjustment target if the adjustment kind is `NeverToAny` is necessary, as otherwise we will go through a series of `delay_bug`s and eventually find that we constructed a `TyKind::Error` without having actually emitted an error. This PR addresses that by re-returning the adjustment target if the adjustment kind is `NeverToAny`, partially reverting this change from #121208. This PR has two commits: 1. The first commit adds a regression test for #134162, which will ICE (on stable 1.83.0, beta and nightly 2024-12-13). 2. The second commit is the partial revert, which will fix the ICE. cc `@nnethercote` FYI as this is related to #121208 changes. The changes from #121208 exposed that we lacked test coverage for the code pattern reported in #134162.
2024-12-14Rollup merge of #133386 - wesleywiser:update_musl_base_crt_default, r=jieyouxuMatthias Krüger-0/+62
Update linux_musl base to dynamically link the crt by default However, don't change the behavior of any existing targets at this time. For targets that used the old default, explicitly set `crt_static_default = true`. This makes it easier for new targets to use the correct defaults while leaving the changing of individual targets to future PRs. Related to https://github.com/rust-lang/compiler-team/issues/422
2024-12-14Rollup merge of #133221 - Urgau:check-cfg-macro-diag, r=jieyouxuMatthias Krüger-15/+109
Add external macros specific diagnostics for check-cfg This PR adds specific check-cfg diagnostics for unexpected cfg in external macros. As well as hiding the some of the Cargo specific help/suggestions as they distraction for external macros and are generally not the right solution. Follow-up to #132577 `@rustbot` label +L-unexpected_cfgs r? compiler
2024-12-14Auto merge of #134296 - matthiaskrgr:rollup-o0sxozj, r=matthiaskrgrbors-80/+99
Rollup of 6 pull requests Successful merges: - #132150 (Fix powerpc64 big-endian FreeBSD ABI) - #133942 (Clarify how to use `black_box()`) - #134081 (Try to evaluate constants in legacy mangling) - #134192 (Remove `Lexer`'s dependency on `Parser`.) - #134208 (coverage: Tidy up creation of covmap and covfun records) - #134211 (On Neutrino QNX, reduce the need to set archiver via environment variables) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Auto merge of #134185 - compiler-errors:impl-trait-in-bindings, r=oli-obkbors-0/+200
(Re-)Implement `impl_trait_in_bindings` This reimplements the `impl_trait_in_bindings` feature for local bindings. "`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference): ```rust let _: impl Fn(&u8) -> &u8 = |x| x; ``` They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes: ```rust trait Static: 'static {} impl<T> Static for T where T: 'static {} let local = 1; let x: impl Static = &local; //~^ ERROR `local` does not live long enough ``` r? oli-obk cc #63065 --- Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example: ```rust type TAIT = impl Display; let local = 0; let x: TAIT = &local; //~^ ERROR `local` does not live long enough ``` That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here. --- I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
2024-12-14Add a regression test for #134162许杰友 Jieyou Xu (Joe)-8/+51
2024-12-14reject aarch64 target feature toggling that would change the float ABIRalf Jung-0/+24
2024-12-14Auto merge of #134294 - matthiaskrgr:rollup-anh6io8, r=matthiaskrgrbors-25/+94
Rollup of 8 pull requests Successful merges: - #134252 (Fix `Path::is_absolute` on Hermit) - #134254 (Fix building `std` for Hermit after `c_char` change) - #134255 (Update includes in `/library/core/src/error.rs`.) - #134261 (Document the symbol Visibility enum) - #134262 (Arbitrary self types v2: adjust diagnostic.) - #134265 (Rename `ty_def_id` so people will stop using it by accident) - #134271 (Arbitrary self types v2: better feature gate test) - #134274 (Add check-pass test for `&raw`) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Rollup merge of #134192 - nnethercote:rm-Lexer-Parser-dep, r=compiler-errorsMatthias Krüger-77/+31
Remove `Lexer`'s dependency on `Parser`. Lexing precedes parsing, as you'd expect: `Lexer` creates a `TokenStream` and `Parser` then parses that `TokenStream`. But, in a horrendous violation of layering abstractions and common sense, `Lexer` depends on `Parser`! The `Lexer::unclosed_delim_err` method does some error recovery that relies on creating a `Parser` to do some post-processing of the `TokenStream` that the `Lexer` just created. This commit just removes `unclosed_delim_err`. This change removes `Lexer`'s dependency on `Parser`, and also means that `lex_token_tree`'s return value can have a more typical form. The cost is slightly worse error messages in two obscure cases, as shown in these tests: - tests/ui/parser/brace-in-let-chain.rs: there is slightly less explanation in this case involving an extra `{`. - tests/ui/parser/diff-markers/unclosed-delims{,-in-macro}.rs: the diff marker detection is no longer supported (because that detection is implemented in the parser). In my opinion this cost is outweighed by the magnitude of the code cleanup. r? ```````@chenyukang```````
2024-12-14Rollup merge of #134081 - oli-obk:push-prpsqxxynxnq, r=BoxyUwUMatthias Krüger-3/+68
Try to evaluate constants in legacy mangling Best reviewed commit by commit. It seems kind of odd to treat literals differently from unevaluated free constants. So let's evaluate those constants and only fall back to `_` rendering if that fails to result in an integral constant
2024-12-14Encode coroutine-closures in SMIRMichael Goulet-0/+102
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-0/+200
2024-12-14Rollup merge of #134274 - fmease:amp-raw-is-a-normal-borrow, r=NoratriebMatthias Krüger-0/+30
Add check-pass test for `&raw` `&raw` denotes a normal/non-raw borrow of the path `raw`, not the start of raw borrow since it's not followed by either `const` or `mut`. Ensure this (and variants) will never regress! When I saw the open diagnostic issue https://github.com/rust-lang/rust/issues/133231 (better parse error (recovery) on `&raw <expr>`), it made me think that we have to make sure that we will never commit too early/overzealously(†) when encountering the sequence `&raw`, even during parse error recovery! Modifying the parser to eagerly treat `&raw` as the start of a raw borrow expr only lead to a single UI test failing, namely [tests/ui/enum-discriminant/ptr_niche.rs](https://github.com/rust-lang/rust/blob/4847d6a9d07d4be9ba3196f6ad444af2d7bdde72/tests/ui/enum-discriminant/ptr_niche.rs). However, this is just coincidental — it didn't *intentionally* test this edge case of the grammar. --- †: With "eager" I mean something like: ```patch diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 0904a42d8a4..68d690fd602 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs `@@` -873,11 +873,16 `@@` fn error_remove_borrow_lifetime(&self, span: Span, lt_span: Span) { /// Parse `mut?` or `raw [ const | mut ]`. fn parse_borrow_modifiers(&mut self) -> (ast::BorrowKind, ast::Mutability) { - if self.check_keyword(kw::Raw) && self.look_ahead(1, Token::is_mutability) { + if self.eat_keyword(kw::Raw) { // `raw [ const | mut ]`. - let found_raw = self.eat_keyword(kw::Raw); - assert!(found_raw); - let mutability = self.parse_const_or_mut().unwrap(); + let mutability = self.parse_const_or_mut().unwrap_or_else(|| { + let span = self.prev_token.span; + self.dcx().emit_err(ExpectedMutOrConstInRawBorrowExpr { + span, + after_ampersand: span.shrink_to_hi(), + }); + ast::Mutability::Not + }); (ast::BorrowKind::Raw, mutability) } else { // `mut?` ``` --- r? compiler
2024-12-14Rollup merge of #134271 - adetaylor:feature-gate-test, r=wesleywiserMatthias Krüger-3/+42
Arbitrary self types v2: better feature gate test Slight improvement to the test for the `arbitrary_self_types_pointers` feature gate, to ensure it's independent of the `arbitrary_self_types` gate. Part of #44874 r? `@wesleywiser`
2024-12-14Rollup merge of #134262 - adetaylor:revert-diagnostics, r=compiler-errorsMatthias Krüger-22/+22
Arbitrary self types v2: adjust diagnostic. The recently landed PR #132961 to adjust arbitrary self types was a bit overenthusiastic, advising folks to use the new Receiver trait even before it's been stabilized. Revert to the older wording of the lint in such cases. Tracking issue #44874 r? ``@wesleywiser``
2024-12-14Rollup merge of #134256 - krtab:suggestion_overlapping, r=petrochenkovMatthias Krüger-5/+60
Use a more precise span in placeholder_type_error_diag Closes: https://github.com/rust-lang/rust/issues/123861