Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

borrowck typeck children together with their root #138499

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -483,7 +483,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
half_open_range_patterns_in_slices,
"half-open range patterns in slices are unstable"
);
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
gate_all!(associated_const_equality, "associated const equality is incomplete");
gate_all!(yeet_expr, "`do yeet` expression is experimental");
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
11 changes: 5 additions & 6 deletions compiler/rustc_borrowck/src/consumers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! This file provides API for compiler consumers.
use rustc_hir::def_id::LocalDefId;
use rustc_index::{IndexSlice, IndexVec};
use rustc_index::IndexVec;
use rustc_middle::mir::{Body, Promoted};
use rustc_middle::ty::TyCtxt;

@@ -15,6 +15,7 @@ pub use super::polonius::legacy::{
RichLocation, RustcFacts,
};
pub use super::region_infer::RegionInferenceContext;
use crate::BorrowCheckRootCtxt;

/// Options determining the output behavior of [`get_body_with_borrowck_facts`].
///
@@ -97,11 +98,9 @@ pub struct BodyWithBorrowckFacts<'tcx> {
/// * Polonius is highly unstable, so expect regular changes in its signature or other details.
pub fn get_body_with_borrowck_facts(
tcx: TyCtxt<'_>,
def: LocalDefId,
def_id: LocalDefId,
options: ConsumerOptions,
) -> BodyWithBorrowckFacts<'_> {
let (input_body, promoted) = tcx.mir_promoted(def);
let input_body: &Body<'_> = &input_body.borrow();
let promoted: &IndexSlice<_, _> = &promoted.borrow();
*super::do_mir_borrowck(tcx, input_body, promoted, Some(options)).1.unwrap()
let mut root_cx = BorrowCheckRootCtxt::new(def_id);
*root_cx.do_mir_borrowck(tcx, def_id, Some(options)).1.unwrap()
}
549 changes: 319 additions & 230 deletions compiler/rustc_borrowck/src/lib.rs

Large diffs are not rendered by default.

19 changes: 6 additions & 13 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
@@ -6,16 +6,14 @@ use std::str::FromStr;
use std::{env, io};

use polonius_engine::{Algorithm, Output};
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::def_id::LocalDefId;
use rustc_index::IndexSlice;
use rustc_middle::mir::pretty::{PrettyPrintMirOptions, dump_mir_with_options};
use rustc_middle::mir::{
Body, ClosureOutlivesSubject, ClosureRegionRequirements, PassWhere, Promoted, create_dump_file,
dump_enabled, dump_mir,
};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt};
use rustc_middle::ty::{self, TyCtxt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
@@ -34,13 +32,12 @@ use crate::polonius::legacy::{
use crate::region_infer::RegionInferenceContext;
use crate::type_check::{self, MirTypeckResults};
use crate::universal_regions::UniversalRegions;
use crate::{BorrowckInferCtxt, polonius, renumber};
use crate::{BorrowCheckRootCtxt, BorrowckInferCtxt, polonius, renumber};

/// The output of `nll::compute_regions`. This includes the computed `RegionInferenceContext`, any
/// closure requirements to propagate, and any generated errors.
pub(crate) struct NllOutput<'tcx> {
pub regioncx: RegionInferenceContext<'tcx>,
pub opaque_type_values: FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
pub polonius_input: Option<Box<PoloniusFacts>>,
pub polonius_output: Option<Box<PoloniusOutput>>,
pub opt_closure_req: Option<ClosureRegionRequirements<'tcx>>,
@@ -79,6 +76,7 @@ pub(crate) fn replace_regions_in_mir<'tcx>(
///
/// This may result in errors being reported.
pub(crate) fn compute_regions<'a, 'tcx>(
root_cx: &mut BorrowCheckRootCtxt<'tcx>,
infcx: &BorrowckInferCtxt<'tcx>,
universal_regions: UniversalRegions<'tcx>,
body: &Body<'tcx>,
@@ -106,6 +104,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
opaque_type_values,
polonius_context,
} = type_check::type_check(
root_cx,
infcx,
body,
promoted,
@@ -180,11 +179,10 @@ pub(crate) fn compute_regions<'a, 'tcx>(
infcx.set_tainted_by_errors(guar);
}

let remapped_opaque_tys = regioncx.infer_opaque_types(infcx, opaque_type_values);
regioncx.infer_opaque_types(root_cx, infcx, opaque_type_values);

NllOutput {
regioncx,
opaque_type_values: remapped_opaque_tys,
polonius_input: polonius_facts.map(Box::new),
polonius_output,
opt_closure_req: closure_region_requirements,
@@ -300,7 +298,6 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
body: &Body<'tcx>,
regioncx: &RegionInferenceContext<'tcx>,
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
opaque_type_values: &FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
diagnostics_buffer: &mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
) {
let tcx = infcx.tcx;
@@ -317,7 +314,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
// better.

let def_span = tcx.def_span(body.source.def_id());
let mut err = if let Some(closure_region_requirements) = closure_region_requirements {
let err = if let Some(closure_region_requirements) = closure_region_requirements {
let mut err = infcx.dcx().struct_span_note(def_span, "external requirements");

regioncx.annotate(tcx, &mut err);
@@ -343,10 +340,6 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
err
};

if !opaque_type_values.is_empty() {
err.note(format!("Inferred opaque type values:\n{opaque_type_values:#?}"));
}

diagnostics_buffer.buffer_non_error(err);
}

40 changes: 10 additions & 30 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ use rustc_trait_selection::traits::ObligationCtxt;
use tracing::{debug, instrument};

use super::RegionInferenceContext;
use crate::BorrowCheckRootCtxt;
use crate::session_diagnostics::{LifetimeMismatchOpaqueParam, NonGenericOpaqueTypeParam};
use crate::universal_regions::RegionClassification;

@@ -62,13 +63,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
///
/// [rustc-dev-guide chapter]:
/// https://rustc-dev-guide.rust-lang.org/opaque-types-region-infer-restrictions.html
#[instrument(level = "debug", skip(self, infcx), ret)]
#[instrument(level = "debug", skip(self, root_cx, infcx), ret)]
pub(crate) fn infer_opaque_types(
&self,
root_cx: &mut BorrowCheckRootCtxt<'tcx>,
infcx: &InferCtxt<'tcx>,
opaque_ty_decls: FxIndexMap<OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>>,
) -> FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>> {
let mut result: FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>> = FxIndexMap::default();
) {
let mut decls_modulo_regions: FxIndexMap<OpaqueTypeKey<'tcx>, (OpaqueTypeKey<'tcx>, Span)> =
FxIndexMap::default();

@@ -143,32 +144,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
continue;
}
}
// Sometimes two opaque types are the same only after we remap the generic parameters
// back to the opaque type definition. E.g. we may have `OpaqueType<X, Y>` mapped to
// `(X, Y)` and `OpaqueType<Y, X>` mapped to `(Y, X)`, and those are the same, but we
// only know that once we convert the generic parameters to those of the opaque type.
if let Some(prev) = result.get_mut(&opaque_type_key.def_id) {
if prev.ty != ty {
let guar = ty.error_reported().err().unwrap_or_else(|| {
let (Ok(e) | Err(e)) = prev
.build_mismatch_error(
&OpaqueHiddenType { ty, span: concrete_type.span },
infcx.tcx,
)
.map(|d| d.emit());
e
});
prev.ty = Ty::new_error(infcx.tcx, guar);
}
// Pick a better span if there is one.
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
prev.span = prev.span.substitute_dummy(concrete_type.span);
} else {
result.insert(
opaque_type_key.def_id,
OpaqueHiddenType { ty, span: concrete_type.span },
);
}

root_cx.add_concrete_opaque_type(
infcx.tcx,
opaque_type_key.def_id,
OpaqueHiddenType { span: concrete_type.span, ty },
);

// Check that all opaque types have the same region parameters if they have the same
// non-region parameters. This is necessary because within the new solver we perform
@@ -193,7 +174,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
});
}
}
result
}

/// Map the regions in the type to named regions. This is similar to what
7 changes: 5 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderI
use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst};
use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations};
use crate::universal_regions::{DefiningTy, UniversalRegions};
use crate::{BorrowckInferCtxt, path_utils};
use crate::{BorrowCheckRootCtxt, BorrowckInferCtxt, path_utils};

macro_rules! span_mirbug {
($context:expr, $elem:expr, $($message:tt)*) => ({
@@ -101,6 +101,7 @@ mod relate_tys;
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
/// - `location_map` -- map between MIR `Location` and `PointIndex`
pub(crate) fn type_check<'a, 'tcx>(
root_cx: &mut BorrowCheckRootCtxt<'tcx>,
infcx: &BorrowckInferCtxt<'tcx>,
body: &Body<'tcx>,
promoted: &IndexSlice<Promoted, Body<'tcx>>,
@@ -151,6 +152,7 @@ pub(crate) fn type_check<'a, 'tcx>(
};

let mut typeck = TypeChecker {
root_cx,
infcx,
last_span: body.span,
body,
@@ -212,6 +214,7 @@ enum FieldAccessError {
/// way, it accrues region constraints -- these can later be used by
/// NLL region checking.
struct TypeChecker<'a, 'tcx> {
root_cx: &'a mut BorrowCheckRootCtxt<'tcx>,
infcx: &'a BorrowckInferCtxt<'tcx>,
last_span: Span,
body: &'a Body<'tcx>,
@@ -2499,7 +2502,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
args: GenericArgsRef<'tcx>,
locations: Locations,
) -> ty::InstantiatedPredicates<'tcx> {
if let Some(closure_requirements) = &tcx.mir_borrowck(def_id).closure_requirements {
if let Some(closure_requirements) = &self.root_cx.closure_requirements(tcx, def_id) {
constraint_conversion::ConstraintConversion::new(
self.infcx,
self.universal_regions,
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
@@ -142,6 +142,9 @@ declare_features! (
/// Allows inferring `'static` outlives requirements (RFC 2093).
(removed, infer_static_outlives_requirements, "1.63.0", Some(54185),
Some("removed as it caused some confusion and discussion was inactive for years")),
/// Allow anonymous constants from an inline `const` block in pattern position
(removed, inline_const_pat, "CURRENT_RUSTC_VERSION", Some(76001),
Some("removed due to implementation concerns as it requires significant refactorings")),
/// Lazily evaluate constants. This allows constants to depend on type parameters.
(removed, lazy_normalization_consts, "1.46.0", Some(72219), Some("superseded by `generic_const_exprs`")),
/// Changes `impl Trait` to capture all lifetimes in scope.
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
@@ -531,8 +531,6 @@ declare_features! (
(unstable, import_trait_associated_functions, "1.86.0", Some(134691)),
/// Allows associated types in inherent impls.
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
/// Allow anonymous constants from an inline `const` block in pattern position
(unstable, inline_const_pat, "1.58.0", Some(76001)),
/// Allows using `pointer` and `reference` in intra-doc links
(unstable, intra_doc_pointers, "1.51.0", Some(80896)),
// Allows using the `kl` and `widekl` target features and the associated intrinsics
14 changes: 8 additions & 6 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
@@ -387,7 +387,9 @@ fn best_definition_site_of_opaque<'tcx>(
}
impl<'tcx> TaitConstraintLocator<'tcx> {
fn check(&self, item_def_id: LocalDefId) -> ControlFlow<(Span, LocalDefId)> {
if !self.tcx.has_typeck_results(item_def_id) {
if !self.tcx.has_typeck_results(item_def_id)
|| self.tcx.is_typeck_child(item_def_id.to_def_id())
{
return ControlFlow::Continue(());
}

@@ -397,8 +399,11 @@ fn best_definition_site_of_opaque<'tcx>(
return ControlFlow::Continue(());
}

if let Some(hidden_ty) =
self.tcx.mir_borrowck(item_def_id).concrete_opaque_types.get(&self.opaque_def_id)
if let Some(hidden_ty) = self
.tcx
.mir_borrowck(item_def_id)
.ok()
.and_then(|opaque_types| opaque_types.0.get(&self.opaque_def_id))
{
ControlFlow::Break((hidden_ty.span, item_def_id))
} else {
@@ -413,9 +418,6 @@ fn best_definition_site_of_opaque<'tcx>(
self.tcx
}
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) -> Self::Result {
if let hir::ExprKind::Closure(closure) = ex.kind {
self.check(closure.def_id)?;
}
intravisit::walk_expr(self, ex)
}
fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) -> Self::Result {
44 changes: 22 additions & 22 deletions compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Original file line number Diff line number Diff line change
@@ -226,17 +226,18 @@ impl TaitConstraintLocator<'_> {
};

// Use borrowck to get the type with unerased regions.
let borrowck_results = &self.tcx.mir_borrowck(item_def_id);

// If the body was tainted, then assume the opaque may have been constrained and just set it to error.
if let Some(guar) = borrowck_results.tainted_by_errors {
self.found =
Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: Ty::new_error(self.tcx, guar) });
return;
}

debug!(?borrowck_results.concrete_opaque_types);
if let Some(&concrete_type) = borrowck_results.concrete_opaque_types.get(&self.def_id) {
let concrete_opaque_types = match self.tcx.mir_borrowck(item_def_id) {
Ok(concrete_opaque_types) => concrete_opaque_types,
Err(guar) => {
self.found = Some(ty::OpaqueHiddenType {
span: DUMMY_SP,
ty: Ty::new_error(self.tcx, guar),
});
return;
}
};
debug!(?concrete_opaque_types);
if let Some(&concrete_type) = concrete_opaque_types.0.get(&self.def_id) {
debug!(?concrete_type, "found constraint");
if let Some(prev) = &mut self.found {
if concrete_type.ty != prev.ty {
@@ -258,9 +259,6 @@ impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
self.tcx
}
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
if let hir::ExprKind::Closure(closure) = ex.kind {
self.check(closure.def_id);
}
intravisit::walk_expr(self, ex);
}
fn visit_item(&mut self, it: &'tcx Item<'tcx>) {
@@ -319,7 +317,11 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
}
}

let mir_opaque_ty = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied();
let concrete_opaque_types = match tcx.mir_borrowck(owner_def_id) {
Ok(concrete_opaque_types) => concrete_opaque_types,
Err(guar) => return Ty::new_error(tcx, guar),
};
let mir_opaque_ty = concrete_opaque_types.0.get(&def_id).copied();
if let Some(mir_opaque_ty) = mir_opaque_ty {
if mir_opaque_ty.references_error() {
return mir_opaque_ty.ty;
@@ -337,8 +339,6 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(

mir_opaque_ty.ty
} else if let Some(guar) = tables.tainted_by_errors {
// Some error in the owner fn prevented us from populating
// the `concrete_opaque_types` table.
Ty::new_error(tcx, guar)
} else {
// Fall back to the RPIT we inferred during HIR typeck
@@ -369,9 +369,12 @@ impl RpitConstraintChecker<'_> {
#[instrument(skip(self), level = "debug")]
fn check(&self, def_id: LocalDefId) {
// Use borrowck to get the type with unerased regions.
let concrete_opaque_types = &self.tcx.mir_borrowck(def_id).concrete_opaque_types;
let concrete_opaque_types = match self.tcx.mir_borrowck(def_id) {
Ok(concrete_opaque_types) => concrete_opaque_types,
Err(_guar) => return,
};
debug!(?concrete_opaque_types);
for (&def_id, &concrete_type) in concrete_opaque_types {
for (&def_id, &concrete_type) in &concrete_opaque_types.0 {
if def_id != self.def_id {
// Ignore constraints for other opaque types.
continue;
@@ -395,9 +398,6 @@ impl<'tcx> intravisit::Visitor<'tcx> for RpitConstraintChecker<'tcx> {
self.tcx
}
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
if let hir::ExprKind::Closure(closure) = ex.kind {
self.check(closure.def_id);
}
intravisit::walk_expr(self, ex);
}
fn visit_item(&mut self, it: &'tcx Item<'tcx>) {
4 changes: 3 additions & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
@@ -926,7 +926,9 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
// Run unsafety check because it's responsible for stealing and
// deallocating THIR.
tcx.ensure_ok().check_unsafety(def_id);
tcx.ensure_ok().mir_borrowck(def_id)
if !tcx.is_typeck_child(def_id.to_def_id()) {
tcx.ensure_ok().mir_borrowck(def_id)
}
});
});
sess.time("MIR_effect_checking", || {
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/arena.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ macro_rules! arena_types {
rustc_middle::mir::Body<'tcx>
>,
[decode] typeck_results: rustc_middle::ty::TypeckResults<'tcx>,
[decode] borrowck_result: rustc_middle::mir::BorrowCheckResult<'tcx>,
[decode] borrowck_result: rustc_middle::mir::ConcreteOpaqueTypes<'tcx>,
[] resolver: rustc_data_structures::steal::Steal<(
rustc_middle::ty::ResolverAstLowering,
std::sync::Arc<rustc_ast::Crate>,
11 changes: 6 additions & 5 deletions compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
@@ -85,15 +85,16 @@ impl Debug for CoroutineLayout<'_> {
}
}

/// All the opaque types that are restricted to concrete types
/// by this function. Unlike the value in `TypeckResults`, this has
/// unerased regions.
#[derive(Default, Debug, TyEncodable, TyDecodable, HashStable)]
pub struct ConcreteOpaqueTypes<'tcx>(pub FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>);

#[derive(Debug, TyEncodable, TyDecodable, HashStable)]
pub struct BorrowCheckResult<'tcx> {
/// All the opaque types that are restricted to concrete types
/// by this function. Unlike the value in `TypeckResults`, this has
/// unerased regions.
pub concrete_opaque_types: FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
pub used_mut_upvars: SmallVec<[FieldIdx; 8]>,
pub tainted_by_errors: Option<ErrorGuaranteed>,
}

/// The result of the `mir_const_qualif` query.
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1127,11 +1127,11 @@ rustc_queries! {
return_result_from_ensure_ok
}

/// Borrow-checks the function body. If this is a closure, returns
/// additional requirements that the closure's creator must verify.
query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
/// Borrow-checks the given typeck root, e.g. functions, const/static items,
/// and its children, e.g. closures, inline consts.
query mir_borrowck(key: LocalDefId) -> Result<&'tcx mir::ConcreteOpaqueTypes<'tcx>, ErrorGuaranteed> {
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }
cache_on_disk_if(tcx) { false }
}

/// Gets a complete map from all types to their inherent impls.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/codec.rs
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ impl_decodable_via_ref! {
&'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
&'tcx traits::ImplSource<'tcx, ()>,
&'tcx mir::Body<'tcx>,
&'tcx mir::BorrowCheckResult<'tcx>,
&'tcx mir::ConcreteOpaqueTypes<'tcx>,
&'tcx ty::List<ty::BoundVariableKind>,
&'tcx ty::ListWithCachedTypeInfo<ty::Clause<'tcx>>,
&'tcx ty::List<FieldIdx>,
9 changes: 6 additions & 3 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
@@ -497,8 +497,11 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
}

// We only need to borrowck non-synthetic MIR.
let tainted_by_errors =
if !tcx.is_synthetic_mir(def) { tcx.mir_borrowck(def).tainted_by_errors } else { None };
let tainted_by_errors = if !tcx.is_synthetic_mir(def) {
tcx.mir_borrowck(tcx.typeck_root_def_id(def.to_def_id()).expect_local()).err()
} else {
None
};

let is_fn_like = tcx.def_kind(def).is_fn_like();
if is_fn_like {
@@ -794,7 +797,7 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_
}

if !tcx.is_synthetic_mir(def) {
tcx.ensure_done().mir_borrowck(def);
tcx.ensure_done().mir_borrowck(tcx.typeck_root_def_id(def.to_def_id()).expect_local());
}
let mut promoted = tcx.mir_promoted(def).1.steal();

2 changes: 0 additions & 2 deletions compiler/rustc_parse/messages.ftl
Original file line number Diff line number Diff line change
@@ -842,8 +842,6 @@ parse_unexpected_expr_in_pat_const_sugg = consider extracting the expression int
parse_unexpected_expr_in_pat_create_guard_sugg = consider moving the expression to a match arm guard
parse_unexpected_expr_in_pat_inline_const_sugg = consider wrapping the expression in an inline `const` (requires `{"#"}![feature(inline_const_pat)]`)
parse_unexpected_expr_in_pat_update_guard_sugg = consider moving the expression to the match arm guard
parse_unexpected_if_with_if = unexpected `if` in the condition expression
11 changes: 0 additions & 11 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
@@ -2787,17 +2787,6 @@ pub(crate) enum UnexpectedExpressionInPatternSugg {
/// The statement's block's indentation.
indentation: String,
},

#[multipart_suggestion(
parse_unexpected_expr_in_pat_inline_const_sugg,
applicability = "maybe-incorrect"
)]
InlineConst {
#[suggestion_part(code = "const {{ ")]
start_span: Span,
#[suggestion_part(code = " }}")]
end_span: Span,
},
}

#[derive(Diagnostic)]
15 changes: 11 additions & 4 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1370,17 +1370,24 @@ impl<'a> Parser<'a> {

/// Parses inline const expressions.
fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> {
if pat {
self.psess.gated_spans.gate(sym::inline_const_pat, span);
}
self.expect_keyword(exp!(Const))?;
let (attrs, blk) = self.parse_inner_attrs_and_block(None)?;
let anon_const = AnonConst {
id: DUMMY_NODE_ID,
value: self.mk_expr(blk.span, ExprKind::Block(blk, None)),
};
let blk_span = anon_const.value.span;
Ok(self.mk_expr_with_attrs(span.to(blk_span), ExprKind::ConstBlock(anon_const), attrs))
let kind = if pat {
let guar = self
.dcx()
.struct_span_err(blk_span, "`inline_const_pat` has been removed")
.with_help("use a named `const`-item or an `if`-guard instead")
.emit();
ExprKind::Err(guar)
} else {
ExprKind::ConstBlock(anon_const)
};
Ok(self.mk_expr_with_attrs(span.to(blk_span), kind, attrs))
}

/// Parses mutability (`mut` or nothing).
9 changes: 0 additions & 9 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
@@ -631,15 +631,6 @@ impl<'a> Parser<'a> {
ident,
indentation,
});

// help: wrap the expr in a `const { expr }`
// FIXME(inline_const_pat): once stabilized, remove this check and remove the `(requires #[feature(inline_const_pat)])` note from the message
if self.parser.psess.unstable_features.is_nightly_build() {
err.subdiagnostic(UnexpectedExpressionInPatternSugg::InlineConst {
start_span: expr_span.shrink_to_lo(),
end_span: expr_span.shrink_to_hi(),
});
}
},
);
}
22 changes: 0 additions & 22 deletions src/doc/unstable-book/src/language-features/inline-const-pat.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -246,7 +246,7 @@ fn emit_redundant_guards<'tcx>(
fn expr_can_be_pat(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
for_each_expr_without_closures(expr, |expr| {
if match expr.kind {
ExprKind::ConstBlock(..) => cx.tcx.features().inline_const_pat(),
ExprKind::ConstBlock(..) => false,
ExprKind::Call(c, ..) if let ExprKind::Path(qpath) = c.kind => {
// Allow ctors
matches!(cx.qpath_res(&qpath, c.hir_id), Res::Def(DefKind::Ctor(..), ..))
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
@@ -2876,7 +2876,6 @@ ui/macros/rfc-3086-metavar-expr/issue-111904.rs
ui/malformed/issue-107423-unused-delim-only-one-no-pair.rs
ui/malformed/issue-69341-malformed-derive-inert.rs
ui/marker_trait_attr/issue-61651-type-mismatch.rs
ui/match/issue-112438.rs
ui/match/issue-113012.rs
ui/match/issue-11319.rs
ui/match/issue-114691.rs
5 changes: 1 addition & 4 deletions tests/pretty/stmt_expr_attributes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ pp-exact

#![feature(inline_const_pat)]
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]

@@ -206,9 +205,7 @@ fn _11() {
let _ = ();
()
};
let const {
#![rustc_dummy]
} =
let _ =
#[rustc_dummy] const {
#![rustc_dummy]
};
9 changes: 0 additions & 9 deletions tests/ui/consts/invalid-inline-const-in-match-arm.rs

This file was deleted.

18 changes: 0 additions & 18 deletions tests/ui/consts/invalid-inline-const-in-match-arm.stderr

This file was deleted.

4 changes: 0 additions & 4 deletions tests/ui/feature-gates/feature-gate-inline_const_pat.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/feature-gates/feature-gate-inline_const_pat.stderr

This file was deleted.

5 changes: 1 addition & 4 deletions tests/ui/half-open-range-patterns/range_pat_interactions0.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ run-pass
#![allow(non_contiguous_range_endpoints)]
#![feature(inline_const_pat)]

fn main() {
let mut if_lettable = vec![];
let mut first_or = vec![];
@@ -16,7 +14,6 @@ fn main() {
match x {
1 | -3..0 => first_or.push(x),
y @ (0..5 | 6) => or_two.push(y),
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
y => bottom.push(y),
@@ -25,6 +22,6 @@ fn main() {
assert_eq!(if_lettable, [-1, 0, 2, 4]);
assert_eq!(first_or, [-3, -2, -1, 1]);
assert_eq!(or_two, [0, 2, 3, 4, 6]);
assert_eq!(range_from, [-5, -4, 7]);
assert_eq!(range_from, [-5, -4, 5, 7]);
assert_eq!(bottom, [-7, -6]);
}
2 changes: 0 additions & 2 deletions tests/ui/half-open-range-patterns/range_pat_interactions1.rs
Original file line number Diff line number Diff line change
@@ -18,8 +18,6 @@ fn main() {
//~^ error: expected a pattern range bound, found an expression
1 | -3..0 => first_or.push(x),
y @ (0..5 | 6) => or_two.push(y),
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
//~^ error: inline-const in pattern position is experimental [E0658]
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
y => bottom.push(y),
19 changes: 2 additions & 17 deletions tests/ui/half-open-range-patterns/range_pat_interactions1.stderr
Original file line number Diff line number Diff line change
@@ -11,10 +11,6 @@ LL + const VAL: /* Type */ = 5+1;
LL ~ match x as i32 {
LL ~ 0..VAL => errors_only.push(x),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 0..const { 5+1 } => errors_only.push(x),
| +++++++ +

error[E0408]: variable `n` is not bound in all patterns
--> $DIR/range_pat_interactions1.rs:10:25
@@ -24,17 +20,6 @@ LL | if let n @ 2..3|4 = x {
| |
| variable not in all patterns

error[E0658]: inline-const in pattern position is experimental
--> $DIR/range_pat_interactions1.rs:21:20
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0408, E0658.
For more information about an error, try `rustc --explain E0408`.
For more information about this error, try `rustc --explain E0408`.
22 changes: 0 additions & 22 deletions tests/ui/half-open-range-patterns/range_pat_interactions2.rs

This file was deleted.

43 changes: 0 additions & 43 deletions tests/ui/half-open-range-patterns/range_pat_interactions2.stderr

This file was deleted.

19 changes: 0 additions & 19 deletions tests/ui/half-open-range-patterns/range_pat_interactions3.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/half-open-range-patterns/range_pat_interactions3.stderr

This file was deleted.

3 changes: 1 addition & 2 deletions tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,7 @@
use std::fmt::Debug;

fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
//~^ ERROR cannot resolve opaque type
//~| WARNING elided lifetime has a name
//~^ WARNING elided lifetime has a name
|x| x
//~^ ERROR expected generic lifetime parameter, found `'_`
}
18 changes: 4 additions & 14 deletions tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr
Original file line number Diff line number Diff line change
@@ -7,24 +7,14 @@ LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
= note: `#[warn(elided_named_lifetimes)]` on by default

error[E0792]: expected generic lifetime parameter, found `'_`
--> $DIR/impl-fn-predefined-lifetimes.rs:7:9
--> $DIR/impl-fn-predefined-lifetimes.rs:6:9
|
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
| -- this generic parameter must be used with a generic lifetime parameter
...
LL |
LL | |x| x
| ^

error[E0720]: cannot resolve opaque type
--> $DIR/impl-fn-predefined-lifetimes.rs:4:35
|
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
| ^^^^^^^^^^^^^^^ recursive opaque type
...
LL | |x| x
| ----- returning here with type `{closure@$DIR/impl-fn-predefined-lifetimes.rs:7:5: 7:8}`

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 1 previous error; 1 warning emitted

Some errors have detailed explanations: E0720, E0792.
For more information about an error, try `rustc --explain E0720`.
For more information about this error, try `rustc --explain E0792`.
1 change: 0 additions & 1 deletion tests/ui/impl-trait/issues/issue-86800.rs
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ impl Context {
f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>,
) -> TransactionResult<O> {
//~^ ERROR expected generic lifetime parameter, found `'_`
//~| ERROR: item does not constrain
let mut conn = Connection {};
let mut transaction = TestTransaction { conn: &mut conn };
f(&mut transaction).await
23 changes: 1 addition & 22 deletions tests/ui/impl-trait/issues/issue-86800.stderr
Original file line number Diff line number Diff line change
@@ -24,26 +24,6 @@ note: this opaque type is supposed to be constrained
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: item does not constrain `TransactionFuture::{opaque#0}`
--> $DIR/issue-86800.rs:41:31
|
LL | ) -> TransactionResult<O> {
| _______________________________^
LL | |
LL | |
LL | | let mut conn = Connection {};
LL | | let mut transaction = TestTransaction { conn: &mut conn };
LL | | f(&mut transaction).await
LL | | }
| |_____^
|
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
--> $DIR/issue-86800.rs:21:34
|
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0792]: expected generic lifetime parameter, found `'_`
--> $DIR/issue-86800.rs:31:5
|
@@ -62,13 +42,12 @@ LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionRe
LL | ) -> TransactionResult<O> {
| _______________________________^
LL | |
LL | |
LL | | let mut conn = Connection {};
LL | | let mut transaction = TestTransaction { conn: &mut conn };
LL | | f(&mut transaction).await
LL | | }
| |_____^

error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0792`.
16 changes: 0 additions & 16 deletions tests/ui/inline-const/collect-scopes-in-pat.rs

This file was deleted.

18 changes: 0 additions & 18 deletions tests/ui/inline-const/const-block-pat-liveness.rs

This file was deleted.

28 changes: 0 additions & 28 deletions tests/ui/inline-const/const-match-pat-generic.rs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/ui/inline-const/const-match-pat-generic.stderr

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui/inline-const/const-match-pat-inference.rs

This file was deleted.

47 changes: 0 additions & 47 deletions tests/ui/inline-const/const-match-pat-lifetime-err.rs

This file was deleted.

28 changes: 0 additions & 28 deletions tests/ui/inline-const/const-match-pat-lifetime-err.stderr

This file was deleted.

34 changes: 0 additions & 34 deletions tests/ui/inline-const/const-match-pat-lifetime.rs

This file was deleted.

38 changes: 0 additions & 38 deletions tests/ui/inline-const/const-match-pat-range.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/inline-const/const-match-pat.rs

This file was deleted.

11 changes: 11 additions & 0 deletions tests/ui/inline-const/in-pat-recovery.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// While `feature(inline_const_pat)` has been removed from the
// compiler, we should still make sure that the resulting error
// message is acceptable.
fn main() {
match 1 {
const { 1 + 7 } => {}
//~^ `inline_const_pat` has been removed
2 => {}
_ => {}
}
}
10 changes: 10 additions & 0 deletions tests/ui/inline-const/in-pat-recovery.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: `inline_const_pat` has been removed
--> $DIR/in-pat-recovery.rs:6:15
|
LL | const { 1 + 7 } => {}
| ^^^^^^^^^
|
= help: use a named `const`-item or an `if`-guard instead

error: aborting due to 1 previous error

12 changes: 0 additions & 12 deletions tests/ui/inline-const/pat-match-fndef.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/inline-const/pat-match-fndef.stderr

This file was deleted.

22 changes: 0 additions & 22 deletions tests/ui/inline-const/pat-unsafe-err.rs

This file was deleted.

19 changes: 0 additions & 19 deletions tests/ui/inline-const/pat-unsafe-err.stderr

This file was deleted.

29 changes: 0 additions & 29 deletions tests/ui/inline-const/pat-unsafe.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/inline-const/pat-unsafe.stderr

This file was deleted.

44 changes: 0 additions & 44 deletions tests/ui/lint/dead-code/anon-const-in-pat.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/match/issue-112438.rs

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/match/validate-range-endpoints.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(inline_const_pat)]
#![allow(overlapping_range_endpoints)]

fn main() {
@@ -17,8 +16,6 @@ fn main() {
// There isn't really a way to detect these
1..=TOO_BIG => {}
//~^ ERROR lower range bound must be less than or equal to upper
1..=const { 256 } => {}
//~^ ERROR lower range bound must be less than or equal to upper
_ => {}
}

28 changes: 11 additions & 17 deletions tests/ui/match/validate-range-endpoints.stderr
Original file line number Diff line number Diff line change
@@ -1,59 +1,53 @@
error: literal out of range for `u8`
--> $DIR/validate-range-endpoints.rs:7:12
--> $DIR/validate-range-endpoints.rs:6:12
|
LL | 1..257 => {}
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`

error: literal out of range for `u8`
--> $DIR/validate-range-endpoints.rs:9:13
--> $DIR/validate-range-endpoints.rs:8:13
|
LL | 1..=256 => {}
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`

error[E0030]: lower range bound must be less than or equal to upper
--> $DIR/validate-range-endpoints.rs:18:9
--> $DIR/validate-range-endpoints.rs:17:9
|
LL | 1..=TOO_BIG => {}
| ^^^^^^^^^^^ lower bound larger than upper bound

error[E0030]: lower range bound must be less than or equal to upper
--> $DIR/validate-range-endpoints.rs:20:9
|
LL | 1..=const { 256 } => {}
| ^^^^^^^^^^^^^^^^^ lower bound larger than upper bound

error: literal out of range for `u64`
--> $DIR/validate-range-endpoints.rs:26:32
--> $DIR/validate-range-endpoints.rs:23:32
|
LL | 10000000000000000000..=99999999999999999999 => {}
| ^^^^^^^^^^^^^^^^^^^^ this value does not fit into the type `u64` whose range is `0..=18446744073709551615`

error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:32:12
--> $DIR/validate-range-endpoints.rs:29:12
|
LL | 0..129 => {}
| ^^^ this value does not fit into the type `i8` whose range is `-128..=127`

error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:34:13
--> $DIR/validate-range-endpoints.rs:31:13
|
LL | 0..=128 => {}
| ^^^ this value does not fit into the type `i8` whose range is `-128..=127`

error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:36:9
--> $DIR/validate-range-endpoints.rs:33:9
|
LL | -129..0 => {}
| ^^^^ this value does not fit into the type `i8` whose range is `-128..=127`

error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:38:9
--> $DIR/validate-range-endpoints.rs:35:9
|
LL | -10000..=-20 => {}
| ^^^^^^ this value does not fit into the type `i8` whose range is `-128..=127`

error[E0004]: non-exhaustive patterns: `i8::MIN..=-17_i8` and `1_i8..=i8::MAX` not covered
--> $DIR/validate-range-endpoints.rs:49:11
--> $DIR/validate-range-endpoints.rs:46:11
|
LL | match 0i8 {
| ^^^ patterns `i8::MIN..=-17_i8` and `1_i8..=i8::MAX` not covered
@@ -66,7 +60,7 @@ LL + i8::MIN..=-17_i8 | 1_i8..=i8::MAX => todo!()
|

error[E0004]: non-exhaustive patterns: `i8::MIN..=-17_i8` not covered
--> $DIR/validate-range-endpoints.rs:53:11
--> $DIR/validate-range-endpoints.rs:50:11
|
LL | match 0i8 {
| ^^^ pattern `i8::MIN..=-17_i8` not covered
@@ -78,7 +72,7 @@ LL ~ -10000.. => {},
LL + i8::MIN..=-17_i8 => todo!()
|

error: aborting due to 11 previous errors
error: aborting due to 10 previous errors

Some errors have detailed explanations: E0004, E0030.
For more information about an error, try `rustc --explain E0004`.
4 changes: 0 additions & 4 deletions tests/ui/parser/issues/issue-24375.stderr
Original file line number Diff line number Diff line change
@@ -16,10 +16,6 @@ LL + const VAL: /* Type */ = tmp[0];
LL ~ match z {
LL ~ VAL => {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { tmp[0] } => {}
| +++++++ +

error: aborting due to 1 previous error

116 changes: 0 additions & 116 deletions tests/ui/parser/recover/recover-pat-exprs.stderr
Original file line number Diff line number Diff line change
@@ -17,10 +17,6 @@ LL ~ match 0 {
LL | x => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.y } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:6:9
@@ -42,10 +38,6 @@ LL | x => (),
LL | x.y => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:7:9
@@ -68,10 +60,6 @@ LL | x.y => (),
LL | x.0 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x._0 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:8:9
@@ -94,10 +82,6 @@ LL | x => (),
LL | x._0 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0.1 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:9:9
@@ -120,10 +104,6 @@ LL | x => (),
LL | x.0.1 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.4.y.17.__z } => (),
| +++++++ +

error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.`
--> $DIR/recover-pat-exprs.rs:12:12
@@ -173,10 +153,6 @@ LL + const VAL: /* Type */ = x[0];
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x[0] } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:24:9
@@ -197,10 +173,6 @@ LL ~ match 0 {
LL | x[0] => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x[..] } => (),
| +++++++ +

error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[`
--> $DIR/recover-pat-exprs.rs:27:12
@@ -247,10 +219,6 @@ LL + const VAL: /* Type */ = x.f();
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.f() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:38:9
@@ -271,10 +239,6 @@ LL ~ match 0 {
LL | x.f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x._f() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:39:9
@@ -296,10 +260,6 @@ LL | x.f() => (),
LL | x._f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x? } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:40:9
@@ -322,10 +282,6 @@ LL | x._f() => (),
LL | x? => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { ().f() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:41:9
@@ -348,10 +304,6 @@ LL | x.f() => (),
LL | ().f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { (0, x)?.f() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:42:9
@@ -374,10 +326,6 @@ LL | x.f() => (),
LL | (0, x)?.f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.f().g() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:43:9
@@ -400,10 +348,6 @@ LL | x.f() => (),
LL | x.f().g() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 0.f()?.g()?? } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:50:9
@@ -423,10 +367,6 @@ LL + const VAL: /* Type */ = x as usize;
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x as usize } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:51:9
@@ -447,10 +387,6 @@ LL ~ match 0 {
LL | x as usize => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 0 as usize } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:52:9
@@ -472,10 +408,6 @@ LL | x as usize => (),
LL | 0 as usize => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.f().0.4 as f32 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:59:9
@@ -495,10 +427,6 @@ LL + const VAL: /* Type */ = 1 + 1;
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 1 + 1 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:60:9
@@ -519,10 +447,6 @@ LL ~ match 0 {
LL | 1 + 1 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { (1 + 2) * 3 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:63:9
@@ -545,10 +469,6 @@ LL | 1 + 1 => (),
LL |
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0 > 2 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:64:9
@@ -571,10 +491,6 @@ LL | 1 + 1 => (),
LL | x.0 > 2 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0 == 2 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:69:13
@@ -594,10 +510,6 @@ LL + const VAL: /* Type */ = y.0 > 2;
LL ~ match (0, 0) {
LL ~ (x, VAL) if x != 0 => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (x, const { y.0 > 2 }) if x != 0 => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:70:13
@@ -618,10 +530,6 @@ LL ~ match (0, 0) {
LL | (x, y.0 > 2) if x != 0 => (),
LL ~ (x, VAL) if x != 0 || x != 1 => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (x, const { y.0 > 2 }) if x != 0 || x != 1 => (),
| +++++++ +

error: left-hand side of `@` must be a binding
--> $DIR/recover-pat-exprs.rs:83:9
@@ -658,10 +566,6 @@ LL + const VAL: /* Type */ = u8::MAX.abs();
LL ~ match u8::MAX {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { u8::MAX.abs() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:86:17
@@ -684,10 +588,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ z @ w @ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | z @ w @ const { v.u() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:88:9
@@ -710,10 +610,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { y.ilog(3) } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:90:9
@@ -736,10 +632,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { n + 1 } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:92:10
@@ -762,10 +654,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ (VAL) => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (const { "".f() + 14 * 8 }) => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:95:9
@@ -788,10 +676,6 @@ LL | u8::MAX.abs() => (),
LL | 0 | ((1) | 2) | 3 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { f?() } => (),
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:101:9
24 changes: 0 additions & 24 deletions tests/ui/parser/recover/recover-pat-issues.stderr
Original file line number Diff line number Diff line change
@@ -16,10 +16,6 @@ LL + const VAL: /* Type */ = "hi".to_owned();
LL ~ match foo {
LL ~ Foo(VAL) => true,
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | Foo(const { "hi".to_owned() }) => true,
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:14:20
@@ -39,10 +35,6 @@ LL + const BAZ: /* Type */ = "hi".to_owned();
LL ~ match bar {
LL ~ Bar { baz: BAZ } => true,
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | Bar { baz: const { "hi".to_owned() } } => true,
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:25:11
@@ -62,10 +54,6 @@ LL + const VAL: /* Type */ = "foo".to_string();
LL ~ match foo.as_slice() {
LL ~ &[VAL] => {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | &[const { "foo".to_string() }] => {}
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:36:17
@@ -79,10 +67,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = MAGIC.0 as usize;
LL ~ if let Some(VAL) = None::<usize> {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let Some(const { MAGIC.0 as usize }) = None::<usize> {}
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:41:13
@@ -96,10 +80,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = -1.some(4);
LL ~ if let (VAL) = (0, Some(4)) {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let (const { -1.some(4) }) = (0, Some(4)) {}
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:44:13
@@ -113,10 +93,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = -1.Some(4);
LL ~ if let (VAL) = (0, Some(4)) {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let (const { -1.Some(4) }) = (0, Some(4)) {}
| +++++++ +

error: aborting due to 6 previous errors

8 changes: 0 additions & 8 deletions tests/ui/parser/recover/recover-pat-lets.stderr
Original file line number Diff line number Diff line change
@@ -34,10 +34,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = 1 + 1;
LL ~ let Some(VAL) = x else {
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | let Some(const { 1 + 1 }) = x else {
| +++++++ +

error: expected a pattern, found an expression
--> $DIR/recover-pat-lets.rs:17:17
@@ -51,10 +47,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = 1 + 1;
LL ~ if let Some(VAL) = x {
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let Some(const { 1 + 1 }) = x {
| +++++++ +

error: aborting due to 5 previous errors

24 changes: 0 additions & 24 deletions tests/ui/parser/recover/recover-pat-ranges.stderr
Original file line number Diff line number Diff line change
@@ -98,10 +98,6 @@ LL | 0..=1 => (),
LL |
LL ~ ..=VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | ..=const { 1 + 2 } => (),
| +++++++ +

error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:15:10
@@ -119,10 +115,6 @@ LL | 0..=1 => (),
LL |
LL ~ (VAL).. => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (const { -4 + 0 }).. => (),
| +++++++ +

error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:18:10
@@ -140,10 +132,6 @@ LL | 0..=1 => (),
LL |
LL ~ (VAL)...1 * 2 => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (const { 1 + 4 })...1 * 2 => (),
| +++++++ +

error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:18:19
@@ -161,10 +149,6 @@ LL | 0..=1 => (),
LL |
LL ~ (1 + 4)...VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (1 + 4)...const { 1 * 2 } => (),
| +++++++ +

error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:24:9
@@ -182,10 +166,6 @@ LL | 0..=1 => (),
LL |
LL ~ VAL..="y".z() => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 0.x() }..="y".z() => (),
| +++++++ +

error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:24:17
@@ -203,10 +183,6 @@ LL | 0..=1 => (),
LL |
LL ~ 0.x()..=VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 0.x()..=const { "y".z() } => (),
| +++++++ +

warning: `...` range patterns are deprecated
--> $DIR/recover-pat-ranges.rs:18:16
4 changes: 0 additions & 4 deletions tests/ui/parser/recover/recover-pat-wildcards.stderr
Original file line number Diff line number Diff line change
@@ -84,10 +84,6 @@ LL + const VAL: /* Type */ = 2 + _;
LL ~ match 9 {
LL ~ 4..=(VAL) => ()
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 4..=(const { 2 + _ }) => ()
| +++++++ +

error: aborting due to 11 previous errors

24 changes: 24 additions & 0 deletions tests/ui/pattern/non-structural-match-types-cycle-err.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ edition:2021

struct AnyOption<T>(T);
impl<T> AnyOption<T> {
const NONE: Option<T> = None;
}

// This is an unfortunate side-effect of borrowchecking nested items
// together with their parent. Evaluating the `AnyOption::<_>::NONE`
// pattern for exhaustiveness checking relies on the layout of the
// async block. This layout relies on `optimized_mir` of the nested
// item which is now borrowck'd together with its parent. As
// borrowck of the parent requires us to have already lowered the match,
// this is a query cycle.

fn uwu() {}
fn defines() {
match Some(async {}) {
AnyOption::<_>::NONE => {}
//~^ ERROR cycle detected when building THIR for `defines`
_ => {}
}
}
fn main() {}
64 changes: 64 additions & 0 deletions tests/ui/pattern/non-structural-match-types-cycle-err.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
error[E0391]: cycle detected when building THIR for `defines`
--> $DIR/non-structural-match-types-cycle-err.rs:19:9
|
LL | AnyOption::<_>::NONE => {}
| ^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires evaluating type-level constant...
--> $DIR/non-structural-match-types-cycle-err.rs:5:5
|
LL | const NONE: Option<T> = None;
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `<impl at $DIR/non-structural-match-types-cycle-err.rs:4:1: 4:21>::NONE`...
--> $DIR/non-structural-match-types-cycle-err.rs:5:5
|
LL | const NONE: Option<T> = None;
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `core::option::Option<{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}>`...
= note: ...which requires computing layout of `{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}`...
note: ...which requires optimizing MIR for `defines::{closure#0}`...
--> $DIR/non-structural-match-types-cycle-err.rs:18:16
|
LL | match Some(async {}) {
| ^^^^^
note: ...which requires elaborating drops for `defines::{closure#0}`...
--> $DIR/non-structural-match-types-cycle-err.rs:18:16
|
LL | match Some(async {}) {
| ^^^^^
note: ...which requires borrow-checking `defines`...
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
|
LL | fn defines() {
| ^^^^^^^^^^^^
note: ...which requires promoting constants in MIR for `defines`...
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
|
LL | fn defines() {
| ^^^^^^^^^^^^
note: ...which requires checking if `defines` contains FFI-unwind calls...
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
|
LL | fn defines() {
| ^^^^^^^^^^^^
note: ...which requires building MIR for `defines`...
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
|
LL | fn defines() {
| ^^^^^^^^^^^^
note: ...which requires match-checking `defines`...
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
|
LL | fn defines() {
| ^^^^^^^^^^^^
= note: ...which again requires building THIR for `defines`, completing the cycle
note: cycle used when unsafety-checking `defines`
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
|
LL | fn defines() {
| ^^^^^^^^^^^^
= 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: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
24 changes: 16 additions & 8 deletions tests/ui/pattern/non-structural-match-types.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
//@ edition:2021

#![allow(unreachable_code)]
#![feature(const_async_blocks)]
#![feature(inline_const_pat)]
struct AnyOption<T>(T);
impl<T> AnyOption<T> {
const NONE: Option<T> = None;
}

fn main() {
match loop {} {
const { || {} } => {} //~ ERROR cannot be used in patterns
fn uwu() {}
fn defines() {
match Some(uwu) {
AnyOption::<_>::NONE => {}
//~^ ERROR constant of non-structural type
_ => {}
}
match loop {} {
const { async {} } => {} //~ ERROR cannot be used in patterns

match Some(|| {}) {
AnyOption::<_>::NONE => {}
//~^ ERROR constant of non-structural type
_ => {}
}
}
fn main() {}
30 changes: 22 additions & 8 deletions tests/ui/pattern/non-structural-match-types.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
error: closure `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:9:9
error: constant of non-structural type `Option<fn() {uwu}>` in a pattern
--> $DIR/non-structural-match-types.rs:11:9
|
LL | const { || {} } => {}
| ^^^^^^^^^^^^^^^ closure can't be used in patterns
LL | impl<T> AnyOption<T> {
| --------------------
LL | const NONE: Option<T> = None;
| --------------------- constant defined here
...
LL | AnyOption::<_>::NONE => {}
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details

error: `async` block `{async block@$DIR/non-structural-match-types.rs:12:17: 12:22}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:12:9
error: constant of non-structural type `Option<{closure@$DIR/non-structural-match-types.rs:16:16: 16:18}>` in a pattern
--> $DIR/non-structural-match-types.rs:17:9
|
LL | impl<T> AnyOption<T> {
| --------------------
LL | const NONE: Option<T> = None;
| --------------------- constant defined here
...
LL | AnyOption::<_>::NONE => {}
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
LL | const { async {} } => {}
| ^^^^^^^^^^^^^^^^^^ `async` block can't be used in patterns
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -19,22 +19,5 @@ note: this opaque type is supposed to be constrained
LL | type Bar = impl std::fmt::Display;
| ^^^^^^^^^^^^^^^^^^^^^^

error: item does not constrain `Bar::{opaque#0}`
--> $DIR/const_generic_type.rs:8:31
|
LL | async fn test<const N: Bar>() {
| _______________________________^
... |
LL | | let x: u32 = N;
LL | | }
| |_^
|
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
--> $DIR/const_generic_type.rs:5:12
|
LL | type Bar = impl std::fmt::Display;
| ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

1 change: 0 additions & 1 deletion tests/ui/type-alias-impl-trait/const_generic_type.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ type Bar = impl std::fmt::Display;
async fn test<const N: Bar>() {
//~^ ERROR: `Bar` is forbidden as the type of a const generic parameter
//[no_infer]~^^ ERROR item does not constrain
//[no_infer]~| ERROR item does not constrain
#[cfg(infer)]
let x: u32 = N;
}
1 change: 0 additions & 1 deletion tests/ui/type-alias-impl-trait/hkl_forbidden4.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ where
for<'any> F: FnMut(&'any mut ()) -> FutNothing<'any>,
{
//~^ ERROR: expected generic lifetime parameter, found `'any`
//~| ERROR item does not constrain
}

fn main() {}
19 changes: 2 additions & 17 deletions tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr
Original file line number Diff line number Diff line change
@@ -11,21 +11,6 @@ note: this opaque type is supposed to be constrained
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: item does not constrain `FutNothing::{opaque#0}`
--> $DIR/hkl_forbidden4.rs:23:1
|
LL | / {
... |
LL | | }
| |_^
|
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
--> $DIR/hkl_forbidden4.rs:10:23
|
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: concrete type differs from previous defining opaque type use
--> $DIR/hkl_forbidden4.rs:12:1
|
@@ -54,10 +39,10 @@ LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
| -- this generic parameter must be used with a generic lifetime parameter
...
LL | / {
... |
LL | |
LL | | }
| |_^

error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0792`.
2 changes: 1 addition & 1 deletion tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ trait Foo {
}

impl Foo for () {
type Assoc<'a> = impl Sized; //~ ERROR unconstrained opaque type
type Assoc<'a> = impl Sized;
fn bar<'a: 'a>()
where
Self::Assoc<'a>:,
10 changes: 1 addition & 9 deletions tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.stderr
Original file line number Diff line number Diff line change
@@ -9,14 +9,6 @@ LL | fn bar<'a: 'a>()
LL | let _: Self::Assoc<'a> = x;
| ^^^^^^^^^^^^^^^

error: unconstrained opaque type
--> $DIR/in-assoc-ty-early-bound2.rs:9:22
|
LL | type Assoc<'a> = impl Sized;
| ^^^^^^^^^^
|
= note: `Assoc` must be used in combination with a concrete type within the same impl

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0700`.
10 changes: 0 additions & 10 deletions tests/ui/type/pattern_types/const_block.rs

This file was deleted.

23 changes: 0 additions & 23 deletions tests/ui/unsafe/const_pat_in_layout_restricted.rs

This file was deleted.