From 5726000b2de7052915e808e42a75d6b60b3db540 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 29 Sep 2024 15:15:29 +0000 Subject: [PATCH 1/6] Copy correct path to clipboard for modules/keywords/primitives --- src/librustdoc/html/static/js/main.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 0d556e0a68274..984b0877d8de2 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1828,11 +1828,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm return; } but.onclick = () => { - const path = []; - onEachLazy(document.querySelectorAll(".rustdoc-breadcrumbs a"), a => { - path.push(a.textContent); - }); - path.push(document.querySelector("title").textContent.split(" ")[0]); + // Most page titles are ' in - Rust', except + // modules (which don't have the first part) and keywords/primitives + // (which don't have a module path) + const title = document.querySelector("title").textContent.replace(" - Rust", ""); + const [item, module] = title.split(" in "); + const path = [item]; + if (module !== undefined) { + path.unshift(module); + } copyContentToClipboard(path.join("::")); copyButtonAnimation(but); From 6d1a25ad7e8ce026a0a2b0c85046afc81ef529ba Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Mon, 30 Sep 2024 03:40:48 +0800 Subject: [PATCH 2/6] preserve brackets around if-lets and skip while-lets --- compiler/rustc_lint/src/if_let_rescope.rs | 29 +++++++++++++++++++++-- tests/ui/drop/lint-if-let-rescope.fixed | 15 +++++++++++- tests/ui/drop/lint-if-let-rescope.rs | 15 +++++++++++- tests/ui/drop/lint-if-let-rescope.stderr | 22 ++++++++++++++++- 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 229d0c3642174..8cb63d5cb0542 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -122,7 +122,11 @@ impl IfLetRescope { } let tcx = cx.tcx; let source_map = tcx.sess.source_map(); - let expr_end = expr.span.shrink_to_hi(); + let expr_end = match expr.kind { + hir::ExprKind::If(_cond, conseq, None) => conseq.span.shrink_to_hi(), + hir::ExprKind::If(_cond, _conseq, Some(alt)) => alt.span.shrink_to_hi(), + _ => return, + }; let mut add_bracket_to_match_head = match_head_needs_bracket(tcx, expr); let mut significant_droppers = vec![]; let mut lifetime_ends = vec![]; @@ -145,7 +149,10 @@ impl IfLetRescope { recovered: Recovered::No, }) = cond.kind { - let if_let_pat = expr.span.shrink_to_lo().between(init.span); + // Peel off round braces + let if_let_pat = source_map + .span_take_while(expr.span, |&ch| ch == '(' || ch.is_whitespace()) + .between(init.span); // The consequent fragment is always a block. let before_conseq = conseq.span.shrink_to_lo(); let lifetime_end = source_map.end_point(conseq.span); @@ -159,6 +166,8 @@ impl IfLetRescope { if ty_ascription.is_some() || !expr.span.can_be_used_for_suggestions() || !pat.span.can_be_used_for_suggestions() + || !if_let_pat.can_be_used_for_suggestions() + || !before_conseq.can_be_used_for_suggestions() { // Our `match` rewrites does not support type ascription, // so we just bail. @@ -240,6 +249,22 @@ impl<'tcx> LateLintPass<'tcx> for IfLetRescope { if let (Level::Allow, _) = cx.tcx.lint_level_at_node(IF_LET_RESCOPE, expr.hir_id) { return; } + if let hir::ExprKind::Loop(block, _label, hir::LoopSource::While, _span) = expr.kind + && let Some(value) = block.expr + && let hir::ExprKind::If(cond, _conseq, _alt) = value.kind + && let hir::ExprKind::Let(..) = cond.kind + { + // Recall that `while let` is lowered into this: + // ``` + // loop { + // if let .. { body } else { break; } + // } + // ``` + // There is no observable from the `{ break; }` block so the edition change + // means nothing substantial to this `while` statement. + self.skip.insert(value.hir_id); + return; + } if expr_parent_is_stmt(cx.tcx, expr.hir_id) && matches!(expr.kind, hir::ExprKind::If(_cond, _conseq, None)) { diff --git a/tests/ui/drop/lint-if-let-rescope.fixed b/tests/ui/drop/lint-if-let-rescope.fixed index f228783f88bc5..d579ce9823691 100644 --- a/tests/ui/drop/lint-if-let-rescope.fixed +++ b/tests/ui/drop/lint-if-let-rescope.fixed @@ -2,7 +2,7 @@ #![deny(if_let_rescope)] #![feature(if_let_rescope)] -#![allow(irrefutable_let_patterns)] +#![allow(irrefutable_let_patterns, unused_parens)] fn droppy() -> Droppy { Droppy @@ -68,4 +68,17 @@ fn main() { //~| HELP: the value is now dropped here in Edition 2024 //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } + + if (match droppy().get() { Some(_value) => { true } _ => { false }}) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + //~| HELP: the value is now dropped here in Edition 2024 + // do something + } + + while let Some(_value) = droppy().get() { + // Should not lint + break; + } } diff --git a/tests/ui/drop/lint-if-let-rescope.rs b/tests/ui/drop/lint-if-let-rescope.rs index 241fb897fce17..aab293cdcfc77 100644 --- a/tests/ui/drop/lint-if-let-rescope.rs +++ b/tests/ui/drop/lint-if-let-rescope.rs @@ -2,7 +2,7 @@ #![deny(if_let_rescope)] #![feature(if_let_rescope)] -#![allow(irrefutable_let_patterns)] +#![allow(irrefutable_let_patterns, unused_parens)] fn droppy() -> Droppy { Droppy @@ -68,4 +68,17 @@ fn main() { //~| HELP: the value is now dropped here in Edition 2024 //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } + + if (if let Some(_value) = droppy().get() { true } else { false }) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + //~| HELP: the value is now dropped here in Edition 2024 + // do something + } + + while let Some(_value) = droppy().get() { + // Should not lint + break; + } } diff --git a/tests/ui/drop/lint-if-let-rescope.stderr b/tests/ui/drop/lint-if-let-rescope.stderr index 25ca3cf1ca873..50801ae166ff0 100644 --- a/tests/ui/drop/lint-if-let-rescope.stderr +++ b/tests/ui/drop/lint-if-let-rescope.stderr @@ -131,5 +131,25 @@ help: a `match` with a single arm can preserve the drop order up to Edition 2021 LL | if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } { | ~~~~~ +++++++++++++++++ ++++++++ -error: aborting due to 5 previous errors +error: `if let` assigns a shorter lifetime since Edition 2024 + --> $DIR/lint-if-let-rescope.rs:72:12 + | +LL | if (if let Some(_value) = droppy().get() { true } else { false }) { + | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ + | | + | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #124085 +help: the value is now dropped here in Edition 2024 + --> $DIR/lint-if-let-rescope.rs:72:53 + | +LL | if (if let Some(_value) = droppy().get() { true } else { false }) { + | ^ +help: a `match` with a single arm can preserve the drop order up to Edition 2021 + | +LL | if (match droppy().get() { Some(_value) => { true } _ => { false }}) { + | ~~~~~ +++++++++++++++++ ~~~~ + + +error: aborting due to 6 previous errors From c5598d6a9e0e8a46775f2c69e1278efee8223425 Mon Sep 17 00:00:00 2001 From: Barrett Ray Date: Sun, 29 Sep 2024 15:28:11 -0500 Subject: [PATCH 3/6] fix(hir_analysis/wfcheck): don't leak {type error} avoid `{type error}` being leaked in user-facing messages, particularly when using the `adt_const_params` feature --- .../rustc_hir_analysis/src/check/wfcheck.rs | 17 ++-- .../suggest_feature_only_when_possible.stderr | 18 ++-- .../const-param-elided-lifetime.full.stderr | 8 +- .../const-param-elided-lifetime.min.stderr | 90 ++----------------- .../const-param-elided-lifetime.rs | 5 -- ...ram-type-depends-on-const-param.min.stderr | 4 +- .../const-generics/default-ty-closure.stderr | 2 +- .../float-generic.simple.stderr | 2 +- .../fn-const-param-call.min.stderr | 4 +- .../fn-const-param-infer.min.stderr | 2 +- ...ay-size-in-generic-struct-param.min.stderr | 2 +- .../generic_const_exprs/error_in_ty.stderr | 2 +- .../unevaluated-const-ice-119731.stderr | 2 +- .../ice-118285-fn-ptr-value.stderr | 2 +- ...ics-type_name-as-const-argument.min.stderr | 2 +- .../issues/issue-56445-1.min.stderr | 18 +--- .../ui/const-generics/issues/issue-56445-1.rs | 1 - .../issues/issue-62878.min.stderr | 2 +- .../issues/issue-63322-forbid-dyn.min.stderr | 2 +- .../issues/issue-68366.full.stderr | 2 +- .../issues/issue-68366.min.stderr | 2 +- .../issues/issue-68615-adt.min.stderr | 2 +- .../issues/issue-68615-array.min.stderr | 2 +- .../issues/issue-71169.min.stderr | 2 +- .../issues/issue-71381.min.stderr | 4 +- .../issues/issue-71382.min.stderr | 2 +- .../issues/issue-71611.min.stderr | 2 +- .../issues/issue-72352.min.stderr | 2 +- .../issues/issue-73491.min.stderr | 2 +- ...tic-reference-array-const-param.min.stderr | 2 +- .../issues/issue-74101.min.stderr | 4 +- .../issues/issue-74255.min.stderr | 2 +- .../issues/issue-74950.min.stderr | 8 +- .../issues/issue-75047.min.stderr | 2 +- .../const-generics/lifetime-in-const-param.rs | 1 - .../lifetime-in-const-param.stderr | 14 +-- .../min_const_generics/complex-types.stderr | 14 +-- .../ui/const-generics/nested-type.min.stderr | 2 +- .../const-generics/not_wf_param_in_rpitit.rs | 1 - .../not_wf_param_in_rpitit.stderr | 16 +--- tests/ui/const-generics/opaque_types.stderr | 2 +- .../projection-as-arg-const.stderr | 2 +- .../raw-ptr-const-param-deref.min.stderr | 4 +- .../raw-ptr-const-param.min.stderr | 2 +- .../slice-const-param-mismatch.min.stderr | 4 +- .../std/const-generics-range.min.stderr | 12 +-- ...te-const-param-static-reference.min.stderr | 2 +- .../type-dependent/issue-71348.min.stderr | 4 +- .../type-dependent/issue-71382.stderr | 2 +- tests/ui/consts/issue-103790.rs | 1 - tests/ui/consts/issue-103790.stderr | 16 +--- .../feature-gate-adt_const_params.stderr | 2 +- .../feature-gate-unsized-const-params.stderr | 2 +- .../generic-const-items/elided-lifetimes.rs | 1 - .../elided-lifetimes.stderr | 20 +---- .../wfcheck_err_leak_issue_118179.rs | 7 ++ .../wfcheck_err_leak_issue_118179.stderr | 11 +++ .../ui/lifetimes/unusual-rib-combinations.rs | 2 - .../lifetimes/unusual-rib-combinations.stderr | 32 +------ .../effects/mismatched_generic_args.stderr | 6 +- ...oj-ty-as-type-of-const-issue-125757.stderr | 2 +- ...st-region-infer-to-static-in-binder.stderr | 4 +- .../const_generic_type.infer.stderr | 2 +- .../const_generic_type.no_infer.stderr | 2 +- .../ice-unexpected-region-123863.stderr | 4 +- ...ce-hir-wf-check-anon-const-issue-122199.rs | 2 - ...ir-wf-check-anon-const-issue-122199.stderr | 44 +++------ ...ir-wf-check-anon-const-issue-122989.stderr | 4 +- 68 files changed, 147 insertions(+), 324 deletions(-) create mode 100644 tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs create mode 100644 tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index a71e14ce463f6..70b0b3f5788ed 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -961,13 +961,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(), hir_ty.span, "using raw pointers as const generic parameters is forbidden", ), - _ => tcx.dcx().struct_span_err( - hir_ty.span, - format!("`{}` is forbidden as the type of a const generic parameter", ty), - ), + _ => { + // Avoid showing "{type error}" to users. See #118179. + ty.error_reported()?; + + tcx.dcx().struct_span_err( + hir_ty.span, + format!( + "`{ty}` is forbidden as the type of a const generic parameter", + ), + ) + } }; - diag.note("the only supported types are integers, `bool` and `char`"); + diag.note("the only supported types are integers, `bool`, and `char`"); let cause = ObligationCause::misc(hir_ty.span, param.def_id); let adt_const_params_feature_string = diff --git a/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr index aafc0640dd2da..8c54aef36cac0 100644 --- a/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr +++ b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr @@ -4,7 +4,7 @@ error: `&'static mut ()` is forbidden as the type of a const generic parameter LL | fn uwu_0() {} | ^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `&'static u32` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:15:19 @@ -12,7 +12,7 @@ error: `&'static u32` is forbidden as the type of a const generic parameter LL | fn owo_0() {} | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `Meow` is forbidden as the type of a const generic parameter LL | fn meow_0() {} | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `&'static Meow` is forbidden as the type of a const generic parameter LL | fn meow_1() {} | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -56,7 +56,7 @@ error: `[Meow; 100]` is forbidden as the type of a const generic parameter LL | fn meow_2() {} | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `(Meow, u8)` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:29:20 @@ -64,7 +64,7 @@ error: `(Meow, u8)` is forbidden as the type of a const generic parameter LL | fn meow_3() {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `(Meow, String)` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:34:20 @@ -72,7 +72,7 @@ error: `(Meow, String)` is forbidden as the type of a const generic parameter LL | fn meow_4() {} | ^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `String` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:38:19 @@ -80,7 +80,7 @@ error: `String` is forbidden as the type of a const generic parameter LL | fn nya_0() {} | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `Vec` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:40:19 @@ -88,7 +88,7 @@ error: `Vec` is forbidden as the type of a const generic parameter LL | fn nya_1>() {} | ^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 9 previous errors diff --git a/tests/ui/const-generics/const-param-elided-lifetime.full.stderr b/tests/ui/const-generics/const-param-elided-lifetime.full.stderr index d6753a74f8574..34510f546c874 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.full.stderr +++ b/tests/ui/const-generics/const-param-elided-lifetime.full.stderr @@ -5,25 +5,25 @@ LL | struct A; | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:14:15 + --> $DIR/const-param-elided-lifetime.rs:13:15 | LL | impl A { | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:17:21 + --> $DIR/const-param-elided-lifetime.rs:15:21 | LL | fn foo(&self) {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:22:15 + --> $DIR/const-param-elided-lifetime.rs:19:15 | LL | impl B for A {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:26:17 + --> $DIR/const-param-elided-lifetime.rs:22:17 | LL | fn bar() {} | ^ explicit lifetime name needed here diff --git a/tests/ui/const-generics/const-param-elided-lifetime.min.stderr b/tests/ui/const-generics/const-param-elided-lifetime.min.stderr index 62267224738d0..34510f546c874 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.min.stderr +++ b/tests/ui/const-generics/const-param-elided-lifetime.min.stderr @@ -5,109 +5,29 @@ LL | struct A; | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:14:15 + --> $DIR/const-param-elided-lifetime.rs:13:15 | LL | impl A { | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:17:21 + --> $DIR/const-param-elided-lifetime.rs:15:21 | LL | fn foo(&self) {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:22:15 + --> $DIR/const-param-elided-lifetime.rs:19:15 | LL | impl B for A {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:26:17 + --> $DIR/const-param-elided-lifetime.rs:22:17 | LL | fn bar() {} | ^ explicit lifetime name needed here -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:9:19 - | -LL | struct A; - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:14:15 - | -LL | impl A { - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:22:15 - | -LL | impl B for A {} - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:26:17 - | -LL | fn bar() {} - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:17:21 - | -LL | fn foo(&self) {} - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/const-generics/const-param-elided-lifetime.rs b/tests/ui/const-generics/const-param-elided-lifetime.rs index e75073de98d30..b1cdb6a46c552 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.rs +++ b/tests/ui/const-generics/const-param-elided-lifetime.rs @@ -8,23 +8,18 @@ struct A; //~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&u8` is forbidden trait B {} impl A { //~^ ERROR `&` without an explicit lifetime name cannot be used here - //[min]~^^ ERROR `&u8` is forbidden fn foo(&self) {} //~^ ERROR `&` without an explicit lifetime name cannot be used here - //[min]~^^ ERROR `&u8` is forbidden } impl B for A {} //~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&u8` is forbidden fn bar() {} //~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&u8` is forbidden fn main() {} diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index fcc86b9ac33f2..18b8996326782 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -20,7 +20,7 @@ error: `[u8; N]` is forbidden as the type of a const generic parameter LL | pub struct Dependent([(); N]); | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -32,7 +32,7 @@ error: `[u8; N]` is forbidden as the type of a const generic parameter LL | pub struct SelfDependent; | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/default-ty-closure.stderr b/tests/ui/const-generics/default-ty-closure.stderr index 9c737c1a19def..3f6ca9aea4ee8 100644 --- a/tests/ui/const-generics/default-ty-closure.stderr +++ b/tests/ui/const-generics/default-ty-closure.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct X; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/float-generic.simple.stderr b/tests/ui/const-generics/float-generic.simple.stderr index 2999bce32d6ad..abc5e7c5a9926 100644 --- a/tests/ui/const-generics/float-generic.simple.stderr +++ b/tests/ui/const-generics/float-generic.simple.stderr @@ -4,7 +4,7 @@ error: `f32` is forbidden as the type of a const generic parameter LL | fn foo() {} | ^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/fn-const-param-call.min.stderr b/tests/ui/const-generics/fn-const-param-call.min.stderr index d37766b28c9ce..b5b809d278703 100644 --- a/tests/ui/const-generics/fn-const-param-call.min.stderr +++ b/tests/ui/const-generics/fn-const-param-call.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct Wrapper u32>; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/fn-const-param-call.rs:15:15 @@ -12,7 +12,7 @@ error: using function pointers as const generic parameters is forbidden LL | impl u32> Wrapper { | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/fn-const-param-infer.min.stderr b/tests/ui/const-generics/fn-const-param-infer.min.stderr index 4da503d344a1a..5e08f71a26701 100644 --- a/tests/ui/const-generics/fn-const-param-infer.min.stderr +++ b/tests/ui/const-generics/fn-const-param-infer.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct Checked bool>; | ^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0308]: mismatched types --> $DIR/fn-const-param-infer.rs:33:25 diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr index 1f67a5c09f134..a8b6f06ab1c2f 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr @@ -22,7 +22,7 @@ error: `Config` is forbidden as the type of a const generic parameter LL | struct B { | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr index 0e40255bcf59b..d822fa5894a5b 100644 --- a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr +++ b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr @@ -12,7 +12,7 @@ error: `[usize; x]` is forbidden as the type of a const generic parameter LL | pub struct A {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index 15d3c47258525..45be31c7ba35f 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -66,7 +66,7 @@ error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter LL | pub struct v17 { | ^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr b/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr index 46a8a975d50d7..4ff386c81635a 100644 --- a/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr +++ b/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct Checked bool>; | ^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr b/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr index 2a6d9f533174e..506f7d05fa63a 100644 --- a/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr +++ b/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr @@ -13,7 +13,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | trait Trait {} | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-56445-1.min.stderr b/tests/ui/const-generics/issues/issue-56445-1.min.stderr index ff0a1bfc0b555..86eb57355bd61 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.min.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.min.stderr @@ -6,22 +6,6 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | = note: lifetime parameters may not be used in the type of const parameters -error: `&str` is forbidden as the type of a const generic parameter - --> $DIR/issue-56445-1.rs:9:25 - | -LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^^^^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-56445-1.rs b/tests/ui/const-generics/issues/issue-56445-1.rs index 53aab40b0ad4a..681e0e147cfc8 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.rs +++ b/tests/ui/const-generics/issues/issue-56445-1.rs @@ -8,6 +8,5 @@ use std::marker::PhantomData; struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); //~^ ERROR: the type of const parameters must not depend on other generic parameters -//[min]~| ERROR: `&str` is forbidden as the type of a const generic parameter impl Bug<'_, ""> {} diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr index 5205726d73845..bd17d70a50ba5 100644 --- a/tests/ui/const-generics/issues/issue-62878.min.stderr +++ b/tests/ui/const-generics/issues/issue-62878.min.stderr @@ -12,7 +12,7 @@ error: `[u8; N]` is forbidden as the type of a const generic parameter LL | fn foo() {} | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr index 101ca456cd90f..f14485a4976e7 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr @@ -4,7 +4,7 @@ error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic LL | fn test() { | ^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68366.full.stderr b/tests/ui/const-generics/issues/issue-68366.full.stderr index 3363a895e4725..caed3c1bf3f7d 100644 --- a/tests/ui/const-generics/issues/issue-68366.full.stderr +++ b/tests/ui/const-generics/issues/issue-68366.full.stderr @@ -4,7 +4,7 @@ error: `Option` is forbidden as the type of a const generic parameter LL | struct Collatz>; | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68366.min.stderr b/tests/ui/const-generics/issues/issue-68366.min.stderr index 276f91e76dd42..10b5a06682f53 100644 --- a/tests/ui/const-generics/issues/issue-68366.min.stderr +++ b/tests/ui/const-generics/issues/issue-68366.min.stderr @@ -13,7 +13,7 @@ error: `Option` is forbidden as the type of a const generic parameter LL | struct Collatz>; | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68615-adt.min.stderr b/tests/ui/const-generics/issues/issue-68615-adt.min.stderr index 2f95eef98c01e..d25b34435ede8 100644 --- a/tests/ui/const-generics/issues/issue-68615-adt.min.stderr +++ b/tests/ui/const-generics/issues/issue-68615-adt.min.stderr @@ -4,7 +4,7 @@ error: `[usize; 0]` is forbidden as the type of a const generic parameter LL | struct Const {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68615-array.min.stderr b/tests/ui/const-generics/issues/issue-68615-array.min.stderr index 6d18f8195d242..60cbc9b4eab14 100644 --- a/tests/ui/const-generics/issues/issue-68615-array.min.stderr +++ b/tests/ui/const-generics/issues/issue-68615-array.min.stderr @@ -4,7 +4,7 @@ error: `[usize; 0]` is forbidden as the type of a const generic parameter LL | struct Foo {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr index 94d11f969ff8a..2ecbc3379516b 100644 --- a/tests/ui/const-generics/issues/issue-71169.min.stderr +++ b/tests/ui/const-generics/issues/issue-71169.min.stderr @@ -12,7 +12,7 @@ error: `[u8; LEN]` is forbidden as the type of a const generic parameter LL | fn foo() {} | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr index e16d3b7a8a469..38d2cbe636831 100644 --- a/tests/ui/const-generics/issues/issue-71381.min.stderr +++ b/tests/ui/const-generics/issues/issue-71381.min.stderr @@ -20,7 +20,7 @@ error: using function pointers as const generic parameters is forbidden LL | pub fn call_me(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:23:19 @@ -28,7 +28,7 @@ error: using function pointers as const generic parameters is forbidden LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/issues/issue-71382.min.stderr b/tests/ui/const-generics/issues/issue-71382.min.stderr index 0c58b10c0b7c8..f70e1733a9770 100644 --- a/tests/ui/const-generics/issues/issue-71382.min.stderr +++ b/tests/ui/const-generics/issues/issue-71382.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | fn test(&self) { | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-71611.min.stderr b/tests/ui/const-generics/issues/issue-71611.min.stderr index b01936f4d2513..7252bfd1d6a72 100644 --- a/tests/ui/const-generics/issues/issue-71611.min.stderr +++ b/tests/ui/const-generics/issues/issue-71611.min.stderr @@ -12,7 +12,7 @@ error: using function pointers as const generic parameters is forbidden LL | fn func(outer: A) { | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-72352.min.stderr b/tests/ui/const-generics/issues/issue-72352.min.stderr index ede0faec7c67c..17ccfa8a0dabb 100644 --- a/tests/ui/const-generics/issues/issue-72352.min.stderr +++ b/tests/ui/const-generics/issues/issue-72352.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | unsafe fn unsafely_do_the_thing usize>(ptr: *const c_char) -> usize { | ^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-73491.min.stderr b/tests/ui/const-generics/issues/issue-73491.min.stderr index 8fdd65894ef2b..2cdbeea2fd6e5 100644 --- a/tests/ui/const-generics/issues/issue-73491.min.stderr +++ b/tests/ui/const-generics/issues/issue-73491.min.stderr @@ -4,7 +4,7 @@ error: `[u32; LEN]` is forbidden as the type of a const generic parameter LL | fn hoge() {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr b/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr index cba03b1cb1f0f..256636c0628cd 100644 --- a/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr +++ b/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr @@ -4,7 +4,7 @@ error: `&'static [u32]` is forbidden as the type of a const generic parameter LL | fn a() {} | ^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-74101.min.stderr b/tests/ui/const-generics/issues/issue-74101.min.stderr index 236556addcefd..65fb51d7df99f 100644 --- a/tests/ui/const-generics/issues/issue-74101.min.stderr +++ b/tests/ui/const-generics/issues/issue-74101.min.stderr @@ -4,7 +4,7 @@ error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter LL | fn test() {} | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter LL | struct Foo; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-74255.min.stderr b/tests/ui/const-generics/issues/issue-74255.min.stderr index 800902860a763..3b30227a9a673 100644 --- a/tests/ui/const-generics/issues/issue-74255.min.stderr +++ b/tests/ui/const-generics/issues/issue-74255.min.stderr @@ -4,7 +4,7 @@ error: `IceEnum` is forbidden as the type of a const generic parameter LL | fn ice_struct_fn() {} | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-74950.min.stderr b/tests/ui/const-generics/issues/issue-74950.min.stderr index 086176d9959c7..22537af786b14 100644 --- a/tests/ui/const-generics/issues/issue-74950.min.stderr +++ b/tests/ui/const-generics/issues/issue-74950.min.stderr @@ -4,7 +4,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | @@ -29,7 +29,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | @@ -42,7 +42,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | diff --git a/tests/ui/const-generics/issues/issue-75047.min.stderr b/tests/ui/const-generics/issues/issue-75047.min.stderr index f2cc76b9bed03..d78ab6718201a 100644 --- a/tests/ui/const-generics/issues/issue-75047.min.stderr +++ b/tests/ui/const-generics/issues/issue-75047.min.stderr @@ -4,7 +4,7 @@ error: `[u8; Bar::::value()]` is forbidden as the type of a const generic p LL | struct Foo::value()]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/lifetime-in-const-param.rs b/tests/ui/const-generics/lifetime-in-const-param.rs index be90dbb213eef..ce6b52b229f4b 100644 --- a/tests/ui/const-generics/lifetime-in-const-param.rs +++ b/tests/ui/const-generics/lifetime-in-const-param.rs @@ -4,6 +4,5 @@ struct S2<'b>(&'b ()); struct S<'a, const N: S2>(&'a ()); //~^ ERROR missing lifetime specifier [E0106] -//~| ERROR `S2<'_>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/lifetime-in-const-param.stderr b/tests/ui/const-generics/lifetime-in-const-param.stderr index 4096725c52a1b..7c9d27c1e284e 100644 --- a/tests/ui/const-generics/lifetime-in-const-param.stderr +++ b/tests/ui/const-generics/lifetime-in-const-param.stderr @@ -4,18 +4,6 @@ error[E0106]: missing lifetime specifier LL | struct S<'a, const N: S2>(&'a ()); | ^^ expected named lifetime parameter -error: `S2<'_>` is forbidden as the type of a const generic parameter - --> $DIR/lifetime-in-const-param.rs:5:23 - | -LL | struct S<'a, const N: S2>(&'a ()); - | ^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/const-generics/min_const_generics/complex-types.stderr b/tests/ui/const-generics/min_const_generics/complex-types.stderr index 0211770f9e51b..bca68982c399d 100644 --- a/tests/ui/const-generics/min_const_generics/complex-types.stderr +++ b/tests/ui/const-generics/min_const_generics/complex-types.stderr @@ -4,7 +4,7 @@ error: `[u8; 0]` is forbidden as the type of a const generic parameter LL | struct Foo; | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `()` is forbidden as the type of a const generic parameter LL | struct Bar; | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `No` is forbidden as the type of a const generic parameter LL | struct Fez; | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `&'static u8` is forbidden as the type of a const generic parameter LL | struct Faz; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -56,7 +56,7 @@ error: `!` is forbidden as the type of a const generic parameter LL | struct Fiz; | ^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `()` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:20:19 @@ -64,7 +64,7 @@ error: `()` is forbidden as the type of a const generic parameter LL | enum Goo { A, B } | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -76,7 +76,7 @@ error: `()` is forbidden as the type of a const generic parameter LL | union Boo { a: () } | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index 0da2b30e3f1a9..8696be3faf37b 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -29,7 +29,7 @@ LL | | LL | | }]>; | |__^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.rs b/tests/ui/const-generics/not_wf_param_in_rpitit.rs index 5471dc9022f90..eb672194340e8 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.rs +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.rs @@ -6,7 +6,6 @@ trait Trait { //~| ERROR: the trait `Trait` cannot be made into an object //~| ERROR: the trait `Trait` cannot be made into an object //~| ERROR: the trait `Trait` cannot be made into an object - //~| ERROR: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| ERROR: trait objects must include the `dyn` keyword async fn a() {} } diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr index 82e251f1306c2..ade40550c7389 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr @@ -25,7 +25,7 @@ LL | trait Trait { | ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/not_wf_param_in_rpitit.rs:11:14 + --> $DIR/not_wf_param_in_rpitit.rs:10:14 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -48,7 +48,7 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/not_wf_param_in_rpitit.rs:11:14 + --> $DIR/not_wf_param_in_rpitit.rs:10:14 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -64,14 +64,6 @@ help: alternatively, consider constraining `a` so it does not apply to trait obj LL | async fn a() where Self: Sized {} | +++++++++++++++++ -error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/not_wf_param_in_rpitit.rs:3:22 - | -LL | trait Trait { - | ^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/not_wf_param_in_rpitit.rs:3:13 | @@ -79,7 +71,7 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/not_wf_param_in_rpitit.rs:11:14 + --> $DIR/not_wf_param_in_rpitit.rs:10:14 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -107,7 +99,7 @@ help: add `dyn` keyword before this trait LL | trait Trait { | +++ -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0038, E0391, E0425, E0782. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/opaque_types.stderr b/tests/ui/const-generics/opaque_types.stderr index 3947d645fcbe2..847f1da16f612 100644 --- a/tests/ui/const-generics/opaque_types.stderr +++ b/tests/ui/const-generics/opaque_types.stderr @@ -74,7 +74,7 @@ error: `Foo` is forbidden as the type of a const generic parameter LL | fn foo() {} | ^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0391]: cycle detected when computing type of opaque `Foo::{opaque#0}` --> $DIR/opaque_types.rs:3:12 diff --git a/tests/ui/const-generics/projection-as-arg-const.stderr b/tests/ui/const-generics/projection-as-arg-const.stderr index 88672bce0a7ee..f6e7620db7d9b 100644 --- a/tests/ui/const-generics/projection-as-arg-const.stderr +++ b/tests/ui/const-generics/projection-as-arg-const.stderr @@ -4,7 +4,7 @@ error: `::Identity` is forbidden as the type of a const generic LL | pub fn foo::Identity>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr b/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr index 6027dbb01cddb..fca2966e3a30a 100644 --- a/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr +++ b/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr @@ -4,7 +4,7 @@ error: using raw pointers as const generic parameters is forbidden LL | struct Const; | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using raw pointers as const generic parameters is forbidden --> $DIR/raw-ptr-const-param-deref.rs:13:15 @@ -12,7 +12,7 @@ error: using raw pointers as const generic parameters is forbidden LL | impl Const

{ | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/raw-ptr-const-param.min.stderr b/tests/ui/const-generics/raw-ptr-const-param.min.stderr index c48eea069e0da..5694b12f2d52a 100644 --- a/tests/ui/const-generics/raw-ptr-const-param.min.stderr +++ b/tests/ui/const-generics/raw-ptr-const-param.min.stderr @@ -4,7 +4,7 @@ error: using raw pointers as const generic parameters is forbidden LL | struct Const; | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0308]: mismatched types --> $DIR/raw-ptr-const-param.rs:11:40 diff --git a/tests/ui/const-generics/slice-const-param-mismatch.min.stderr b/tests/ui/const-generics/slice-const-param-mismatch.min.stderr index 3b2410c989477..594f8b9b79a33 100644 --- a/tests/ui/const-generics/slice-const-param-mismatch.min.stderr +++ b/tests/ui/const-generics/slice-const-param-mismatch.min.stderr @@ -4,7 +4,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | struct ConstString; | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -20,7 +20,7 @@ error: `&'static [u8]` is forbidden as the type of a const generic parameter LL | struct ConstBytes; | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/std/const-generics-range.min.stderr b/tests/ui/const-generics/std/const-generics-range.min.stderr index 67f137cf1a077..fd23b9b248a06 100644 --- a/tests/ui/const-generics/std/const-generics-range.min.stderr +++ b/tests/ui/const-generics/std/const-generics-range.min.stderr @@ -4,7 +4,7 @@ error: `std::ops::Range` is forbidden as the type of a const generic para LL | struct _Range>; | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `RangeFrom` is forbidden as the type of a const generic parameter LL | struct _RangeFrom>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `RangeFull` is forbidden as the type of a const generic parameter LL | struct _RangeFull; | ^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `RangeInclusive` is forbidden as the type of a const generic param LL | struct _RangeInclusive>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -52,7 +52,7 @@ error: `RangeTo` is forbidden as the type of a const generic parameter LL | struct _RangeTo>; | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -64,7 +64,7 @@ error: `RangeToInclusive` is forbidden as the type of a const generic par LL | struct _RangeToInclusive>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr b/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr index cf236487cf0ec..911afa3391d16 100644 --- a/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr +++ b/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr @@ -4,7 +4,7 @@ error: `&'static ()` is forbidden as the type of a const generic parameter LL | struct Const; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr index 5aee282952aa2..8995c4158635f 100644 --- a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr @@ -12,7 +12,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | trait Get<'a, const N: &'static str> { | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a >::Target | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/type-dependent/issue-71382.stderr b/tests/ui/const-generics/type-dependent/issue-71382.stderr index 69fd6f1c7d53e..3830b1527c372 100644 --- a/tests/ui/const-generics/type-dependent/issue-71382.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71382.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | fn test u8>(&self) -> u8 { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-103790.rs b/tests/ui/consts/issue-103790.rs index d19115ede74bf..869a43e4018b3 100644 --- a/tests/ui/consts/issue-103790.rs +++ b/tests/ui/consts/issue-103790.rs @@ -6,6 +6,5 @@ struct S; //~| ERROR missing generics for struct `S` //~| ERROR cycle detected when computing type of `S::S` //~| ERROR `()` is forbidden as the type of a const generic parameter -//~| ERROR `S<{const error}, {const error}>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/consts/issue-103790.stderr b/tests/ui/consts/issue-103790.stderr index c671f078cb5c0..1515fa60a5c08 100644 --- a/tests/ui/consts/issue-103790.stderr +++ b/tests/ui/consts/issue-103790.stderr @@ -42,25 +42,13 @@ error: `()` is forbidden as the type of a const generic parameter LL | struct S; | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | -error: `S<{const error}, {const error}>` is forbidden as the type of a const generic parameter - --> $DIR/issue-103790.rs:4:32 - | -LL | struct S; - | ^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0107, E0391, E0403. For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr index 649e936888b22..18d514f8cb5f8 100644 --- a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr +++ b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr @@ -4,7 +4,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | struct Foo; | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr b/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr index 0a87f34f4f51f..85ca2f59cb639 100644 --- a/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr +++ b/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr @@ -4,7 +4,7 @@ error: `[u8]` is forbidden as the type of a const generic parameter LL | struct Foo; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/generic-const-items/elided-lifetimes.rs b/tests/ui/generic-const-items/elided-lifetimes.rs index cca73e2e81e8d..90899de5af618 100644 --- a/tests/ui/generic-const-items/elided-lifetimes.rs +++ b/tests/ui/generic-const-items/elided-lifetimes.rs @@ -9,7 +9,6 @@ where const I: &str = ""; //~^ ERROR `&` without an explicit lifetime name cannot be used here -//~| ERROR `&str` is forbidden as the type of a const generic parameter const B>: () = (); //~ ERROR `'_` cannot be used here diff --git a/tests/ui/generic-const-items/elided-lifetimes.stderr b/tests/ui/generic-const-items/elided-lifetimes.stderr index 85807a1b631a6..2b543d02b5d0f 100644 --- a/tests/ui/generic-const-items/elided-lifetimes.stderr +++ b/tests/ui/generic-const-items/elided-lifetimes.stderr @@ -16,27 +16,11 @@ LL | const I: &str = ""; | ^ explicit lifetime name needed here error[E0637]: `'_` cannot be used here - --> $DIR/elided-lifetimes.rs:14:18 + --> $DIR/elided-lifetimes.rs:13:18 | LL | const B>: () = (); | ^^ `'_` is a reserved lifetime name -error: `&str` is forbidden as the type of a const generic parameter - --> $DIR/elided-lifetimes.rs:10:18 - | -LL | const I: &str = ""; - | ^^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs new file mode 100644 index 0000000000000..856f7b622d7ef --- /dev/null +++ b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs @@ -0,0 +1,7 @@ +//! Regression test for #118179: `adt_const_params` feature shouldn't leak +//! `{type error}` in error messages. + +struct G>(T); +//~^ ERROR the type of const parameters must not depend on other generic parameters + +fn main() {} diff --git a/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr new file mode 100644 index 0000000000000..654004571dbbe --- /dev/null +++ b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr @@ -0,0 +1,11 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/wfcheck_err_leak_issue_118179.rs:4:26 + | +LL | struct G>(T); + | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/lifetimes/unusual-rib-combinations.rs b/tests/ui/lifetimes/unusual-rib-combinations.rs index 0708a00d37157..0e92b41ae1ee2 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.rs +++ b/tests/ui/lifetimes/unusual-rib-combinations.rs @@ -20,11 +20,9 @@ fn c() {} // Elided lifetime in path in ConstGeneric fn d() {} //~^ ERROR missing lifetime specifier -//~| ERROR `S<'_>` is forbidden as the type of a const generic parameter trait Foo<'a> {} struct Bar Foo<'a>)>; //~^ ERROR the type of const parameters must not depend on other generic parameters -//~| ERROR `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index ebf6f6ca403cb..b7effdc8d61d0 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -5,7 +5,7 @@ LL | fn d() {} | ^ expected named lifetime parameter error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/unusual-rib-combinations.rs:26:22 + --> $DIR/unusual-rib-combinations.rs:25:22 | LL | struct Bar Foo<'a>)>; | ^^ the type must not depend on the parameter `'a` @@ -40,35 +40,7 @@ error[E0308]: mismatched types LL | fn a() -> [u8; foo()] { | ^^^^^ expected `usize`, found `()` -error: `S<'_>` is forbidden as the type of a const generic parameter - --> $DIR/unusual-rib-combinations.rs:21:15 - | -LL | fn d() {} - | ^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter - --> $DIR/unusual-rib-combinations.rs:26:21 - | -LL | struct Bar Foo<'a>)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 8 previous errors +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`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr index 8c814295de465..8e12b40381fd2 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr @@ -22,7 +22,7 @@ error: `Dimension` is forbidden as the type of a const generic parameter LL | pub struct Quantity(S); | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `Dimension` is forbidden as the type of a const generic parameter LL | impl Add for Quantity {} | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -52,7 +52,7 @@ error: `Dimension` is forbidden as the type of a const generic parameter LL | pub fn add(x: Quantity) -> Quantity { | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr index 7094ee8c67ca0..8df76b296acd6 100644 --- a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr +++ b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr @@ -4,7 +4,7 @@ error: `::Type` is forbidden as the type of a const generic parame LL | struct Wrapper::Type> {} | ^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: the constant `C` is not of type `::Type` --> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:22 diff --git a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr index e0cbee88aa100..377dfc8b52916 100644 --- a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr +++ b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr @@ -10,7 +10,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct X; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/const-region-infer-to-static-in-binder.rs:4:20 @@ -18,7 +18,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct X; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr index 3b6999cabc416..b7999a695e7f3 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr @@ -4,7 +4,7 @@ error: `Bar` is forbidden as the type of a const generic parameter LL | async fn test() { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index 55a5a3d20006b..b526ab49d8d4a 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -45,7 +45,7 @@ error: `Bar` is forbidden as the type of a const generic parameter LL | async fn test() { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 4 previous errors diff --git a/tests/ui/typeck/ice-unexpected-region-123863.stderr b/tests/ui/typeck/ice-unexpected-region-123863.stderr index 0479f134a3897..742096f3861f6 100644 --- a/tests/ui/typeck/ice-unexpected-region-123863.stderr +++ b/tests/ui/typeck/ice-unexpected-region-123863.stderr @@ -4,7 +4,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | const fn concat_strs() -> &'static str { | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -20,7 +20,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | struct Inner; | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs index 3f43fbfc0cf41..53363319ba0e6 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs @@ -4,7 +4,6 @@ trait Trait { //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object - //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] @@ -15,7 +14,6 @@ trait Trait { //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| ERROR associated item referring to unboxed trait object for its own trait //~| ERROR the trait `Trait` cannot be made into an object - //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index 6b309c223afff..fefb788fac79c 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -1,5 +1,5 @@ error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:18 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:18 | LL | trait Trait { | - first use of `N` @@ -14,13 +14,13 @@ LL | trait Trait { | ^^^ not found in this scope error[E0423]: expected value, found builtin type `u32` - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:29 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:29 | LL | fn fnc(&self) -> Trait { | ^^^ not a value error[E0425]: cannot find value `bar` in this scope - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:25:9 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:23:9 | LL | bar | ^^^ not found in this scope @@ -54,13 +54,13 @@ LL | trait Trait { = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:12 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:12 | LL | fn fnc(&self) -> Trait { | ^^^^^^^^^^^^^^^^^^^^ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ @@ -73,7 +73,7 @@ LL | fn fnc(&self) -> Trait { | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:44 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:44 | LL | fn fnc(&self) -> Trait { | ^^^^^ @@ -106,7 +106,7 @@ LL | trait Trait { | ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -122,7 +122,7 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -131,16 +131,8 @@ LL | fn fnc(&self) -> Trait { | ^^^ ...because method `fnc` has generic type parameters = help: consider moving `fnc` to another trait -error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 - | -LL | trait Trait { - | ^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - error: associated item referring to unboxed trait object for its own trait - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:44 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:44 | LL | trait Trait { | ----- in this trait @@ -154,7 +146,7 @@ LL | fn fnc(&self) -> Self { | ~~~~ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ @@ -168,13 +160,13 @@ LL | fn fnc(&self) -> Trait { | +++ error[E0038]: the trait `Trait` cannot be made into an object - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -190,7 +182,7 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -200,15 +192,7 @@ LL | fn fnc(&self) -> Trait { = help: consider moving `fnc` to another trait = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 - | -LL | fn fnc(&self) -> Trait { - | ^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - -error: aborting due to 13 previous errors; 5 warnings emitted +error: aborting due to 11 previous errors; 5 warnings emitted Some errors have detailed explanations: E0038, E0391, E0403, E0423, E0425. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index d2b0e2d92e01f..f8905437c6ea6 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -73,7 +73,7 @@ error: `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic para LL | trait Foo> { | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:11 @@ -104,7 +104,7 @@ error: `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic para LL | trait Bar> {} | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 5 previous errors; 2 warnings emitted From 020bd6d323f20fa3c723320ee5b8484a8bcaa6cb Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 30 Sep 2024 11:15:05 +0200 Subject: [PATCH 4/6] Improve `--print=check-cfg` documentation --- .../src/compiler-flags/print-check-cfg.md | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md b/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md index ab63c986e856e..8d314aa62d4cc 100644 --- a/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md +++ b/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md @@ -4,23 +4,28 @@ The tracking issue for this feature is: [#125704](https://github.com/rust-lang/r ------------------------ -This option of the `--print` flag print the list of expected cfgs. +This option of the `--print` flag print the list of all the expected cfgs. -This is related to the `--check-cfg` flag which allows specifying arbitrary expected +This is related to the [`--check-cfg` flag][check-cfg] which allows specifying arbitrary expected names and values. -This print option works similarly to `--print=cfg` (modulo check-cfg specifics): - - *check_cfg syntax*: *output of --print=check-cfg* - - `cfg(windows)`: `windows` - - `cfg(feature, values("foo", "bar"))`: `feature="foo"` and `feature="bar"` - - `cfg(feature, values(none(), ""))`: `feature` and `feature=""` - - `cfg(feature, values(any()))`: `feature=any()` - - `cfg(feature, values())`: `feature=` - - `cfg(any())`: `any()` - - *nothing*: `any()=any()` +This print option works similarly to `--print=cfg` (modulo check-cfg specifics). + +| `--check-cfg` | `--print=check-cfg` | +|-----------------------------------|-----------------------------| +| `cfg(foo)` | `foo` | +| `cfg(foo, values("bar"))` | `foo="bar"` | +| `cfg(foo, values(none(), "bar"))` | `foo` & `foo="bar"` | +| | *check-cfg specific syntax* | +| `cfg(foo, values(any())` | `foo=any()` | +| `cfg(foo, values())` | `foo=` | +| `cfg(any())` | `any()` | +| *none* | `any()=any()` | To be used like this: ```bash rustc --print=check-cfg -Zunstable-options lib.rs ``` + +[check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html From 874d55cea8af386d23663dcea1821d9697e028ff Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 30 Sep 2024 13:05:44 +0300 Subject: [PATCH 5/6] enable compiler fingerprint logs in verbose mode Signed-off-by: onur-ozkan --- src/bootstrap/src/core/builder.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 47420f8fe72fb..122eb50dd946e 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -2012,6 +2012,11 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_BACKTRACE_ON_ICE", "1"); } + if self.is_verbose() { + // This provides very useful logs especially when debugging build cache-related stuff. + cargo.env("CARGO_LOG", "cargo::core::compiler::fingerprint=info"); + } + cargo.env("RUSTC_VERBOSE", self.verbosity.to_string()); // Downstream forks of the Rust compiler might want to use a custom libc to add support for From ed5443fcdf3b4d02a89aec929cd62aa97586096f Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Mon, 30 Sep 2024 22:21:45 +0800 Subject: [PATCH 6/6] apply suggestions --- compiler/rustc_lint/src/if_let_rescope.rs | 3 +- tests/ui/drop/lint-if-let-rescope.fixed | 17 ++++++++- tests/ui/drop/lint-if-let-rescope.rs | 17 ++++++++- tests/ui/drop/lint-if-let-rescope.stderr | 46 +++++++++++++++++++++-- 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 8cb63d5cb0542..8f643de836a02 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -260,7 +260,8 @@ impl<'tcx> LateLintPass<'tcx> for IfLetRescope { // if let .. { body } else { break; } // } // ``` - // There is no observable from the `{ break; }` block so the edition change + // There is no observable change in drop order on the overall `if let` expression + // given that the `{ break; }` block is trivial so the edition change // means nothing substantial to this `while` statement. self.skip.insert(value.hir_id); return; diff --git a/tests/ui/drop/lint-if-let-rescope.fixed b/tests/ui/drop/lint-if-let-rescope.fixed index d579ce9823691..199068d0fd265 100644 --- a/tests/ui/drop/lint-if-let-rescope.fixed +++ b/tests/ui/drop/lint-if-let-rescope.fixed @@ -1,7 +1,7 @@ //@ run-rustfix #![deny(if_let_rescope)] -#![feature(if_let_rescope)] +#![feature(if_let_rescope, stmt_expr_attributes)] #![allow(irrefutable_let_patterns, unused_parens)] fn droppy() -> Droppy { @@ -69,16 +69,29 @@ fn main() { //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } + #[rustfmt::skip] if (match droppy().get() { Some(_value) => { true } _ => { false }}) { //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 //~| WARN: this changes meaning in Rust 2024 - //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 // do something + } else if (((match droppy().get() { Some(_value) => { true } _ => { false }}))) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } while let Some(_value) = droppy().get() { // Should not lint break; } + + while (match droppy().get() { Some(_value) => { false } _ => { true }}) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + } } diff --git a/tests/ui/drop/lint-if-let-rescope.rs b/tests/ui/drop/lint-if-let-rescope.rs index aab293cdcfc77..4c043c0266cc4 100644 --- a/tests/ui/drop/lint-if-let-rescope.rs +++ b/tests/ui/drop/lint-if-let-rescope.rs @@ -1,7 +1,7 @@ //@ run-rustfix #![deny(if_let_rescope)] -#![feature(if_let_rescope)] +#![feature(if_let_rescope, stmt_expr_attributes)] #![allow(irrefutable_let_patterns, unused_parens)] fn droppy() -> Droppy { @@ -69,16 +69,29 @@ fn main() { //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } + #[rustfmt::skip] if (if let Some(_value) = droppy().get() { true } else { false }) { //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 //~| WARN: this changes meaning in Rust 2024 - //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 // do something + } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } while let Some(_value) = droppy().get() { // Should not lint break; } + + while (if let Some(_value) = droppy().get() { false } else { true }) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + } } diff --git a/tests/ui/drop/lint-if-let-rescope.stderr b/tests/ui/drop/lint-if-let-rescope.stderr index 50801ae166ff0..ef60d141b7988 100644 --- a/tests/ui/drop/lint-if-let-rescope.stderr +++ b/tests/ui/drop/lint-if-let-rescope.stderr @@ -132,7 +132,7 @@ LL | if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } { | ~~~~~ +++++++++++++++++ ++++++++ error: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/lint-if-let-rescope.rs:72:12 + --> $DIR/lint-if-let-rescope.rs:73:12 | LL | if (if let Some(_value) = droppy().get() { true } else { false }) { | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ @@ -142,7 +142,7 @@ LL | if (if let Some(_value) = droppy().get() { true } else { false }) { = warning: this changes meaning in Rust 2024 = note: for more information, see issue #124085 help: the value is now dropped here in Edition 2024 - --> $DIR/lint-if-let-rescope.rs:72:53 + --> $DIR/lint-if-let-rescope.rs:73:53 | LL | if (if let Some(_value) = droppy().get() { true } else { false }) { | ^ @@ -151,5 +151,45 @@ help: a `match` with a single arm can preserve the drop order up to Edition 2021 LL | if (match droppy().get() { Some(_value) => { true } _ => { false }}) { | ~~~~~ +++++++++++++++++ ~~~~ + -error: aborting due to 6 previous errors +error: `if let` assigns a shorter lifetime since Edition 2024 + --> $DIR/lint-if-let-rescope.rs:79:21 + | +LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { + | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ + | | + | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #124085 +help: the value is now dropped here in Edition 2024 + --> $DIR/lint-if-let-rescope.rs:79:62 + | +LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { + | ^ +help: a `match` with a single arm can preserve the drop order up to Edition 2021 + | +LL | } else if (((match droppy().get() { Some(_value) => { true } _ => { false }}))) { + | ~~~~~ +++++++++++++++++ ~~~~ + + +error: `if let` assigns a shorter lifetime since Edition 2024 + --> $DIR/lint-if-let-rescope.rs:91:15 + | +LL | while (if let Some(_value) = droppy().get() { false } else { true }) { + | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ + | | + | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #124085 +help: the value is now dropped here in Edition 2024 + --> $DIR/lint-if-let-rescope.rs:91:57 + | +LL | while (if let Some(_value) = droppy().get() { false } else { true }) { + | ^ +help: a `match` with a single arm can preserve the drop order up to Edition 2021 + | +LL | while (match droppy().get() { Some(_value) => { false } _ => { true }}) { + | ~~~~~ +++++++++++++++++ ~~~~ + + +error: aborting due to 8 previous errors