mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Tidy up comments and some formatting.
Mostly by wrapping overly long comment lines, plus a few other things.
This commit is contained in:
parent
ad875529bf
commit
bf1a5c2b7f
@ -254,8 +254,8 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
|
||||
let sccs = self.regioncx.constraint_sccs();
|
||||
let universal_regions = self.regioncx.universal_regions();
|
||||
|
||||
// We first handle the cases where the loan doesn't go out of scope, depending on the issuing
|
||||
// region's successors.
|
||||
// We first handle the cases where the loan doesn't go out of scope, depending on the
|
||||
// issuing region's successors.
|
||||
for successor in graph::depth_first_search(&self.regioncx.region_graph(), issuing_region) {
|
||||
// 1. Via applied member constraints
|
||||
//
|
||||
|
@ -289,8 +289,8 @@ where
|
||||
// `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
|
||||
// `ObligationCause`. The normalization results are currently different between
|
||||
// `QueryNormalizeExt::query_normalize` used in the query and `normalize` called below:
|
||||
// the former fails to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs` test.
|
||||
// Check after #85499 lands to see if its fixes have erased this difference.
|
||||
// the former fails to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs`
|
||||
// test. Check after #85499 lands to see if its fixes have erased this difference.
|
||||
let (param_env, value) = key.into_parts();
|
||||
let _ = ocx.normalize(&cause, param_env, value.value);
|
||||
|
||||
|
@ -1345,11 +1345,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
// See `tests/ui/moves/needs-clone-through-deref.rs`
|
||||
return false;
|
||||
}
|
||||
// We don't want to suggest `.clone()` in a move closure, since the value has already been captured.
|
||||
// We don't want to suggest `.clone()` in a move closure, since the value has already been
|
||||
// captured.
|
||||
if self.in_move_closure(expr) {
|
||||
return false;
|
||||
}
|
||||
// We also don't want to suggest cloning a closure itself, since the value has already been captured.
|
||||
// We also don't want to suggest cloning a closure itself, since the value has already been
|
||||
// captured.
|
||||
if let hir::ExprKind::Closure(_) = expr.kind {
|
||||
return false;
|
||||
}
|
||||
@ -1381,7 +1383,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cloning the raw pointer doesn't make sense in some cases and would cause a type mismatch error. (see #126863)
|
||||
// Cloning the raw pointer doesn't make sense in some cases and would cause a type mismatch
|
||||
// error. (see #126863)
|
||||
if inner_expr.span.lo() != expr.span.lo() && !is_raw_ptr {
|
||||
// Remove "(*" or "(&"
|
||||
sugg.push((expr.span.with_hi(inner_expr.span.lo()), String::new()));
|
||||
@ -1553,8 +1556,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
let use_spans = self.move_spans(place.as_ref(), location);
|
||||
let span = use_spans.var_or_use();
|
||||
|
||||
// If the attempted use is in a closure then we do not care about the path span of the place we are currently trying to use
|
||||
// we call `var_span_label` on `borrow_spans` to annotate if the existing borrow was in a closure
|
||||
// If the attempted use is in a closure then we do not care about the path span of the
|
||||
// place we are currently trying to use we call `var_span_label` on `borrow_spans` to
|
||||
// annotate if the existing borrow was in a closure.
|
||||
let mut err = self.cannot_use_when_mutably_borrowed(
|
||||
span,
|
||||
&self.describe_any_place(place.as_ref()),
|
||||
@ -2480,7 +2484,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
if let hir::ExprKind::Closure(closure) = ex.kind
|
||||
&& ex.span.contains(self.borrow_span)
|
||||
// To support cases like `|| { v.call(|this| v.get()) }`
|
||||
// FIXME: actually support such cases (need to figure out how to move from the capture place to original local)
|
||||
// FIXME: actually support such cases (need to figure out how to move from the
|
||||
// capture place to original local).
|
||||
&& self.res.as_ref().map_or(true, |(prev_res, _)| prev_res.span.contains(ex.span))
|
||||
{
|
||||
self.res = Some((ex, closure));
|
||||
@ -3188,8 +3193,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
/// misleading users in cases like `tests/ui/nll/borrowed-temporary-error.rs`.
|
||||
/// We could expand the analysis to suggest hoising all of the relevant parts of
|
||||
/// the users' code to make the code compile, but that could be too much.
|
||||
/// We found the `prop_expr` by the way to check whether the expression is a `FormatArguments`,
|
||||
/// which is a special case since it's generated by the compiler.
|
||||
/// We found the `prop_expr` by the way to check whether the expression is a
|
||||
/// `FormatArguments`, which is a special case since it's generated by the
|
||||
/// compiler.
|
||||
struct NestedStatementVisitor<'tcx> {
|
||||
span: Span,
|
||||
current: usize,
|
||||
@ -3420,7 +3426,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
let (sugg_span, suggestion) = match tcx.sess.source_map().span_to_snippet(args_span) {
|
||||
Ok(string) => {
|
||||
let coro_prefix = if string.starts_with("async") {
|
||||
// `async` is 5 chars long. Not using `.len()` to avoid the cast from `usize` to `u32`
|
||||
// `async` is 5 chars long. Not using `.len()` to avoid the cast from `usize`
|
||||
// to `u32`.
|
||||
Some(5)
|
||||
} else if string.starts_with("gen") {
|
||||
// `gen` is 3 chars long
|
||||
@ -3618,10 +3625,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
let stmt_kind =
|
||||
self.body[location.block].statements.get(location.statement_index).map(|s| &s.kind);
|
||||
if let Some(StatementKind::StorageDead(..)) = stmt_kind {
|
||||
// this analysis only tries to find moves explicitly
|
||||
// written by the user, so we ignore the move-outs
|
||||
// created by `StorageDead` and at the beginning
|
||||
// of a function.
|
||||
// This analysis only tries to find moves explicitly written by the user, so we
|
||||
// ignore the move-outs created by `StorageDead` and at the beginning of a
|
||||
// function.
|
||||
} else {
|
||||
// If we are found a use of a.b.c which was in error, then we want to look for
|
||||
// moves not only of a.b.c but also a.b and a.
|
||||
@ -3706,13 +3712,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
if (is_argument || !reached_start) && result.is_empty() {
|
||||
/* Process back edges (moves in future loop iterations) only if
|
||||
the move path is definitely initialized upon loop entry,
|
||||
to avoid spurious "in previous iteration" errors.
|
||||
During DFS, if there's a path from the error back to the start
|
||||
of the function with no intervening init or move, then the
|
||||
move path may be uninitialized at loop entry.
|
||||
*/
|
||||
// Process back edges (moves in future loop iterations) only if
|
||||
// the move path is definitely initialized upon loop entry,
|
||||
// to avoid spurious "in previous iteration" errors.
|
||||
// During DFS, if there's a path from the error back to the start
|
||||
// of the function with no intervening init or move, then the
|
||||
// move path may be uninitialized at loop entry.
|
||||
while let Some(location) = back_edge_stack.pop() {
|
||||
if dfs_iter(&mut result, location, true) {
|
||||
continue;
|
||||
|
@ -130,7 +130,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||
{
|
||||
suggest_rewrite_if_let(tcx, expr, &pat, init, conseq, alt, err);
|
||||
} else if path_span.map_or(true, |path_span| path_span == var_or_use_span) {
|
||||
// We can use `var_or_use_span` if either `path_span` is not present, or both spans are the same
|
||||
// We can use `var_or_use_span` if either `path_span` is not present, or both
|
||||
// spans are the same.
|
||||
if borrow_span.map_or(true, |sp| !sp.overlaps(var_or_use_span)) {
|
||||
err.span_label(
|
||||
var_or_use_span,
|
||||
@ -165,7 +166,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||
LaterUseKind::FakeLetRead => "borrow later stored here",
|
||||
LaterUseKind::Other => "borrow used here, in later iteration of loop",
|
||||
};
|
||||
// We can use `var_or_use_span` if either `path_span` is not present, or both spans are the same
|
||||
// We can use `var_or_use_span` if either `path_span` is not present, or both spans
|
||||
// are the same.
|
||||
if path_span.map(|path_span| path_span == var_or_use_span).unwrap_or(true) {
|
||||
err.span_label(var_or_use_span, format!("{borrow_desc}{message}"));
|
||||
} else {
|
||||
@ -285,7 +287,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||
span: _,
|
||||
pat,
|
||||
init,
|
||||
// FIXME(#101728): enable rewrite when type ascription is stabilized again
|
||||
// FIXME(#101728): enable rewrite when type ascription is
|
||||
// stabilized again.
|
||||
ty: None,
|
||||
recovered: _,
|
||||
}) = cond.kind
|
||||
@ -353,8 +356,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||
unsize_ty: Ty<'tcx>,
|
||||
) {
|
||||
if let ty::Adt(def, args) = unsize_ty.kind() {
|
||||
// We try to elaborate the object lifetime defaults and present those to the user. This should
|
||||
// make it clear where the region constraint is coming from.
|
||||
// We try to elaborate the object lifetime defaults and present those to the user. This
|
||||
// should make it clear where the region constraint is coming from.
|
||||
let generics = tcx.generics_of(def.did());
|
||||
|
||||
let mut has_dyn = false;
|
||||
@ -531,9 +534,10 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
||||
let mut use_in_later_iteration_of_loop = false;
|
||||
|
||||
if region_sub == borrow_region_vid {
|
||||
// When `region_sub` is the same as `borrow_region_vid` (the location where the borrow is
|
||||
// issued is the same location that invalidates the reference), this is likely a loop iteration
|
||||
// - in this case, try using the loop terminator location in `find_sub_region_live_at`.
|
||||
// When `region_sub` is the same as `borrow_region_vid` (the location where the borrow
|
||||
// is issued is the same location that invalidates the reference), this is likely a
|
||||
// loop iteration. In this case, try using the loop terminator location in
|
||||
// `find_sub_region_live_at`.
|
||||
if let Some(loop_terminator_location) =
|
||||
regioncx.find_loop_terminator_location(borrow.region, body)
|
||||
{
|
||||
|
@ -763,7 +763,7 @@ impl<'tcx> BorrowedContentSource<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
///helper struct for explain_captures()
|
||||
/// Helper struct for `explain_captures`.
|
||||
struct CapturedMessageOpt {
|
||||
is_partial_move: bool,
|
||||
is_loop_message: bool,
|
||||
|
@ -793,7 +793,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
let reason = if let PlaceBase::Upvar(upvar_id) = closure_kind_origin.base {
|
||||
let upvar = ty::place_to_string_for_capture(tcx, closure_kind_origin);
|
||||
let root_hir_id = upvar_id.var_path.hir_id;
|
||||
// we have an origin for this closure kind starting at this root variable so it's safe to unwrap here
|
||||
// We have an origin for this closure kind starting at this root variable so it's
|
||||
// safe to unwrap here.
|
||||
let captured_places =
|
||||
tables.closure_min_captures[&closure_local_def_id].get(&root_hir_id).unwrap();
|
||||
|
||||
@ -966,8 +967,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
// If we can detect the expression to be an function or method call where the closure was an argument,
|
||||
// we point at the function or method definition argument...
|
||||
// If we can detect the expression to be an function or method call where the closure was
|
||||
// an argument, we point at the function or method definition argument...
|
||||
if let Some((callee_def_id, call_span, call_args)) = get_call_details() {
|
||||
let arg_pos = call_args
|
||||
.iter()
|
||||
|
@ -30,8 +30,8 @@ pub(crate) struct RegionName {
|
||||
}
|
||||
|
||||
/// Denotes the source of a region that is named by a `RegionName`. For example, a free region that
|
||||
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get `Static`.
|
||||
/// This helps to print the right kinds of diagnostics.
|
||||
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get
|
||||
/// `Static`. This helps to print the right kinds of diagnostics.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub(crate) enum RegionNameSource {
|
||||
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
|
||||
@ -825,8 +825,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
||||
/// async fn foo() -> i32 { 2 }
|
||||
/// ```
|
||||
///
|
||||
/// this function, given the lowered return type of `foo`, an [`OpaqueDef`] that implements `Future<Output=i32>`,
|
||||
/// returns the `i32`.
|
||||
/// this function, given the lowered return type of `foo`, an [`OpaqueDef`] that implements
|
||||
/// `Future<Output=i32>`, returns the `i32`.
|
||||
///
|
||||
/// [`OpaqueDef`]: hir::TyKind::OpaqueDef
|
||||
fn get_future_inner_return_ty(&self, hir_ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
|
||||
|
@ -92,6 +92,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
||||
/// Associate some local constants with the `'tcx` lifetime
|
||||
struct TyCtxtConsts<'tcx>(PhantomData<&'tcx ()>);
|
||||
|
||||
impl<'tcx> TyCtxtConsts<'tcx> {
|
||||
const DEREF_PROJECTION: &'tcx [PlaceElem<'tcx>; 1] = &[ProjectionElem::Deref];
|
||||
}
|
||||
@ -637,7 +638,9 @@ impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
|
||||
);
|
||||
}
|
||||
StatementKind::Intrinsic(box kind) => match kind {
|
||||
NonDivergingIntrinsic::Assume(op) => self.consume_operand(location, (op, span), state),
|
||||
NonDivergingIntrinsic::Assume(op) => {
|
||||
self.consume_operand(location, (op, span), state);
|
||||
}
|
||||
NonDivergingIntrinsic::CopyNonOverlapping(..) => span_bug!(
|
||||
span,
|
||||
"Unexpected CopyNonOverlapping, should only appear after lower_intrinsics",
|
||||
@ -2104,7 +2107,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||
| Write(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind })) => {
|
||||
let is_local_mutation_allowed = match mut_borrow_kind {
|
||||
// `ClosureCapture` is used for mutable variable with an immutable binding.
|
||||
// This is only behaviour difference between `ClosureCapture` and mutable borrows.
|
||||
// This is only behaviour difference between `ClosureCapture` and mutable
|
||||
// borrows.
|
||||
MutBorrowKind::ClosureCapture => LocalMutationIsAllowed::Yes,
|
||||
MutBorrowKind::Default | MutBorrowKind::TwoPhaseBorrow => {
|
||||
is_local_mutation_allowed
|
||||
@ -2349,23 +2353,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||
) => Err(place),
|
||||
(Mutability::Not, LocalMutationIsAllowed::Yes)
|
||||
| (Mutability::Mut, _) => {
|
||||
// Subtle: this is an upvar
|
||||
// reference, so it looks like
|
||||
// `self.foo` -- we want to double
|
||||
// check that the location `*self`
|
||||
// is mutable (i.e., this is not a
|
||||
// `Fn` closure). But if that
|
||||
// check succeeds, we want to
|
||||
// *blame* the mutability on
|
||||
// `place` (that is,
|
||||
// `self.foo`). This is used to
|
||||
// propagate the info about
|
||||
// whether mutability declarations
|
||||
// are used outwards, so that we register
|
||||
// the outer variable as mutable. Otherwise a
|
||||
// test like this fails to record the `mut`
|
||||
// as needed:
|
||||
//
|
||||
// Subtle: this is an upvar reference, so it looks like
|
||||
// `self.foo` -- we want to double check that the location
|
||||
// `*self` is mutable (i.e., this is not a `Fn` closure). But
|
||||
// if that check succeeds, we want to *blame* the mutability on
|
||||
// `place` (that is, `self.foo`). This is used to propagate the
|
||||
// info about whether mutability declarations are used
|
||||
// outwards, so that we register the outer variable as mutable.
|
||||
// Otherwise a test like this fails to record the `mut` as
|
||||
// needed:
|
||||
// ```
|
||||
// fn foo<F: FnOnce()>(_f: F) { }
|
||||
// fn main() {
|
||||
|
@ -1497,6 +1497,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
fn scc_universe(&self, scc: ConstraintSccIndex) -> UniverseIndex {
|
||||
self.constraint_sccs().annotation(scc).min_universe()
|
||||
}
|
||||
|
||||
/// Checks the final value for the free region `fr` to see if it
|
||||
/// grew too large. In particular, examine what `end(X)` points
|
||||
/// wound up in `fr`'s final value; for each `end(X)` where `X !=
|
||||
@ -1669,7 +1670,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
placeholder,
|
||||
});
|
||||
|
||||
// Stop after the first error, it gets too noisy otherwise, and does not provide more information.
|
||||
// Stop after the first error, it gets too noisy otherwise, and does not provide more
|
||||
// information.
|
||||
break;
|
||||
}
|
||||
debug!("check_bound_universal_region: all bounds satisfied");
|
||||
@ -2002,8 +2004,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
|
||||
// We try to avoid reporting a `ConstraintCategory::Predicate` as our best constraint.
|
||||
// Instead, we use it to produce an improved `ObligationCauseCode`.
|
||||
// FIXME - determine what we should do if we encounter multiple `ConstraintCategory::Predicate`
|
||||
// constraints. Currently, we just pick the first one.
|
||||
// FIXME - determine what we should do if we encounter multiple
|
||||
// `ConstraintCategory::Predicate` constraints. Currently, we just pick the first one.
|
||||
let cause_code = path
|
||||
.iter()
|
||||
.find_map(|constraint| {
|
||||
|
@ -145,9 +145,9 @@ 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.
|
||||
// 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(|| {
|
||||
|
@ -59,8 +59,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
)),
|
||||
"this needs to be modified if we're lowering non-async closures"
|
||||
);
|
||||
// Make sure to use the args from `DefiningTy` so the right NLL region vids are prepopulated
|
||||
// into the type.
|
||||
// Make sure to use the args from `DefiningTy` so the right NLL region vids are
|
||||
// prepopulated into the type.
|
||||
let args = args.as_coroutine_closure();
|
||||
let tupled_upvars_ty = ty::CoroutineClosureSignature::tupled_upvars_by_closure_kind(
|
||||
self.tcx(),
|
||||
@ -195,8 +195,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
// doing so ends up causing some other trouble.
|
||||
let b = self.normalize(b, Locations::All(span));
|
||||
|
||||
// Note: if we have to introduce new placeholders during normalization above, then we won't have
|
||||
// added those universes to the universe info, which we would want in `relate_tys`.
|
||||
// Note: if we have to introduce new placeholders during normalization above, then we
|
||||
// won't have added those universes to the universe info, which we would want in
|
||||
// `relate_tys`.
|
||||
if let Err(terr) =
|
||||
self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation)
|
||||
{
|
||||
|
@ -251,7 +251,8 @@ impl<'a, 'typeck, 'b, 'tcx> LivenessResults<'a, 'typeck, 'b, 'tcx> {
|
||||
.collect()
|
||||
};
|
||||
|
||||
// FIXME: these locations seem to have a special meaning (e.g. everywhere, at the end, ...), but I don't know which one. Please help me rename it to something descriptive!
|
||||
// FIXME: these locations seem to have a special meaning (e.g. everywhere, at the end,
|
||||
// ...), but I don't know which one. Please help me rename it to something descriptive!
|
||||
// Also, if this IntervalSet is used in many places, it maybe should have a newtype'd
|
||||
// name with a description of what it means for future mortals passing by.
|
||||
let locations = IntervalSet::new(self.cx.elements.num_points());
|
||||
|
@ -1606,9 +1606,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
|
||||
let func_ty = func.ty(body, self.infcx.tcx);
|
||||
if let ty::FnDef(def_id, _) = *func_ty.kind() {
|
||||
// Some of the SIMD intrinsics are special: they need a particular argument to be a constant.
|
||||
// (Eventually this should use const-generics, but those are not up for the task yet:
|
||||
// https://github.com/rust-lang/rust/issues/85229.)
|
||||
// Some of the SIMD intrinsics are special: they need a particular argument to be a
|
||||
// constant. (Eventually this should use const-generics, but those are not up for the
|
||||
// task yet: https://github.com/rust-lang/rust/issues/85229.)
|
||||
if let Some(name @ (sym::simd_shuffle | sym::simd_insert | sym::simd_extract)) =
|
||||
self.tcx().intrinsic(def_id).map(|i| i.name)
|
||||
{
|
||||
@ -1921,7 +1921,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
if len.try_to_target_usize(tcx).is_none_or(|len| len > 1) {
|
||||
match operand {
|
||||
Operand::Copy(..) | Operand::Constant(..) => {
|
||||
// These are always okay: direct use of a const, or a value that can evidently be copied.
|
||||
// These are always okay: direct use of a const, or a value that can
|
||||
// evidently be copied.
|
||||
}
|
||||
Operand::Move(place) => {
|
||||
// Make sure that repeated elements implement `Copy`.
|
||||
@ -2402,9 +2403,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
let dst_tail = self.struct_tail(dst.ty, location);
|
||||
|
||||
// This checks (lifetime part of) vtable validity for pointer casts,
|
||||
// which is irrelevant when there are aren't principal traits on both sides (aka only auto traits).
|
||||
// which is irrelevant when there are aren't principal traits on
|
||||
// both sides (aka only auto traits).
|
||||
//
|
||||
// Note that other checks (such as denying `dyn Send` -> `dyn Debug`) are in `rustc_hir_typeck`.
|
||||
// Note that other checks (such as denying `dyn Send` -> `dyn
|
||||
// Debug`) are in `rustc_hir_typeck`.
|
||||
if let ty::Dynamic(src_tty, ..) = src_tail.kind()
|
||||
&& let ty::Dynamic(dst_tty, ..) = dst_tail.kind()
|
||||
&& src_tty.principal().is_some()
|
||||
@ -2427,8 +2430,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
ty::Dyn,
|
||||
));
|
||||
|
||||
// Replace trait object lifetimes with fresh vars, to allow casts like
|
||||
// `*mut dyn FnOnce() + 'a` -> `*mut dyn FnOnce() + 'static`,
|
||||
// Replace trait object lifetimes with fresh vars, to allow
|
||||
// casts like
|
||||
// `*mut dyn FnOnce() + 'a` -> `*mut dyn FnOnce() + 'static`
|
||||
let src_obj =
|
||||
freshen_single_trait_object_lifetime(self.infcx, src_obj);
|
||||
let dst_obj =
|
||||
|
Loading…
Reference in New Issue
Block a user