Use Option::as_slice
where applicable
This commit is contained in:
parent
13471d3b20
commit
03334503b3
4 changed files with 8 additions and 17 deletions
|
@ -36,7 +36,6 @@ use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext}
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::slice;
|
|
||||||
|
|
||||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pub(in super::super) fn check_casts(&mut self) {
|
pub(in super::super) fn check_casts(&mut self) {
|
||||||
|
@ -1507,11 +1506,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let coerce = if blk.targeted_by_break {
|
let coerce = if blk.targeted_by_break {
|
||||||
CoerceMany::new(coerce_to_ty)
|
CoerceMany::new(coerce_to_ty)
|
||||||
} else {
|
} else {
|
||||||
let tail_expr: &[&hir::Expr<'_>] = match tail_expr {
|
CoerceMany::with_coercion_sites(coerce_to_ty, blk.expr.as_slice())
|
||||||
Some(e) => slice::from_ref(e),
|
|
||||||
None => &[],
|
|
||||||
};
|
|
||||||
CoerceMany::with_coercion_sites(coerce_to_ty, tail_expr)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let prev_diverges = self.diverges.get();
|
let prev_diverges = self.diverges.get();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(control_flow_enum)]
|
#![feature(control_flow_enum)]
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
|
#![feature(option_as_slice)]
|
||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
|
||||||
|
|
|
@ -749,14 +749,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let opname = Ident::with_dummy_span(opname);
|
let opname = Ident::with_dummy_span(opname);
|
||||||
let input_types =
|
let (opt_rhs_expr, opt_rhs_ty) = opt_rhs.unzip();
|
||||||
opt_rhs.as_ref().map(|(_, ty)| std::slice::from_ref(ty)).unwrap_or_default();
|
let input_types = opt_rhs_ty.as_slice();
|
||||||
let cause = self.cause(
|
let cause = self.cause(
|
||||||
span,
|
span,
|
||||||
traits::BinOp {
|
traits::BinOp {
|
||||||
rhs_span: opt_rhs.map(|(expr, _)| expr.span),
|
rhs_span: opt_rhs_expr.map(|expr| expr.span),
|
||||||
is_lit: opt_rhs
|
is_lit: opt_rhs_expr
|
||||||
.map_or(false, |(expr, _)| matches!(expr.kind, hir::ExprKind::Lit(_))),
|
.map_or(false, |expr| matches!(expr.kind, hir::ExprKind::Lit(_))),
|
||||||
output_ty: expected.only_has_type(self),
|
output_ty: expected.only_has_type(self),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,7 +11,6 @@ use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutabili
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::symbol::{sym, Ident};
|
use rustc_span::symbol::{sym, Ident};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use std::slice;
|
|
||||||
|
|
||||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
/// Type-check `*oprnd_expr` with `oprnd_expr` type-checked already.
|
/// Type-check `*oprnd_expr` with `oprnd_expr` type-checked already.
|
||||||
|
@ -393,11 +392,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
Some(self.typeck_results.borrow().node_substs(expr.hir_id).type_at(1))
|
Some(self.typeck_results.borrow().node_substs(expr.hir_id).type_at(1))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let arg_tys = match arg_ty {
|
let arg_tys = arg_ty.as_slice();
|
||||||
None => &[],
|
|
||||||
Some(ref ty) => slice::from_ref(ty),
|
|
||||||
};
|
|
||||||
|
|
||||||
let method = self.try_mutable_overloaded_place_op(expr.span, base_ty, arg_tys, op);
|
let method = self.try_mutable_overloaded_place_op(expr.span, base_ty, arg_tys, op);
|
||||||
let method = match method {
|
let method = match method {
|
||||||
Some(ok) => self.register_infer_ok_obligations(ok),
|
Some(ok) => self.register_infer_ok_obligations(ok),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue