diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-06 21:29:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-06 21:29:32 +0200 |
| commit | 12d1b173fb4a125eb89637a25b193981be1b639e (patch) | |
| tree | 6fde41d15ede0327c67f3e268cee689c08216577 /tests/ui/lifetimes | |
| parent | 094b893f777db2a152ba478fb9b8d54f6d91bb4f (diff) | |
| parent | 02ea38cfff9b07be2366fb76bcd2f24ddb589df2 (diff) | |
| download | rust-12d1b173fb4a125eb89637a25b193981be1b639e.tar.gz rust-12d1b173fb4a125eb89637a25b193981be1b639e.zip | |
Rollup merge of #144977 - fmease:fortify-param-default-checks, r=compiler-errors
Fortify generic param default checks * Hard-reject instead of lint-reject type param defaults in generic assoc consts (GACs) (feature: `generic_const_items`). * In https://github.com/rust-lang/rust/pull/113522, I explicitly handled the free const item case and forgot about the assoc const one. * This led rustc to assume the default of emitting the deny-by-default lint `invalid_type_param_default`. * GCIs are unstable, thus we're not bound by backward compat * Hard-reject instead of lint-reject type param defaults in foreign items. * We already hard-reject generic params on foreign items, so this isn't a breaking change. * There's no reason why we need to lint-reject. * Refactor the way we determine where generic param defaults are allowed: * Don't default to emitting lint `invalid_type_param_defaults` for nodes that aren't explicitly handled but instead panic. * This would've caught my GAC oversight from above much earlier via fuzzing * Prevents us from accidentally stabilizing more invalid type param defaults in the future * Streamline the phrasing of the diagnostic
Diffstat (limited to 'tests/ui/lifetimes')
| -rw-r--r-- | tests/ui/lifetimes/unusual-rib-combinations.rs | 2 | ||||
| -rw-r--r-- | tests/ui/lifetimes/unusual-rib-combinations.stderr | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/ui/lifetimes/unusual-rib-combinations.rs b/tests/ui/lifetimes/unusual-rib-combinations.rs index 0e92b41ae1e..b3e9642332b 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.rs +++ b/tests/ui/lifetimes/unusual-rib-combinations.rs @@ -14,7 +14,7 @@ fn b<const C: u8()>() {} // Paren generic args in AnonymousReportError fn c<T = u8()>() {} //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait -//~| ERROR defaults for type parameters are only allowed in +//~| ERROR defaults for generic parameters are not allowed here //~| WARN this was previously accepted // Elided lifetime in path in ConstGeneric diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index 7373ca8cf84..bd68479c58c 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -22,7 +22,7 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait LL | fn c<T = u8()>() {} | ^^^^ only `Fn` traits may use parentheses -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/unusual-rib-combinations.rs:15:6 | LL | fn c<T = u8()>() {} @@ -43,7 +43,7 @@ error: aborting due to 6 previous errors Some errors have detailed explanations: E0106, E0214, E0308, E0770. For more information about an error, try `rustc --explain E0106`. Future incompatibility report: Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/unusual-rib-combinations.rs:15:6 | LL | fn c<T = u8()>() {} |
