Auto merge of #111919 - matthiaskrgr:rollup-8qcdp0q, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #111121 (Work around `rust-analyzer` false-positive type errors) - #111759 (Leverage the interval property to precompute borrow kill points.) - #111841 (Run AST validation on match guards correctly) - #111862 (Split out opaque collection from from `type_of`) - #111863 (Don't skip mir typeck if body has errors) - #111903 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
096309e6dc
@ -736,11 +736,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
this.visit_expr(&arm.body);
|
this.visit_expr(&arm.body);
|
||||||
this.visit_pat(&arm.pat);
|
this.visit_pat(&arm.pat);
|
||||||
walk_list!(this, visit_attribute, &arm.attrs);
|
walk_list!(this, visit_attribute, &arm.attrs);
|
||||||
if let Some(guard) = &arm.guard && let ExprKind::Let(_, guard_expr, _) = &guard.kind {
|
if let Some(guard) = &arm.guard {
|
||||||
this.with_let_management(None, |this, _| {
|
this.with_let_management(None, |this, _| {
|
||||||
this.visit_expr(guard_expr)
|
this.visit_expr(guard)
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,10 +156,10 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
borrow_index: BorrowIndex,
|
borrow_index: BorrowIndex,
|
||||||
borrow_region: RegionVid,
|
borrow_region: RegionVid,
|
||||||
location: Location,
|
first_location: Location,
|
||||||
) {
|
) {
|
||||||
// We visit one BB at a time. The complication is that we may start in the
|
// We visit one BB at a time. The complication is that we may start in the
|
||||||
// middle of the first BB visited (the one containing `location`), in which
|
// middle of the first BB visited (the one containing `first_location`), in which
|
||||||
// case we may have to later on process the first part of that BB if there
|
// case we may have to later on process the first part of that BB if there
|
||||||
// is a path back to its start.
|
// is a path back to its start.
|
||||||
|
|
||||||
@ -168,61 +168,58 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> {
|
|||||||
// `visited` once they are added to `stack`, before they are actually
|
// `visited` once they are added to `stack`, before they are actually
|
||||||
// processed, because this avoids the need to look them up again on
|
// processed, because this avoids the need to look them up again on
|
||||||
// completion.
|
// completion.
|
||||||
self.visited.insert(location.block);
|
self.visited.insert(first_location.block);
|
||||||
|
|
||||||
let mut first_lo = location.statement_index;
|
let first_block = first_location.block;
|
||||||
let first_hi = self.body[location.block].statements.len();
|
let mut first_lo = first_location.statement_index;
|
||||||
|
let first_hi = self.body[first_block].statements.len();
|
||||||
|
|
||||||
self.visit_stack.push(StackEntry { bb: location.block, lo: first_lo, hi: first_hi });
|
self.visit_stack.push(StackEntry { bb: first_block, lo: first_lo, hi: first_hi });
|
||||||
|
|
||||||
while let Some(StackEntry { bb, lo, hi }) = self.visit_stack.pop() {
|
'preorder: while let Some(StackEntry { bb, lo, hi }) = self.visit_stack.pop() {
|
||||||
// If we process the first part of the first basic block (i.e. we encounter that block
|
if let Some(kill_stmt) =
|
||||||
// for the second time), we no longer have to visit its successors again.
|
self.regioncx.first_non_contained_inclusive(borrow_region, bb, lo, hi)
|
||||||
let mut finished_early = bb == location.block && hi != first_hi;
|
{
|
||||||
for i in lo..=hi {
|
let kill_location = Location { block: bb, statement_index: kill_stmt };
|
||||||
let location = Location { block: bb, statement_index: i };
|
|
||||||
// If region does not contain a point at the location, then add to list and skip
|
// If region does not contain a point at the location, then add to list and skip
|
||||||
// successor locations.
|
// successor locations.
|
||||||
if !self.regioncx.region_contains(borrow_region, location) {
|
debug!("borrow {:?} gets killed at {:?}", borrow_index, kill_location);
|
||||||
debug!("borrow {:?} gets killed at {:?}", borrow_index, location);
|
self.borrows_out_of_scope_at_location
|
||||||
self.borrows_out_of_scope_at_location
|
.entry(kill_location)
|
||||||
.entry(location)
|
.or_default()
|
||||||
.or_default()
|
.push(borrow_index);
|
||||||
.push(borrow_index);
|
continue 'preorder;
|
||||||
finished_early = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !finished_early {
|
// If we process the first part of the first basic block (i.e. we encounter that block
|
||||||
// Add successor BBs to the work list, if necessary.
|
// for the second time), we no longer have to visit its successors again.
|
||||||
let bb_data = &self.body[bb];
|
if bb == first_block && hi != first_hi {
|
||||||
debug_assert!(hi == bb_data.statements.len());
|
continue;
|
||||||
for succ_bb in bb_data.terminator().successors() {
|
}
|
||||||
if !self.visited.insert(succ_bb) {
|
|
||||||
if succ_bb == location.block && first_lo > 0 {
|
|
||||||
// `succ_bb` has been seen before. If it wasn't
|
|
||||||
// fully processed, add its first part to `stack`
|
|
||||||
// for processing.
|
|
||||||
self.visit_stack.push(StackEntry {
|
|
||||||
bb: succ_bb,
|
|
||||||
lo: 0,
|
|
||||||
hi: first_lo - 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
// And update this entry with 0, to represent the
|
// Add successor BBs to the work list, if necessary.
|
||||||
// whole BB being processed.
|
let bb_data = &self.body[bb];
|
||||||
first_lo = 0;
|
debug_assert!(hi == bb_data.statements.len());
|
||||||
}
|
for succ_bb in bb_data.terminator().successors() {
|
||||||
} else {
|
if !self.visited.insert(succ_bb) {
|
||||||
// succ_bb hasn't been seen before. Add it to
|
if succ_bb == first_block && first_lo > 0 {
|
||||||
// `stack` for processing.
|
// `succ_bb` has been seen before. If it wasn't
|
||||||
self.visit_stack.push(StackEntry {
|
// fully processed, add its first part to `stack`
|
||||||
bb: succ_bb,
|
// for processing.
|
||||||
lo: 0,
|
self.visit_stack.push(StackEntry { bb: succ_bb, lo: 0, hi: first_lo - 1 });
|
||||||
hi: self.body[succ_bb].statements.len(),
|
|
||||||
});
|
// And update this entry with 0, to represent the
|
||||||
|
// whole BB being processed.
|
||||||
|
first_lo = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// succ_bb hasn't been seen before. Add it to
|
||||||
|
// `stack` for processing.
|
||||||
|
self.visit_stack.push(StackEntry {
|
||||||
|
bb: succ_bb,
|
||||||
|
lo: 0,
|
||||||
|
hi: self.body[succ_bb].statements.len(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use rustc_infer::infer::outlives::test_type_match;
|
|||||||
use rustc_infer::infer::region_constraints::{GenericKind, VarInfos, VerifyBound, VerifyIfEq};
|
use rustc_infer::infer::region_constraints::{GenericKind, VarInfos, VerifyBound, VerifyIfEq};
|
||||||
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin};
|
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin};
|
||||||
use rustc_middle::mir::{
|
use rustc_middle::mir::{
|
||||||
Body, ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureOutlivesSubjectTy,
|
BasicBlock, Body, ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureOutlivesSubjectTy,
|
||||||
ClosureRegionRequirements, ConstraintCategory, Local, Location, ReturnConstraint,
|
ClosureRegionRequirements, ConstraintCategory, Local, Location, ReturnConstraint,
|
||||||
TerminatorKind,
|
TerminatorKind,
|
||||||
};
|
};
|
||||||
@ -598,6 +598,20 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
self.scc_values.contains(scc, p)
|
self.scc_values.contains(scc, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the lowest statement index in `start..=end` which is not contained by `r`.
|
||||||
|
///
|
||||||
|
/// Panics if called before `solve()` executes.
|
||||||
|
pub(crate) fn first_non_contained_inclusive(
|
||||||
|
&self,
|
||||||
|
r: RegionVid,
|
||||||
|
block: BasicBlock,
|
||||||
|
start: usize,
|
||||||
|
end: usize,
|
||||||
|
) -> Option<usize> {
|
||||||
|
let scc = self.constraint_sccs.scc(r);
|
||||||
|
self.scc_values.first_non_contained_inclusive(scc, block, start, end)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns access to the value of `r` for debugging purposes.
|
/// Returns access to the value of `r` for debugging purposes.
|
||||||
pub(crate) fn region_value_str(&self, r: RegionVid) -> String {
|
pub(crate) fn region_value_str(&self, r: RegionVid) -> String {
|
||||||
let scc = self.constraint_sccs.scc(r);
|
let scc = self.constraint_sccs.scc(r);
|
||||||
|
@ -283,6 +283,22 @@ impl<N: Idx> RegionValues<N> {
|
|||||||
elem.contained_in_row(self, r)
|
elem.contained_in_row(self, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the lowest statement index in `start..=end` which is not contained by `r`.
|
||||||
|
pub(crate) fn first_non_contained_inclusive(
|
||||||
|
&self,
|
||||||
|
r: N,
|
||||||
|
block: BasicBlock,
|
||||||
|
start: usize,
|
||||||
|
end: usize,
|
||||||
|
) -> Option<usize> {
|
||||||
|
let row = self.points.row(r)?;
|
||||||
|
let block = self.elements.entry_point(block);
|
||||||
|
let start = block.plus(start);
|
||||||
|
let end = block.plus(end);
|
||||||
|
let first_unset = row.first_unset_in(start..=end)?;
|
||||||
|
Some(first_unset.index() - block.index())
|
||||||
|
}
|
||||||
|
|
||||||
/// `self[to] |= values[from]`, essentially: that is, take all the
|
/// `self[to] |= values[from]`, essentially: that is, take all the
|
||||||
/// elements for the region `from` from `values` and add them to
|
/// elements for the region `from` from `values` and add them to
|
||||||
/// the region `to` in `self`.
|
/// the region `to` in `self`.
|
||||||
|
@ -183,17 +183,10 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
|||||||
&mut borrowck_context,
|
&mut borrowck_context,
|
||||||
);
|
);
|
||||||
|
|
||||||
let errors_reported = {
|
let mut verifier = TypeVerifier::new(&mut checker, promoted);
|
||||||
let mut verifier = TypeVerifier::new(&mut checker, promoted);
|
verifier.visit_body(&body);
|
||||||
verifier.visit_body(&body);
|
|
||||||
verifier.errors_reported
|
|
||||||
};
|
|
||||||
|
|
||||||
if !errors_reported {
|
|
||||||
// if verifier failed, don't do further checks to avoid ICEs
|
|
||||||
checker.typeck_mir(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
checker.typeck_mir(body);
|
||||||
checker.equate_inputs_and_outputs(&body, universal_regions, &normalized_inputs_and_output);
|
checker.equate_inputs_and_outputs(&body, universal_regions, &normalized_inputs_and_output);
|
||||||
checker.check_signature_annotation(&body);
|
checker.check_signature_annotation(&body);
|
||||||
|
|
||||||
@ -294,7 +287,6 @@ struct TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
cx: &'a mut TypeChecker<'b, 'tcx>,
|
cx: &'a mut TypeChecker<'b, 'tcx>,
|
||||||
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
|
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
|
||||||
last_span: Span,
|
last_span: Span,
|
||||||
errors_reported: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
|
impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
|
||||||
@ -383,13 +375,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if !self.errors_reported {
|
let promoted_body = &self.promoted[promoted];
|
||||||
let promoted_body = &self.promoted[promoted];
|
self.sanitize_promoted(promoted_body, location);
|
||||||
self.sanitize_promoted(promoted_body, location);
|
|
||||||
|
|
||||||
let promoted_ty = promoted_body.return_ty();
|
let promoted_ty = promoted_body.return_ty();
|
||||||
check_err(self, promoted_body, ty, promoted_ty);
|
check_err(self, promoted_body, ty, promoted_ty);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.cx.ascribe_user_type(
|
self.cx.ascribe_user_type(
|
||||||
constant.literal.ty(),
|
constant.literal.ty(),
|
||||||
@ -483,9 +473,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
for local_decl in &body.local_decls {
|
for local_decl in &body.local_decls {
|
||||||
self.sanitize_type(local_decl, local_decl.ty);
|
self.sanitize_type(local_decl, local_decl.ty);
|
||||||
}
|
}
|
||||||
if self.errors_reported {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.super_body(body);
|
self.super_body(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,7 +482,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
cx: &'a mut TypeChecker<'b, 'tcx>,
|
cx: &'a mut TypeChecker<'b, 'tcx>,
|
||||||
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
|
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
TypeVerifier { promoted, last_span: cx.body.span, cx, errors_reported: false }
|
TypeVerifier { promoted, last_span: cx.body.span, cx }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn body(&self) -> &Body<'tcx> {
|
fn body(&self) -> &Body<'tcx> {
|
||||||
@ -529,7 +516,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
for elem in place.projection.iter() {
|
for elem in place.projection.iter() {
|
||||||
if place_ty.variant_index.is_none() {
|
if place_ty.variant_index.is_none() {
|
||||||
if let Err(guar) = place_ty.ty.error_reported() {
|
if let Err(guar) = place_ty.ty.error_reported() {
|
||||||
assert!(self.errors_reported);
|
|
||||||
return PlaceTy::from_ty(self.tcx().ty_error(guar));
|
return PlaceTy::from_ty(self.tcx().ty_error(guar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,10 +579,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
|
|
||||||
self.visit_body(&promoted_body);
|
self.visit_body(&promoted_body);
|
||||||
|
|
||||||
if !self.errors_reported {
|
self.cx.typeck_mir(promoted_body);
|
||||||
// if verifier failed, don't do further checks to avoid ICEs
|
|
||||||
self.cx.typeck_mir(promoted_body);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.cx.body = parent_body;
|
self.cx.body = parent_body;
|
||||||
// Merge the outlives constraints back in, at the given location.
|
// Merge the outlives constraints back in, at the given location.
|
||||||
@ -762,7 +745,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn error(&mut self) -> Ty<'tcx> {
|
fn error(&mut self) -> Ty<'tcx> {
|
||||||
self.errors_reported = true;
|
|
||||||
self.tcx().ty_error_misc()
|
self.tcx().ty_error_misc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
use rustc_errors::{Applicability, StashKey};
|
use rustc_errors::{Applicability, StashKey};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
use rustc_hir::intravisit;
|
use rustc_hir::HirId;
|
||||||
use rustc_hir::intravisit::Visitor;
|
|
||||||
use rustc_hir::{HirId, Node};
|
|
||||||
use rustc_middle::hir::nested_filter;
|
|
||||||
use rustc_middle::ty::print::with_forced_trimmed_paths;
|
use rustc_middle::ty::print::with_forced_trimmed_paths;
|
||||||
use rustc_middle::ty::subst::InternalSubsts;
|
use rustc_middle::ty::subst::InternalSubsts;
|
||||||
use rustc_middle::ty::util::IntTypeExt;
|
use rustc_middle::ty::util::IntTypeExt;
|
||||||
@ -14,7 +11,8 @@ use rustc_span::{Span, DUMMY_SP};
|
|||||||
|
|
||||||
use super::ItemCtxt;
|
use super::ItemCtxt;
|
||||||
use super::{bad_placeholder, is_suggestable_infer_ty};
|
use super::{bad_placeholder, is_suggestable_infer_ty};
|
||||||
use crate::errors::UnconstrainedOpaqueType;
|
|
||||||
|
mod opaque;
|
||||||
|
|
||||||
fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
||||||
use hir::*;
|
use hir::*;
|
||||||
@ -429,7 +427,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||||||
ItemKind::OpaqueTy(OpaqueTy {
|
ItemKind::OpaqueTy(OpaqueTy {
|
||||||
origin: hir::OpaqueTyOrigin::TyAlias { .. },
|
origin: hir::OpaqueTyOrigin::TyAlias { .. },
|
||||||
..
|
..
|
||||||
}) => find_opaque_ty_constraints_for_tait(tcx, def_id),
|
}) => opaque::find_opaque_ty_constraints_for_tait(tcx, def_id),
|
||||||
// Opaque types desugared from `impl Trait`.
|
// Opaque types desugared from `impl Trait`.
|
||||||
ItemKind::OpaqueTy(OpaqueTy {
|
ItemKind::OpaqueTy(OpaqueTy {
|
||||||
origin:
|
origin:
|
||||||
@ -443,7 +441,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||||||
"tried to get type of this RPITIT with no definition"
|
"tried to get type of this RPITIT with no definition"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
find_opaque_ty_constraints_for_rpit(tcx, def_id, owner)
|
opaque::find_opaque_ty_constraints_for_rpit(tcx, def_id, owner)
|
||||||
}
|
}
|
||||||
ItemKind::Trait(..)
|
ItemKind::Trait(..)
|
||||||
| ItemKind::TraitAlias(..)
|
| ItemKind::TraitAlias(..)
|
||||||
@ -502,304 +500,6 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||||||
ty::EarlyBinder(output)
|
ty::EarlyBinder(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(tcx), level = "debug")]
|
|
||||||
/// Checks "defining uses" of opaque `impl Trait` types to ensure that they meet the restrictions
|
|
||||||
/// laid for "higher-order pattern unification".
|
|
||||||
/// This ensures that inference is tractable.
|
|
||||||
/// In particular, definitions of opaque types can only use other generics as arguments,
|
|
||||||
/// and they cannot repeat an argument. Example:
|
|
||||||
///
|
|
||||||
/// ```ignore (illustrative)
|
|
||||||
/// type Foo<A, B> = impl Bar<A, B>;
|
|
||||||
///
|
|
||||||
/// // Okay -- `Foo` is applied to two distinct, generic types.
|
|
||||||
/// fn a<T, U>() -> Foo<T, U> { .. }
|
|
||||||
///
|
|
||||||
/// // Not okay -- `Foo` is applied to `T` twice.
|
|
||||||
/// fn b<T>() -> Foo<T, T> { .. }
|
|
||||||
///
|
|
||||||
/// // Not okay -- `Foo` is applied to a non-generic type.
|
|
||||||
/// fn b<T>() -> Foo<T, u32> { .. }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
|
||||||
use rustc_hir::{Expr, ImplItem, Item, TraitItem};
|
|
||||||
|
|
||||||
struct ConstraintLocator<'tcx> {
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
|
|
||||||
/// def_id of the opaque type whose defining uses are being checked
|
|
||||||
def_id: LocalDefId,
|
|
||||||
|
|
||||||
/// as we walk the defining uses, we are checking that all of them
|
|
||||||
/// define the same hidden type. This variable is set to `Some`
|
|
||||||
/// with the first type that we find, and then later types are
|
|
||||||
/// checked against it (we also carry the span of that first
|
|
||||||
/// type).
|
|
||||||
found: Option<ty::OpaqueHiddenType<'tcx>>,
|
|
||||||
|
|
||||||
/// In the presence of dead code, typeck may figure out a hidden type
|
|
||||||
/// while borrowck will not. We collect these cases here and check at
|
|
||||||
/// the end that we actually found a type that matches (modulo regions).
|
|
||||||
typeck_types: Vec<ty::OpaqueHiddenType<'tcx>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ConstraintLocator<'_> {
|
|
||||||
#[instrument(skip(self), level = "debug")]
|
|
||||||
fn check(&mut self, item_def_id: LocalDefId) {
|
|
||||||
// Don't try to check items that cannot possibly constrain the type.
|
|
||||||
if !self.tcx.has_typeck_results(item_def_id) {
|
|
||||||
debug!("no constraint: no typeck results");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Calling `mir_borrowck` can lead to cycle errors through
|
|
||||||
// const-checking, avoid calling it if we don't have to.
|
|
||||||
// ```rust
|
|
||||||
// type Foo = impl Fn() -> usize; // when computing type for this
|
|
||||||
// const fn bar() -> Foo {
|
|
||||||
// || 0usize
|
|
||||||
// }
|
|
||||||
// const BAZR: Foo = bar(); // we would mir-borrowck this, causing cycles
|
|
||||||
// // because we again need to reveal `Foo` so we can check whether the
|
|
||||||
// // constant does not contain interior mutability.
|
|
||||||
// ```
|
|
||||||
let tables = self.tcx.typeck(item_def_id);
|
|
||||||
if let Some(guar) = tables.tainted_by_errors {
|
|
||||||
self.found =
|
|
||||||
Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error(guar) });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let Some(&typeck_hidden_ty) = tables.concrete_opaque_types.get(&self.def_id) else {
|
|
||||||
debug!("no constraints in typeck results");
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
if self.typeck_types.iter().all(|prev| prev.ty != typeck_hidden_ty.ty) {
|
|
||||||
self.typeck_types.push(typeck_hidden_ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use borrowck to get the type with unerased regions.
|
|
||||||
let concrete_opaque_types = &self.tcx.mir_borrowck(item_def_id).concrete_opaque_types;
|
|
||||||
debug!(?concrete_opaque_types);
|
|
||||||
if let Some(&concrete_type) = concrete_opaque_types.get(&self.def_id) {
|
|
||||||
debug!(?concrete_type, "found constraint");
|
|
||||||
if let Some(prev) = &mut self.found {
|
|
||||||
if concrete_type.ty != prev.ty && !(concrete_type, prev.ty).references_error() {
|
|
||||||
let guar =
|
|
||||||
prev.report_mismatch(&concrete_type, self.def_id, self.tcx).emit();
|
|
||||||
prev.ty = self.tcx.ty_error(guar);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.found = Some(concrete_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> intravisit::Visitor<'tcx> for ConstraintLocator<'tcx> {
|
|
||||||
type NestedFilter = nested_filter::All;
|
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> Self::Map {
|
|
||||||
self.tcx.hir()
|
|
||||||
}
|
|
||||||
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>) {
|
|
||||||
trace!(?it.owner_id);
|
|
||||||
// The opaque type itself or its children are not within its reveal scope.
|
|
||||||
if it.owner_id.def_id != self.def_id {
|
|
||||||
self.check(it.owner_id.def_id);
|
|
||||||
intravisit::walk_item(self, it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
|
||||||
trace!(?it.owner_id);
|
|
||||||
// The opaque type itself or its children are not within its reveal scope.
|
|
||||||
if it.owner_id.def_id != self.def_id {
|
|
||||||
self.check(it.owner_id.def_id);
|
|
||||||
intravisit::walk_impl_item(self, it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
|
||||||
trace!(?it.owner_id);
|
|
||||||
self.check(it.owner_id.def_id);
|
|
||||||
intravisit::walk_trait_item(self, it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
|
||||||
let scope = tcx.hir().get_defining_scope(hir_id);
|
|
||||||
let mut locator = ConstraintLocator { def_id, tcx, found: None, typeck_types: vec![] };
|
|
||||||
|
|
||||||
debug!(?scope);
|
|
||||||
|
|
||||||
if scope == hir::CRATE_HIR_ID {
|
|
||||||
tcx.hir().walk_toplevel_module(&mut locator);
|
|
||||||
} else {
|
|
||||||
trace!("scope={:#?}", tcx.hir().get(scope));
|
|
||||||
match tcx.hir().get(scope) {
|
|
||||||
// We explicitly call `visit_*` methods, instead of using `intravisit::walk_*` methods
|
|
||||||
// This allows our visitor to process the defining item itself, causing
|
|
||||||
// it to pick up any 'sibling' defining uses.
|
|
||||||
//
|
|
||||||
// For example, this code:
|
|
||||||
// ```
|
|
||||||
// fn foo() {
|
|
||||||
// type Blah = impl Debug;
|
|
||||||
// let my_closure = || -> Blah { true };
|
|
||||||
// }
|
|
||||||
// ```
|
|
||||||
//
|
|
||||||
// requires us to explicitly process `foo()` in order
|
|
||||||
// to notice the defining usage of `Blah`.
|
|
||||||
Node::Item(it) => locator.visit_item(it),
|
|
||||||
Node::ImplItem(it) => locator.visit_impl_item(it),
|
|
||||||
Node::TraitItem(it) => locator.visit_trait_item(it),
|
|
||||||
other => bug!("{:?} is not a valid scope for an opaque type item", other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let Some(hidden) = locator.found else {
|
|
||||||
let reported = tcx.sess.emit_err(UnconstrainedOpaqueType {
|
|
||||||
span: tcx.def_span(def_id),
|
|
||||||
name: tcx.item_name(tcx.local_parent(def_id).to_def_id()),
|
|
||||||
what: match tcx.hir().get(scope) {
|
|
||||||
_ if scope == hir::CRATE_HIR_ID => "module",
|
|
||||||
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
|
|
||||||
Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }) => "impl",
|
|
||||||
_ => "item",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return tcx.ty_error(reported);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Only check against typeck if we didn't already error
|
|
||||||
if !hidden.ty.references_error() {
|
|
||||||
for concrete_type in locator.typeck_types {
|
|
||||||
if concrete_type.ty != tcx.erase_regions(hidden.ty)
|
|
||||||
&& !(concrete_type, hidden).references_error()
|
|
||||||
{
|
|
||||||
hidden.report_mismatch(&concrete_type, def_id, tcx).emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hidden.ty
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_opaque_ty_constraints_for_rpit(
|
|
||||||
tcx: TyCtxt<'_>,
|
|
||||||
def_id: LocalDefId,
|
|
||||||
owner_def_id: LocalDefId,
|
|
||||||
) -> Ty<'_> {
|
|
||||||
use rustc_hir::{Expr, ImplItem, Item, TraitItem};
|
|
||||||
|
|
||||||
struct ConstraintChecker<'tcx> {
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
|
|
||||||
/// def_id of the opaque type whose defining uses are being checked
|
|
||||||
def_id: LocalDefId,
|
|
||||||
|
|
||||||
found: ty::OpaqueHiddenType<'tcx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ConstraintChecker<'_> {
|
|
||||||
#[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;
|
|
||||||
debug!(?concrete_opaque_types);
|
|
||||||
for (&def_id, &concrete_type) in concrete_opaque_types {
|
|
||||||
if def_id != self.def_id {
|
|
||||||
// Ignore constraints for other opaque types.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!(?concrete_type, "found constraint");
|
|
||||||
|
|
||||||
if concrete_type.ty != self.found.ty
|
|
||||||
&& !(concrete_type, self.found).references_error()
|
|
||||||
{
|
|
||||||
self.found.report_mismatch(&concrete_type, self.def_id, self.tcx).emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> intravisit::Visitor<'tcx> for ConstraintChecker<'tcx> {
|
|
||||||
type NestedFilter = nested_filter::OnlyBodies;
|
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> Self::Map {
|
|
||||||
self.tcx.hir()
|
|
||||||
}
|
|
||||||
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>) {
|
|
||||||
trace!(?it.owner_id);
|
|
||||||
// The opaque type itself or its children are not within its reveal scope.
|
|
||||||
if it.owner_id.def_id != self.def_id {
|
|
||||||
self.check(it.owner_id.def_id);
|
|
||||||
intravisit::walk_item(self, it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
|
||||||
trace!(?it.owner_id);
|
|
||||||
// The opaque type itself or its children are not within its reveal scope.
|
|
||||||
if it.owner_id.def_id != self.def_id {
|
|
||||||
self.check(it.owner_id.def_id);
|
|
||||||
intravisit::walk_impl_item(self, it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
|
||||||
trace!(?it.owner_id);
|
|
||||||
self.check(it.owner_id.def_id);
|
|
||||||
intravisit::walk_trait_item(self, it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let concrete = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied();
|
|
||||||
|
|
||||||
if let Some(concrete) = concrete {
|
|
||||||
let scope = tcx.hir().local_def_id_to_hir_id(owner_def_id);
|
|
||||||
debug!(?scope);
|
|
||||||
let mut locator = ConstraintChecker { def_id, tcx, found: concrete };
|
|
||||||
|
|
||||||
match tcx.hir().get(scope) {
|
|
||||||
Node::Item(it) => intravisit::walk_item(&mut locator, it),
|
|
||||||
Node::ImplItem(it) => intravisit::walk_impl_item(&mut locator, it),
|
|
||||||
Node::TraitItem(it) => intravisit::walk_trait_item(&mut locator, it),
|
|
||||||
other => bug!("{:?} is not a valid scope for an opaque type item", other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
concrete.map(|concrete| concrete.ty).unwrap_or_else(|| {
|
|
||||||
let table = tcx.typeck(owner_def_id);
|
|
||||||
if let Some(guar) = table.tainted_by_errors {
|
|
||||||
// Some error in the
|
|
||||||
// owner fn prevented us from populating
|
|
||||||
// the `concrete_opaque_types` table.
|
|
||||||
tcx.ty_error(guar)
|
|
||||||
} else {
|
|
||||||
table.concrete_opaque_types.get(&def_id).map(|ty| ty.ty).unwrap_or_else(|| {
|
|
||||||
// We failed to resolve the opaque type or it
|
|
||||||
// resolves to itself. We interpret this as the
|
|
||||||
// no values of the hidden type ever being constructed,
|
|
||||||
// so we can just make the hidden type be `!`.
|
|
||||||
// For backwards compatibility reasons, we fall back to
|
|
||||||
// `()` until we the diverging default is changed.
|
|
||||||
tcx.mk_diverging_default()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn infer_placeholder_type<'a>(
|
fn infer_placeholder_type<'a>(
|
||||||
tcx: TyCtxt<'a>,
|
tcx: TyCtxt<'a>,
|
||||||
def_id: LocalDefId,
|
def_id: LocalDefId,
|
||||||
|
298
compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Normal file
298
compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
use rustc_hir::def_id::LocalDefId;
|
||||||
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
|
use rustc_hir::{self as hir, Expr, ImplItem, Item, Node, TraitItem};
|
||||||
|
use rustc_middle::hir::nested_filter;
|
||||||
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
|
||||||
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
|
use crate::errors::UnconstrainedOpaqueType;
|
||||||
|
|
||||||
|
/// Checks "defining uses" of opaque `impl Trait` types to ensure that they meet the restrictions
|
||||||
|
/// laid for "higher-order pattern unification".
|
||||||
|
/// This ensures that inference is tractable.
|
||||||
|
/// In particular, definitions of opaque types can only use other generics as arguments,
|
||||||
|
/// and they cannot repeat an argument. Example:
|
||||||
|
///
|
||||||
|
/// ```ignore (illustrative)
|
||||||
|
/// type Foo<A, B> = impl Bar<A, B>;
|
||||||
|
///
|
||||||
|
/// // Okay -- `Foo` is applied to two distinct, generic types.
|
||||||
|
/// fn a<T, U>() -> Foo<T, U> { .. }
|
||||||
|
///
|
||||||
|
/// // Not okay -- `Foo` is applied to `T` twice.
|
||||||
|
/// fn b<T>() -> Foo<T, T> { .. }
|
||||||
|
///
|
||||||
|
/// // Not okay -- `Foo` is applied to a non-generic type.
|
||||||
|
/// fn b<T>() -> Foo<T, u32> { .. }
|
||||||
|
/// ```
|
||||||
|
#[instrument(skip(tcx), level = "debug")]
|
||||||
|
pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
||||||
|
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||||
|
let scope = tcx.hir().get_defining_scope(hir_id);
|
||||||
|
let mut locator = TaitConstraintLocator { def_id, tcx, found: None, typeck_types: vec![] };
|
||||||
|
|
||||||
|
debug!(?scope);
|
||||||
|
|
||||||
|
if scope == hir::CRATE_HIR_ID {
|
||||||
|
tcx.hir().walk_toplevel_module(&mut locator);
|
||||||
|
} else {
|
||||||
|
trace!("scope={:#?}", tcx.hir().get(scope));
|
||||||
|
match tcx.hir().get(scope) {
|
||||||
|
// We explicitly call `visit_*` methods, instead of using `intravisit::walk_*` methods
|
||||||
|
// This allows our visitor to process the defining item itself, causing
|
||||||
|
// it to pick up any 'sibling' defining uses.
|
||||||
|
//
|
||||||
|
// For example, this code:
|
||||||
|
// ```
|
||||||
|
// fn foo() {
|
||||||
|
// type Blah = impl Debug;
|
||||||
|
// let my_closure = || -> Blah { true };
|
||||||
|
// }
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// requires us to explicitly process `foo()` in order
|
||||||
|
// to notice the defining usage of `Blah`.
|
||||||
|
Node::Item(it) => locator.visit_item(it),
|
||||||
|
Node::ImplItem(it) => locator.visit_impl_item(it),
|
||||||
|
Node::TraitItem(it) => locator.visit_trait_item(it),
|
||||||
|
other => bug!("{:?} is not a valid scope for an opaque type item", other),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(hidden) = locator.found else {
|
||||||
|
let reported = tcx.sess.emit_err(UnconstrainedOpaqueType {
|
||||||
|
span: tcx.def_span(def_id),
|
||||||
|
name: tcx.item_name(tcx.local_parent(def_id).to_def_id()),
|
||||||
|
what: match tcx.hir().get(scope) {
|
||||||
|
_ if scope == hir::CRATE_HIR_ID => "module",
|
||||||
|
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
|
||||||
|
Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }) => "impl",
|
||||||
|
_ => "item",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return tcx.ty_error(reported);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Only check against typeck if we didn't already error
|
||||||
|
if !hidden.ty.references_error() {
|
||||||
|
for concrete_type in locator.typeck_types {
|
||||||
|
if concrete_type.ty != tcx.erase_regions(hidden.ty)
|
||||||
|
&& !(concrete_type, hidden).references_error()
|
||||||
|
{
|
||||||
|
hidden.report_mismatch(&concrete_type, def_id, tcx).emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hidden.ty
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TaitConstraintLocator<'tcx> {
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
||||||
|
/// def_id of the opaque type whose defining uses are being checked
|
||||||
|
def_id: LocalDefId,
|
||||||
|
|
||||||
|
/// as we walk the defining uses, we are checking that all of them
|
||||||
|
/// define the same hidden type. This variable is set to `Some`
|
||||||
|
/// with the first type that we find, and then later types are
|
||||||
|
/// checked against it (we also carry the span of that first
|
||||||
|
/// type).
|
||||||
|
found: Option<ty::OpaqueHiddenType<'tcx>>,
|
||||||
|
|
||||||
|
/// In the presence of dead code, typeck may figure out a hidden type
|
||||||
|
/// while borrowck will not. We collect these cases here and check at
|
||||||
|
/// the end that we actually found a type that matches (modulo regions).
|
||||||
|
typeck_types: Vec<ty::OpaqueHiddenType<'tcx>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TaitConstraintLocator<'_> {
|
||||||
|
#[instrument(skip(self), level = "debug")]
|
||||||
|
fn check(&mut self, item_def_id: LocalDefId) {
|
||||||
|
// Don't try to check items that cannot possibly constrain the type.
|
||||||
|
if !self.tcx.has_typeck_results(item_def_id) {
|
||||||
|
debug!("no constraint: no typeck results");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Calling `mir_borrowck` can lead to cycle errors through
|
||||||
|
// const-checking, avoid calling it if we don't have to.
|
||||||
|
// ```rust
|
||||||
|
// type Foo = impl Fn() -> usize; // when computing type for this
|
||||||
|
// const fn bar() -> Foo {
|
||||||
|
// || 0usize
|
||||||
|
// }
|
||||||
|
// const BAZR: Foo = bar(); // we would mir-borrowck this, causing cycles
|
||||||
|
// // because we again need to reveal `Foo` so we can check whether the
|
||||||
|
// // constant does not contain interior mutability.
|
||||||
|
// ```
|
||||||
|
let tables = self.tcx.typeck(item_def_id);
|
||||||
|
if let Some(guar) = tables.tainted_by_errors {
|
||||||
|
self.found = Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error(guar) });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let Some(&typeck_hidden_ty) = tables.concrete_opaque_types.get(&self.def_id) else {
|
||||||
|
debug!("no constraints in typeck results");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if self.typeck_types.iter().all(|prev| prev.ty != typeck_hidden_ty.ty) {
|
||||||
|
self.typeck_types.push(typeck_hidden_ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use borrowck to get the type with unerased regions.
|
||||||
|
let concrete_opaque_types = &self.tcx.mir_borrowck(item_def_id).concrete_opaque_types;
|
||||||
|
debug!(?concrete_opaque_types);
|
||||||
|
if let Some(&concrete_type) = concrete_opaque_types.get(&self.def_id) {
|
||||||
|
debug!(?concrete_type, "found constraint");
|
||||||
|
if let Some(prev) = &mut self.found {
|
||||||
|
if concrete_type.ty != prev.ty && !(concrete_type, prev.ty).references_error() {
|
||||||
|
let guar = prev.report_mismatch(&concrete_type, self.def_id, self.tcx).emit();
|
||||||
|
prev.ty = self.tcx.ty_error(guar);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.found = Some(concrete_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
|
||||||
|
type NestedFilter = nested_filter::All;
|
||||||
|
|
||||||
|
fn nested_visit_map(&mut self) -> Self::Map {
|
||||||
|
self.tcx.hir()
|
||||||
|
}
|
||||||
|
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>) {
|
||||||
|
trace!(?it.owner_id);
|
||||||
|
// The opaque type itself or its children are not within its reveal scope.
|
||||||
|
if it.owner_id.def_id != self.def_id {
|
||||||
|
self.check(it.owner_id.def_id);
|
||||||
|
intravisit::walk_item(self, it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
||||||
|
trace!(?it.owner_id);
|
||||||
|
// The opaque type itself or its children are not within its reveal scope.
|
||||||
|
if it.owner_id.def_id != self.def_id {
|
||||||
|
self.check(it.owner_id.def_id);
|
||||||
|
intravisit::walk_impl_item(self, it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
||||||
|
trace!(?it.owner_id);
|
||||||
|
self.check(it.owner_id.def_id);
|
||||||
|
intravisit::walk_trait_item(self, it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn find_opaque_ty_constraints_for_rpit(
|
||||||
|
tcx: TyCtxt<'_>,
|
||||||
|
def_id: LocalDefId,
|
||||||
|
owner_def_id: LocalDefId,
|
||||||
|
) -> Ty<'_> {
|
||||||
|
let concrete = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied();
|
||||||
|
|
||||||
|
if let Some(concrete) = concrete {
|
||||||
|
let scope = tcx.hir().local_def_id_to_hir_id(owner_def_id);
|
||||||
|
debug!(?scope);
|
||||||
|
let mut locator = RpitConstraintChecker { def_id, tcx, found: concrete };
|
||||||
|
|
||||||
|
match tcx.hir().get(scope) {
|
||||||
|
Node::Item(it) => intravisit::walk_item(&mut locator, it),
|
||||||
|
Node::ImplItem(it) => intravisit::walk_impl_item(&mut locator, it),
|
||||||
|
Node::TraitItem(it) => intravisit::walk_trait_item(&mut locator, it),
|
||||||
|
other => bug!("{:?} is not a valid scope for an opaque type item", other),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
concrete.map(|concrete| concrete.ty).unwrap_or_else(|| {
|
||||||
|
let table = tcx.typeck(owner_def_id);
|
||||||
|
if let Some(guar) = table.tainted_by_errors {
|
||||||
|
// Some error in the
|
||||||
|
// owner fn prevented us from populating
|
||||||
|
// the `concrete_opaque_types` table.
|
||||||
|
tcx.ty_error(guar)
|
||||||
|
} else {
|
||||||
|
table.concrete_opaque_types.get(&def_id).map(|ty| ty.ty).unwrap_or_else(|| {
|
||||||
|
// We failed to resolve the opaque type or it
|
||||||
|
// resolves to itself. We interpret this as the
|
||||||
|
// no values of the hidden type ever being constructed,
|
||||||
|
// so we can just make the hidden type be `!`.
|
||||||
|
// For backwards compatibility reasons, we fall back to
|
||||||
|
// `()` until we the diverging default is changed.
|
||||||
|
tcx.mk_diverging_default()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RpitConstraintChecker<'tcx> {
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
||||||
|
/// def_id of the opaque type whose defining uses are being checked
|
||||||
|
def_id: LocalDefId,
|
||||||
|
|
||||||
|
found: ty::OpaqueHiddenType<'tcx>,
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
debug!(?concrete_opaque_types);
|
||||||
|
for (&def_id, &concrete_type) in concrete_opaque_types {
|
||||||
|
if def_id != self.def_id {
|
||||||
|
// Ignore constraints for other opaque types.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!(?concrete_type, "found constraint");
|
||||||
|
|
||||||
|
if concrete_type.ty != self.found.ty && !(concrete_type, self.found).references_error()
|
||||||
|
{
|
||||||
|
self.found.report_mismatch(&concrete_type, self.def_id, self.tcx).emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> intravisit::Visitor<'tcx> for RpitConstraintChecker<'tcx> {
|
||||||
|
type NestedFilter = nested_filter::OnlyBodies;
|
||||||
|
|
||||||
|
fn nested_visit_map(&mut self) -> Self::Map {
|
||||||
|
self.tcx.hir()
|
||||||
|
}
|
||||||
|
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>) {
|
||||||
|
trace!(?it.owner_id);
|
||||||
|
// The opaque type itself or its children are not within its reveal scope.
|
||||||
|
if it.owner_id.def_id != self.def_id {
|
||||||
|
self.check(it.owner_id.def_id);
|
||||||
|
intravisit::walk_item(self, it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
||||||
|
trace!(?it.owner_id);
|
||||||
|
// The opaque type itself or its children are not within its reveal scope.
|
||||||
|
if it.owner_id.def_id != self.def_id {
|
||||||
|
self.check(it.owner_id.def_id);
|
||||||
|
intravisit::walk_impl_item(self, it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
||||||
|
trace!(?it.owner_id);
|
||||||
|
self.check(it.owner_id.def_id);
|
||||||
|
intravisit::walk_trait_item(self, it);
|
||||||
|
}
|
||||||
|
}
|
@ -181,6 +181,30 @@ impl<I: Idx> IntervalSet<I> {
|
|||||||
self.map.is_empty()
|
self.map.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Equivalent to `range.iter().find(|i| !self.contains(i))`.
|
||||||
|
pub fn first_unset_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I> {
|
||||||
|
let start = inclusive_start(range.clone());
|
||||||
|
let Some(end) = inclusive_end(self.domain, range) else {
|
||||||
|
// empty range
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
if start > end {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let Some(last) = self.map.partition_point(|r| r.0 <= start).checked_sub(1) else {
|
||||||
|
// All ranges in the map start after the new range's end
|
||||||
|
return Some(I::new(start as usize));
|
||||||
|
};
|
||||||
|
let (_, prev_end) = self.map[last];
|
||||||
|
if start > prev_end {
|
||||||
|
Some(I::new(start as usize))
|
||||||
|
} else if prev_end < end {
|
||||||
|
Some(I::new(prev_end as usize + 1))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the maximum (last) element present in the set from `range`.
|
/// Returns the maximum (last) element present in the set from `range`.
|
||||||
pub fn last_set_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I> {
|
pub fn last_set_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I> {
|
||||||
let start = inclusive_start(range.clone());
|
let start = inclusive_start(range.clone());
|
||||||
|
@ -118,7 +118,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let category = Category::of(&expr.kind).unwrap();
|
let category = Category::of(&expr.kind).unwrap();
|
||||||
debug!(?category, ?expr.kind);
|
debug!(?category, ?expr.kind);
|
||||||
match category {
|
match category {
|
||||||
Category::Constant if let NeedsTemporary::No = needs_temporary || !expr.ty.needs_drop(this.tcx, this.param_env) => {
|
Category::Constant
|
||||||
|
if matches!(needs_temporary, NeedsTemporary::No)
|
||||||
|
|| !expr.ty.needs_drop(this.tcx, this.param_env) =>
|
||||||
|
{
|
||||||
let constant = this.as_constant(expr);
|
let constant = this.as_constant(expr);
|
||||||
block.and(Operand::Constant(Box::new(constant)))
|
block.and(Operand::Constant(Box::new(constant)))
|
||||||
}
|
}
|
||||||
@ -126,7 +129,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
|
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
|
||||||
// Overwrite temp local info if we have something more interesting to record.
|
// Overwrite temp local info if we have something more interesting to record.
|
||||||
if !matches!(local_info, LocalInfo::Boring) {
|
if !matches!(local_info, LocalInfo::Boring) {
|
||||||
let decl_info = this.local_decls[operand].local_info.as_mut().assert_crate_local();
|
let decl_info =
|
||||||
|
this.local_decls[operand].local_info.as_mut().assert_crate_local();
|
||||||
if let LocalInfo::Boring | LocalInfo::BlockTailTemp(_) = **decl_info {
|
if let LocalInfo::Boring | LocalInfo::BlockTailTemp(_) = **decl_info {
|
||||||
**decl_info = local_info;
|
**decl_info = local_info;
|
||||||
}
|
}
|
||||||
|
@ -639,7 +639,7 @@ pub(super) fn dump_coverage_spanview<'tcx>(
|
|||||||
let def_id = mir_source.def_id();
|
let def_id = mir_source.def_id();
|
||||||
|
|
||||||
let span_viewables = span_viewables(tcx, mir_body, basic_coverage_blocks, &coverage_spans);
|
let span_viewables = span_viewables(tcx, mir_body, basic_coverage_blocks, &coverage_spans);
|
||||||
let mut file = create_dump_file(tcx, "html", false, pass_name, &0, mir_body)
|
let mut file = create_dump_file(tcx, "html", false, pass_name, &0i32, mir_body)
|
||||||
.expect("Unexpected error creating MIR spanview HTML file");
|
.expect("Unexpected error creating MIR spanview HTML file");
|
||||||
let crate_name = tcx.crate_name(def_id.krate);
|
let crate_name = tcx.crate_name(def_id.krate);
|
||||||
let item_name = tcx.def_path(def_id).to_filename_friendly_no_crate();
|
let item_name = tcx.def_path(def_id).to_filename_friendly_no_crate();
|
||||||
@ -740,7 +740,7 @@ pub(super) fn dump_coverage_graphviz<'tcx>(
|
|||||||
.join("\n ")
|
.join("\n ")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let mut file = create_dump_file(tcx, "dot", false, pass_name, &0, mir_body)
|
let mut file = create_dump_file(tcx, "dot", false, pass_name, &0i32, mir_body)
|
||||||
.expect("Unexpected error creating BasicCoverageBlock graphviz DOT file");
|
.expect("Unexpected error creating BasicCoverageBlock graphviz DOT file");
|
||||||
graphviz_writer
|
graphviz_writer
|
||||||
.write_graphviz(tcx, &mut file)
|
.write_graphviz(tcx, &mut file)
|
||||||
|
@ -26,16 +26,16 @@ define-function: (
|
|||||||
|
|
||||||
call-function: ("check-badge", {
|
call-function: ("check-badge", {
|
||||||
"theme": "ayu",
|
"theme": "ayu",
|
||||||
"color": "rgb(197, 197, 197)",
|
"color": "#c5c5c5",
|
||||||
"background": "rgb(49, 69, 89)",
|
"background": "#314559",
|
||||||
})
|
})
|
||||||
call-function: ("check-badge", {
|
call-function: ("check-badge", {
|
||||||
"theme": "dark",
|
"theme": "dark",
|
||||||
"color": "rgb(221, 221, 221)",
|
"color": "#ddd",
|
||||||
"background": "rgb(49, 69, 89)",
|
"background": "#314559",
|
||||||
})
|
})
|
||||||
call-function: ("check-badge", {
|
call-function: ("check-badge", {
|
||||||
"theme": "light",
|
"theme": "light",
|
||||||
"color": "rgb(0, 0, 0)",
|
"color": "black",
|
||||||
"background": "rgb(255, 245, 214)",
|
"background": "#fff5d6",
|
||||||
})
|
})
|
||||||
|
@ -10,10 +10,12 @@ fn _if_let_guard() {
|
|||||||
() if (let 0 = 1) => {}
|
() if (let 0 = 1) => {}
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
|
||||||
() if (((let 0 = 1))) => {}
|
() if (((let 0 = 1))) => {}
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
|
||||||
() if true && let 0 = 1 => {}
|
() if true && let 0 = 1 => {}
|
||||||
//~^ ERROR `if let` guards are experimental
|
//~^ ERROR `if let` guards are experimental
|
||||||
@ -26,16 +28,20 @@ fn _if_let_guard() {
|
|||||||
() if (let 0 = 1) && true => {}
|
() if (let 0 = 1) && true => {}
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
|
||||||
() if true && (let 0 = 1) => {}
|
() if true && (let 0 = 1) => {}
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
|
||||||
() if (let 0 = 1) && (let 0 = 1) => {}
|
() if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR `let` expressions in this position are unstable
|
//~| ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
|
||||||
() if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
() if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
//~^ ERROR `if let` guards are experimental
|
//~^ ERROR `if let` guards are experimental
|
||||||
@ -47,6 +53,10 @@ fn _if_let_guard() {
|
|||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
|
|
||||||
|
|
||||||
() if let Range { start: _, end: _ } = (true..true) && false => {}
|
() if let Range { start: _, end: _ } = (true..true) && false => {}
|
||||||
//~^ ERROR `if let` guards are experimental
|
//~^ ERROR `if let` guards are experimental
|
||||||
@ -68,9 +78,11 @@ fn _macros() {
|
|||||||
use_expr!((let 0 = 1 && 0 == 0));
|
use_expr!((let 0 = 1 && 0 == 0));
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
use_expr!((let 0 = 1));
|
use_expr!((let 0 = 1));
|
||||||
//~^ ERROR `let` expressions in this position are unstable
|
//~^ ERROR `let` expressions in this position are unstable
|
||||||
//~| ERROR expected expression, found `let` statement
|
//~| ERROR expected expression, found `let` statement
|
||||||
|
//~| ERROR `let` expressions are not supported here
|
||||||
match () {
|
match () {
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
() if let 0 = 1 => {}
|
() if let 0 = 1 => {}
|
||||||
|
@ -5,67 +5,67 @@ LL | () if (let 0 = 1) => {}
|
|||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:14:18
|
--> $DIR/feature-gate.rs:15:18
|
||||||
|
|
|
|
||||||
LL | () if (((let 0 = 1))) => {}
|
LL | () if (((let 0 = 1))) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:26:16
|
--> $DIR/feature-gate.rs:28:16
|
||||||
|
|
|
|
||||||
LL | () if (let 0 = 1) && true => {}
|
LL | () if (let 0 = 1) && true => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:30:24
|
--> $DIR/feature-gate.rs:33:24
|
||||||
|
|
|
|
||||||
LL | () if true && (let 0 = 1) => {}
|
LL | () if true && (let 0 = 1) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:34:16
|
--> $DIR/feature-gate.rs:38:16
|
||||||
|
|
|
|
||||||
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:34:31
|
--> $DIR/feature-gate.rs:38:31
|
||||||
|
|
|
|
||||||
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:40:42
|
--> $DIR/feature-gate.rs:46:42
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:40:55
|
--> $DIR/feature-gate.rs:46:55
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:40:68
|
--> $DIR/feature-gate.rs:46:68
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:68:16
|
--> $DIR/feature-gate.rs:78:16
|
||||||
|
|
|
|
||||||
LL | use_expr!((let 0 = 1 && 0 == 0));
|
LL | use_expr!((let 0 = 1 && 0 == 0));
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found `let` statement
|
error: expected expression, found `let` statement
|
||||||
--> $DIR/feature-gate.rs:71:16
|
--> $DIR/feature-gate.rs:82:16
|
||||||
|
|
|
|
||||||
LL | use_expr!((let 0 = 1));
|
LL | use_expr!((let 0 = 1));
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: no rules expected the token `let`
|
error: no rules expected the token `let`
|
||||||
--> $DIR/feature-gate.rs:80:15
|
--> $DIR/feature-gate.rs:92:15
|
||||||
|
|
|
|
||||||
LL | macro_rules! use_expr {
|
LL | macro_rules! use_expr {
|
||||||
| --------------------- when calling this macro
|
| --------------------- when calling this macro
|
||||||
@ -74,11 +74,154 @@ LL | use_expr!(let 0 = 1);
|
|||||||
| ^^^ no rules expected this token in macro call
|
| ^^^ no rules expected this token in macro call
|
||||||
|
|
|
|
||||||
note: while trying to match meta-variable `$e:expr`
|
note: while trying to match meta-variable `$e:expr`
|
||||||
--> $DIR/feature-gate.rs:61:10
|
--> $DIR/feature-gate.rs:71:10
|
||||||
|
|
|
|
||||||
LL | ($e:expr) => {
|
LL | ($e:expr) => {
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:10:16
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:10:16
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:15:18
|
||||||
|
|
|
||||||
|
LL | () if (((let 0 = 1))) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:15:18
|
||||||
|
|
|
||||||
|
LL | () if (((let 0 = 1))) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:28:16
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) && true => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:28:16
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) && true => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:33:24
|
||||||
|
|
|
||||||
|
LL | () if true && (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:33:24
|
||||||
|
|
|
||||||
|
LL | () if true && (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:38:16
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:38:16
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:38:31
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:38:31
|
||||||
|
|
|
||||||
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:46:42
|
||||||
|
|
|
||||||
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:46:42
|
||||||
|
|
|
||||||
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:46:55
|
||||||
|
|
|
||||||
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:46:42
|
||||||
|
|
|
||||||
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:46:68
|
||||||
|
|
|
||||||
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:46:42
|
||||||
|
|
|
||||||
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:78:16
|
||||||
|
|
|
||||||
|
LL | use_expr!((let 0 = 1 && 0 == 0));
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:78:16
|
||||||
|
|
|
||||||
|
LL | use_expr!((let 0 = 1 && 0 == 0));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/feature-gate.rs:82:16
|
||||||
|
|
|
||||||
|
LL | use_expr!((let 0 = 1));
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `let`s wrapped in parentheses are not supported in a context with let chains
|
||||||
|
--> $DIR/feature-gate.rs:82:16
|
||||||
|
|
|
||||||
|
LL | use_expr!((let 0 = 1));
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error[E0658]: `if let` guards are experimental
|
error[E0658]: `if let` guards are experimental
|
||||||
--> $DIR/feature-gate.rs:7:12
|
--> $DIR/feature-gate.rs:7:12
|
||||||
|
|
|
|
||||||
@ -90,7 +233,7 @@ LL | () if let 0 = 1 => {}
|
|||||||
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
||||||
|
|
||||||
error[E0658]: `if let` guards are experimental
|
error[E0658]: `if let` guards are experimental
|
||||||
--> $DIR/feature-gate.rs:18:12
|
--> $DIR/feature-gate.rs:20:12
|
||||||
|
|
|
|
||||||
LL | () if true && let 0 = 1 => {}
|
LL | () if true && let 0 = 1 => {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -100,7 +243,7 @@ LL | () if true && let 0 = 1 => {}
|
|||||||
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
||||||
|
|
||||||
error[E0658]: `if let` guards are experimental
|
error[E0658]: `if let` guards are experimental
|
||||||
--> $DIR/feature-gate.rs:22:12
|
--> $DIR/feature-gate.rs:24:12
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && true => {}
|
LL | () if let 0 = 1 && true => {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -110,7 +253,7 @@ LL | () if let 0 = 1 && true => {}
|
|||||||
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
||||||
|
|
||||||
error[E0658]: `if let` guards are experimental
|
error[E0658]: `if let` guards are experimental
|
||||||
--> $DIR/feature-gate.rs:40:12
|
--> $DIR/feature-gate.rs:46:12
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -120,7 +263,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
|||||||
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
||||||
|
|
||||||
error[E0658]: `if let` guards are experimental
|
error[E0658]: `if let` guards are experimental
|
||||||
--> $DIR/feature-gate.rs:51:12
|
--> $DIR/feature-gate.rs:61:12
|
||||||
|
|
|
|
||||||
LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -130,7 +273,7 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
|||||||
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
|
||||||
|
|
||||||
error[E0658]: `if let` guards are experimental
|
error[E0658]: `if let` guards are experimental
|
||||||
--> $DIR/feature-gate.rs:76:12
|
--> $DIR/feature-gate.rs:88:12
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 => {}
|
LL | () if let 0 = 1 => {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
@ -149,7 +292,7 @@ LL | () if (let 0 = 1) => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:14:18
|
--> $DIR/feature-gate.rs:15:18
|
||||||
|
|
|
|
||||||
LL | () if (((let 0 = 1))) => {}
|
LL | () if (((let 0 = 1))) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -158,7 +301,7 @@ LL | () if (((let 0 = 1))) => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:18:23
|
--> $DIR/feature-gate.rs:20:23
|
||||||
|
|
|
|
||||||
LL | () if true && let 0 = 1 => {}
|
LL | () if true && let 0 = 1 => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -167,7 +310,7 @@ LL | () if true && let 0 = 1 => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:22:15
|
--> $DIR/feature-gate.rs:24:15
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && true => {}
|
LL | () if let 0 = 1 && true => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -176,7 +319,7 @@ LL | () if let 0 = 1 && true => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:26:16
|
--> $DIR/feature-gate.rs:28:16
|
||||||
|
|
|
|
||||||
LL | () if (let 0 = 1) && true => {}
|
LL | () if (let 0 = 1) && true => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -185,7 +328,7 @@ LL | () if (let 0 = 1) && true => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:30:24
|
--> $DIR/feature-gate.rs:33:24
|
||||||
|
|
|
|
||||||
LL | () if true && (let 0 = 1) => {}
|
LL | () if true && (let 0 = 1) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -194,7 +337,7 @@ LL | () if true && (let 0 = 1) => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:34:16
|
--> $DIR/feature-gate.rs:38:16
|
||||||
|
|
|
|
||||||
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -203,7 +346,7 @@ LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:34:31
|
--> $DIR/feature-gate.rs:38:31
|
||||||
|
|
|
|
||||||
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -212,7 +355,7 @@ LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:40:15
|
--> $DIR/feature-gate.rs:46:15
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -221,7 +364,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:40:28
|
--> $DIR/feature-gate.rs:46:28
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -230,7 +373,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:40:42
|
--> $DIR/feature-gate.rs:46:42
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -239,7 +382,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:40:55
|
--> $DIR/feature-gate.rs:46:55
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -248,7 +391,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:40:68
|
--> $DIR/feature-gate.rs:46:68
|
||||||
|
|
|
|
||||||
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -257,7 +400,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:51:15
|
--> $DIR/feature-gate.rs:61:15
|
||||||
|
|
|
|
||||||
LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -266,7 +409,7 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:68:16
|
--> $DIR/feature-gate.rs:78:16
|
||||||
|
|
|
|
||||||
LL | use_expr!((let 0 = 1 && 0 == 0));
|
LL | use_expr!((let 0 = 1 && 0 == 0));
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -275,7 +418,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0));
|
|||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `let` expressions in this position are unstable
|
error[E0658]: `let` expressions in this position are unstable
|
||||||
--> $DIR/feature-gate.rs:71:16
|
--> $DIR/feature-gate.rs:82:16
|
||||||
|
|
|
|
||||||
LL | use_expr!((let 0 = 1));
|
LL | use_expr!((let 0 = 1));
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
@ -283,6 +426,6 @@ LL | use_expr!((let 0 = 1));
|
|||||||
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
|
||||||
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
= help: add `#![feature(let_chains)]` to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to 34 previous errors
|
error: aborting due to 45 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
23
tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs
Normal file
23
tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#![feature(let_chains)]
|
||||||
|
|
||||||
|
fn let_or_guard(x: Result<Option<i32>, ()>) {
|
||||||
|
match x {
|
||||||
|
Ok(opt) if let Some(4) = opt || false => {}
|
||||||
|
//~^ ERROR `let` expressions are not supported here
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hiding_unsafe_mod(x: Result<Option<i32>, ()>) {
|
||||||
|
match x {
|
||||||
|
Ok(opt)
|
||||||
|
if {
|
||||||
|
unsafe mod a {};
|
||||||
|
//~^ ERROR module cannot be declared unsafe
|
||||||
|
false
|
||||||
|
} => {}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
21
tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr
Normal file
21
tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
error: `let` expressions are not supported here
|
||||||
|
--> $DIR/ast-validate-guards.rs:5:20
|
||||||
|
|
|
||||||
|
LL | Ok(opt) if let Some(4) = opt || false => {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only supported directly in conditions of `if` and `while` expressions
|
||||||
|
note: `||` operators are not supported in let chain expressions
|
||||||
|
--> $DIR/ast-validate-guards.rs:5:38
|
||||||
|
|
|
||||||
|
LL | Ok(opt) if let Some(4) = opt || false => {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: module cannot be declared unsafe
|
||||||
|
--> $DIR/ast-validate-guards.rs:15:17
|
||||||
|
|
|
||||||
|
LL | unsafe mod a {};
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user