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 sccs = self.regioncx.constraint_sccs();
|
||||||
let universal_regions = self.regioncx.universal_regions();
|
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
|
// We first handle the cases where the loan doesn't go out of scope, depending on the
|
||||||
// region's successors.
|
// issuing region's successors.
|
||||||
for successor in graph::depth_first_search(&self.regioncx.region_graph(), issuing_region) {
|
for successor in graph::depth_first_search(&self.regioncx.region_graph(), issuing_region) {
|
||||||
// 1. Via applied member constraints
|
// 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
|
// `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
|
||||||
// `ObligationCause`. The normalization results are currently different between
|
// `ObligationCause`. The normalization results are currently different between
|
||||||
// `QueryNormalizeExt::query_normalize` used in the query and `normalize` called below:
|
// `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.
|
// the former fails to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs`
|
||||||
// Check after #85499 lands to see if its fixes have erased this difference.
|
// test. Check after #85499 lands to see if its fixes have erased this difference.
|
||||||
let (param_env, value) = key.into_parts();
|
let (param_env, value) = key.into_parts();
|
||||||
let _ = ocx.normalize(&cause, param_env, value.value);
|
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`
|
// See `tests/ui/moves/needs-clone-through-deref.rs`
|
||||||
return false;
|
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) {
|
if self.in_move_closure(expr) {
|
||||||
return false;
|
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 {
|
if let hir::ExprKind::Closure(_) = expr.kind {
|
||||||
return false;
|
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 {
|
if inner_expr.span.lo() != expr.span.lo() && !is_raw_ptr {
|
||||||
// Remove "(*" or "(&"
|
// Remove "(*" or "(&"
|
||||||
sugg.push((expr.span.with_hi(inner_expr.span.lo()), String::new()));
|
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 use_spans = self.move_spans(place.as_ref(), location);
|
||||||
let span = use_spans.var_or_use();
|
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
|
// If the attempted use is in a closure then we do not care about the path span of the
|
||||||
// we call `var_span_label` on `borrow_spans` to annotate if the existing borrow was in a closure
|
// 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(
|
let mut err = self.cannot_use_when_mutably_borrowed(
|
||||||
span,
|
span,
|
||||||
&self.describe_any_place(place.as_ref()),
|
&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
|
if let hir::ExprKind::Closure(closure) = ex.kind
|
||||||
&& ex.span.contains(self.borrow_span)
|
&& ex.span.contains(self.borrow_span)
|
||||||
// To support cases like `|| { v.call(|this| v.get()) }`
|
// 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.as_ref().map_or(true, |(prev_res, _)| prev_res.span.contains(ex.span))
|
||||||
{
|
{
|
||||||
self.res = Some((ex, closure));
|
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`.
|
/// 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
|
/// 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.
|
/// 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`,
|
/// We found the `prop_expr` by the way to check whether the expression is a
|
||||||
/// which is a special case since it's generated by the compiler.
|
/// `FormatArguments`, which is a special case since it's generated by the
|
||||||
|
/// compiler.
|
||||||
struct NestedStatementVisitor<'tcx> {
|
struct NestedStatementVisitor<'tcx> {
|
||||||
span: Span,
|
span: Span,
|
||||||
current: usize,
|
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) {
|
let (sugg_span, suggestion) = match tcx.sess.source_map().span_to_snippet(args_span) {
|
||||||
Ok(string) => {
|
Ok(string) => {
|
||||||
let coro_prefix = if string.starts_with("async") {
|
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)
|
Some(5)
|
||||||
} else if string.starts_with("gen") {
|
} else if string.starts_with("gen") {
|
||||||
// `gen` is 3 chars long
|
// `gen` is 3 chars long
|
||||||
@ -3618,10 +3625,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||||||
let stmt_kind =
|
let stmt_kind =
|
||||||
self.body[location.block].statements.get(location.statement_index).map(|s| &s.kind);
|
self.body[location.block].statements.get(location.statement_index).map(|s| &s.kind);
|
||||||
if let Some(StatementKind::StorageDead(..)) = stmt_kind {
|
if let Some(StatementKind::StorageDead(..)) = stmt_kind {
|
||||||
// this analysis only tries to find moves explicitly
|
// This analysis only tries to find moves explicitly written by the user, so we
|
||||||
// written by the user, so we ignore the move-outs
|
// ignore the move-outs created by `StorageDead` and at the beginning of a
|
||||||
// created by `StorageDead` and at the beginning
|
// function.
|
||||||
// of a function.
|
|
||||||
} else {
|
} else {
|
||||||
// If we are found a use of a.b.c which was in error, then we want to look for
|
// 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.
|
// 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() {
|
if (is_argument || !reached_start) && result.is_empty() {
|
||||||
/* Process back edges (moves in future loop iterations) only if
|
// Process back edges (moves in future loop iterations) only if
|
||||||
the move path is definitely initialized upon loop entry,
|
// the move path is definitely initialized upon loop entry,
|
||||||
to avoid spurious "in previous iteration" errors.
|
// to avoid spurious "in previous iteration" errors.
|
||||||
During DFS, if there's a path from the error back to the start
|
// 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
|
// of the function with no intervening init or move, then the
|
||||||
move path may be uninitialized at loop entry.
|
// move path may be uninitialized at loop entry.
|
||||||
*/
|
|
||||||
while let Some(location) = back_edge_stack.pop() {
|
while let Some(location) = back_edge_stack.pop() {
|
||||||
if dfs_iter(&mut result, location, true) {
|
if dfs_iter(&mut result, location, true) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -130,7 +130,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||||||
{
|
{
|
||||||
suggest_rewrite_if_let(tcx, expr, &pat, init, conseq, alt, err);
|
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) {
|
} 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)) {
|
if borrow_span.map_or(true, |sp| !sp.overlaps(var_or_use_span)) {
|
||||||
err.span_label(
|
err.span_label(
|
||||||
var_or_use_span,
|
var_or_use_span,
|
||||||
@ -165,7 +166,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||||||
LaterUseKind::FakeLetRead => "borrow later stored here",
|
LaterUseKind::FakeLetRead => "borrow later stored here",
|
||||||
LaterUseKind::Other => "borrow used here, in later iteration of loop",
|
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) {
|
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}"));
|
err.span_label(var_or_use_span, format!("{borrow_desc}{message}"));
|
||||||
} else {
|
} else {
|
||||||
@ -285,7 +287,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||||||
span: _,
|
span: _,
|
||||||
pat,
|
pat,
|
||||||
init,
|
init,
|
||||||
// FIXME(#101728): enable rewrite when type ascription is stabilized again
|
// FIXME(#101728): enable rewrite when type ascription is
|
||||||
|
// stabilized again.
|
||||||
ty: None,
|
ty: None,
|
||||||
recovered: _,
|
recovered: _,
|
||||||
}) = cond.kind
|
}) = cond.kind
|
||||||
@ -353,8 +356,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||||||
unsize_ty: Ty<'tcx>,
|
unsize_ty: Ty<'tcx>,
|
||||||
) {
|
) {
|
||||||
if let ty::Adt(def, args) = unsize_ty.kind() {
|
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
|
// We try to elaborate the object lifetime defaults and present those to the user. This
|
||||||
// make it clear where the region constraint is coming from.
|
// should make it clear where the region constraint is coming from.
|
||||||
let generics = tcx.generics_of(def.did());
|
let generics = tcx.generics_of(def.did());
|
||||||
|
|
||||||
let mut has_dyn = false;
|
let mut has_dyn = false;
|
||||||
@ -531,9 +534,10 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
|||||||
let mut use_in_later_iteration_of_loop = false;
|
let mut use_in_later_iteration_of_loop = false;
|
||||||
|
|
||||||
if region_sub == borrow_region_vid {
|
if region_sub == borrow_region_vid {
|
||||||
// When `region_sub` is the same as `borrow_region_vid` (the location where the borrow is
|
// When `region_sub` is the same as `borrow_region_vid` (the location where the borrow
|
||||||
// issued is the same location that invalidates the reference), this is likely a loop iteration
|
// is issued is the same location that invalidates the reference), this is likely a
|
||||||
// - in this case, try using the loop terminator location in `find_sub_region_live_at`.
|
// loop iteration. In this case, try using the loop terminator location in
|
||||||
|
// `find_sub_region_live_at`.
|
||||||
if let Some(loop_terminator_location) =
|
if let Some(loop_terminator_location) =
|
||||||
regioncx.find_loop_terminator_location(borrow.region, body)
|
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 {
|
struct CapturedMessageOpt {
|
||||||
is_partial_move: bool,
|
is_partial_move: bool,
|
||||||
is_loop_message: 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 reason = if let PlaceBase::Upvar(upvar_id) = closure_kind_origin.base {
|
||||||
let upvar = ty::place_to_string_for_capture(tcx, closure_kind_origin);
|
let upvar = ty::place_to_string_for_capture(tcx, closure_kind_origin);
|
||||||
let root_hir_id = upvar_id.var_path.hir_id;
|
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 =
|
let captured_places =
|
||||||
tables.closure_min_captures[&closure_local_def_id].get(&root_hir_id).unwrap();
|
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,
|
// If we can detect the expression to be an function or method call where the closure was
|
||||||
// we point at the function or method definition argument...
|
// an argument, we point at the function or method definition argument...
|
||||||
if let Some((callee_def_id, call_span, call_args)) = get_call_details() {
|
if let Some((callee_def_id, call_span, call_args)) = get_call_details() {
|
||||||
let arg_pos = call_args
|
let arg_pos = call_args
|
||||||
.iter()
|
.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
|
/// 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`.
|
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get
|
||||||
/// This helps to print the right kinds of diagnostics.
|
/// `Static`. This helps to print the right kinds of diagnostics.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub(crate) enum RegionNameSource {
|
pub(crate) enum RegionNameSource {
|
||||||
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
|
/// 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 }
|
/// async fn foo() -> i32 { 2 }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// this function, given the lowered return type of `foo`, an [`OpaqueDef`] that implements `Future<Output=i32>`,
|
/// this function, given the lowered return type of `foo`, an [`OpaqueDef`] that implements
|
||||||
/// returns the `i32`.
|
/// `Future<Output=i32>`, returns the `i32`.
|
||||||
///
|
///
|
||||||
/// [`OpaqueDef`]: hir::TyKind::OpaqueDef
|
/// [`OpaqueDef`]: hir::TyKind::OpaqueDef
|
||||||
fn get_future_inner_return_ty(&self, hir_ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
|
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
|
/// Associate some local constants with the `'tcx` lifetime
|
||||||
struct TyCtxtConsts<'tcx>(PhantomData<&'tcx ()>);
|
struct TyCtxtConsts<'tcx>(PhantomData<&'tcx ()>);
|
||||||
|
|
||||||
impl<'tcx> TyCtxtConsts<'tcx> {
|
impl<'tcx> TyCtxtConsts<'tcx> {
|
||||||
const DEREF_PROJECTION: &'tcx [PlaceElem<'tcx>; 1] = &[ProjectionElem::Deref];
|
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 {
|
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!(
|
NonDivergingIntrinsic::CopyNonOverlapping(..) => span_bug!(
|
||||||
span,
|
span,
|
||||||
"Unexpected CopyNonOverlapping, should only appear after lower_intrinsics",
|
"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 })) => {
|
| Write(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind })) => {
|
||||||
let is_local_mutation_allowed = match mut_borrow_kind {
|
let is_local_mutation_allowed = match mut_borrow_kind {
|
||||||
// `ClosureCapture` is used for mutable variable with an immutable binding.
|
// `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::ClosureCapture => LocalMutationIsAllowed::Yes,
|
||||||
MutBorrowKind::Default | MutBorrowKind::TwoPhaseBorrow => {
|
MutBorrowKind::Default | MutBorrowKind::TwoPhaseBorrow => {
|
||||||
is_local_mutation_allowed
|
is_local_mutation_allowed
|
||||||
@ -2349,23 +2353,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
|||||||
) => Err(place),
|
) => Err(place),
|
||||||
(Mutability::Not, LocalMutationIsAllowed::Yes)
|
(Mutability::Not, LocalMutationIsAllowed::Yes)
|
||||||
| (Mutability::Mut, _) => {
|
| (Mutability::Mut, _) => {
|
||||||
// Subtle: this is an upvar
|
// Subtle: this is an upvar reference, so it looks like
|
||||||
// reference, so it looks like
|
// `self.foo` -- we want to double check that the location
|
||||||
// `self.foo` -- we want to double
|
// `*self` is mutable (i.e., this is not a `Fn` closure). But
|
||||||
// check that the location `*self`
|
// if that check succeeds, we want to *blame* the mutability on
|
||||||
// is mutable (i.e., this is not a
|
// `place` (that is, `self.foo`). This is used to propagate the
|
||||||
// `Fn` closure). But if that
|
// info about whether mutability declarations are used
|
||||||
// check succeeds, we want to
|
// outwards, so that we register the outer variable as mutable.
|
||||||
// *blame* the mutability on
|
// Otherwise a test like this fails to record the `mut` as
|
||||||
// `place` (that is,
|
// needed:
|
||||||
// `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 foo<F: FnOnce()>(_f: F) { }
|
||||||
// fn main() {
|
// fn main() {
|
||||||
|
@ -1497,6 +1497,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
fn scc_universe(&self, scc: ConstraintSccIndex) -> UniverseIndex {
|
fn scc_universe(&self, scc: ConstraintSccIndex) -> UniverseIndex {
|
||||||
self.constraint_sccs().annotation(scc).min_universe()
|
self.constraint_sccs().annotation(scc).min_universe()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks the final value for the free region `fr` to see if it
|
/// Checks the final value for the free region `fr` to see if it
|
||||||
/// grew too large. In particular, examine what `end(X)` points
|
/// grew too large. In particular, examine what `end(X)` points
|
||||||
/// wound up in `fr`'s final value; for each `end(X)` where `X !=
|
/// wound up in `fr`'s final value; for each `end(X)` where `X !=
|
||||||
@ -1669,7 +1670,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
placeholder,
|
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;
|
break;
|
||||||
}
|
}
|
||||||
debug!("check_bound_universal_region: all bounds satisfied");
|
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.
|
// We try to avoid reporting a `ConstraintCategory::Predicate` as our best constraint.
|
||||||
// Instead, we use it to produce an improved `ObligationCauseCode`.
|
// Instead, we use it to produce an improved `ObligationCauseCode`.
|
||||||
// FIXME - determine what we should do if we encounter multiple `ConstraintCategory::Predicate`
|
// FIXME - determine what we should do if we encounter multiple
|
||||||
// constraints. Currently, we just pick the first one.
|
// `ConstraintCategory::Predicate` constraints. Currently, we just pick the first one.
|
||||||
let cause_code = path
|
let cause_code = path
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|constraint| {
|
.find_map(|constraint| {
|
||||||
|
@ -145,9 +145,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Sometimes two opaque types are the same only after we remap the generic parameters
|
// 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)`
|
// back to the opaque type definition. E.g. we may have `OpaqueType<X, Y>` mapped to
|
||||||
// and `OpaqueType<Y, X>` mapped to `(Y, X)`, and those are the same, but we only know that
|
// `(X, Y)` and `OpaqueType<Y, X>` mapped to `(Y, X)`, and those are the same, but we
|
||||||
// once we convert the generic parameters to those of the opaque type.
|
// 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 let Some(prev) = result.get_mut(&opaque_type_key.def_id) {
|
||||||
if prev.ty != ty {
|
if prev.ty != ty {
|
||||||
let guar = ty.error_reported().err().unwrap_or_else(|| {
|
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"
|
"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
|
// Make sure to use the args from `DefiningTy` so the right NLL region vids are
|
||||||
// into the type.
|
// prepopulated into the type.
|
||||||
let args = args.as_coroutine_closure();
|
let args = args.as_coroutine_closure();
|
||||||
let tupled_upvars_ty = ty::CoroutineClosureSignature::tupled_upvars_by_closure_kind(
|
let tupled_upvars_ty = ty::CoroutineClosureSignature::tupled_upvars_by_closure_kind(
|
||||||
self.tcx(),
|
self.tcx(),
|
||||||
@ -195,8 +195,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
// doing so ends up causing some other trouble.
|
// doing so ends up causing some other trouble.
|
||||||
let b = self.normalize(b, Locations::All(span));
|
let b = self.normalize(b, Locations::All(span));
|
||||||
|
|
||||||
// Note: if we have to introduce new placeholders during normalization above, then we won't have
|
// Note: if we have to introduce new placeholders during normalization above, then we
|
||||||
// added those universes to the universe info, which we would want in `relate_tys`.
|
// won't have added those universes to the universe info, which we would want in
|
||||||
|
// `relate_tys`.
|
||||||
if let Err(terr) =
|
if let Err(terr) =
|
||||||
self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation)
|
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()
|
.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
|
// 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.
|
// name with a description of what it means for future mortals passing by.
|
||||||
let locations = IntervalSet::new(self.cx.elements.num_points());
|
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);
|
let func_ty = func.ty(body, self.infcx.tcx);
|
||||||
if let ty::FnDef(def_id, _) = *func_ty.kind() {
|
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.
|
// Some of the SIMD intrinsics are special: they need a particular argument to be a
|
||||||
// (Eventually this should use const-generics, but those are not up for the task yet:
|
// constant. (Eventually this should use const-generics, but those are not up for the
|
||||||
// https://github.com/rust-lang/rust/issues/85229.)
|
// task yet: https://github.com/rust-lang/rust/issues/85229.)
|
||||||
if let Some(name @ (sym::simd_shuffle | sym::simd_insert | sym::simd_extract)) =
|
if let Some(name @ (sym::simd_shuffle | sym::simd_insert | sym::simd_extract)) =
|
||||||
self.tcx().intrinsic(def_id).map(|i| i.name)
|
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) {
|
if len.try_to_target_usize(tcx).is_none_or(|len| len > 1) {
|
||||||
match operand {
|
match operand {
|
||||||
Operand::Copy(..) | Operand::Constant(..) => {
|
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) => {
|
Operand::Move(place) => {
|
||||||
// Make sure that repeated elements implement `Copy`.
|
// 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);
|
let dst_tail = self.struct_tail(dst.ty, location);
|
||||||
|
|
||||||
// This checks (lifetime part of) vtable validity for pointer casts,
|
// 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()
|
if let ty::Dynamic(src_tty, ..) = src_tail.kind()
|
||||||
&& let ty::Dynamic(dst_tty, ..) = dst_tail.kind()
|
&& let ty::Dynamic(dst_tty, ..) = dst_tail.kind()
|
||||||
&& src_tty.principal().is_some()
|
&& src_tty.principal().is_some()
|
||||||
@ -2427,8 +2430,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
ty::Dyn,
|
ty::Dyn,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Replace trait object lifetimes with fresh vars, to allow casts like
|
// Replace trait object lifetimes with fresh vars, to allow
|
||||||
// `*mut dyn FnOnce() + 'a` -> `*mut dyn FnOnce() + 'static`,
|
// casts like
|
||||||
|
// `*mut dyn FnOnce() + 'a` -> `*mut dyn FnOnce() + 'static`
|
||||||
let src_obj =
|
let src_obj =
|
||||||
freshen_single_trait_object_lifetime(self.infcx, src_obj);
|
freshen_single_trait_object_lifetime(self.infcx, src_obj);
|
||||||
let dst_obj =
|
let dst_obj =
|
||||||
|
Loading…
Reference in New Issue
Block a user