Auto merge of #104809 - matthiaskrgr:rollup-8abjdwh, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #103908 (Suggest `.clone()` or `ref binding` on E0382)
 - #104517 (Throw error on failure in loading llvm-plugin)
 - #104594 (Properly handle `Pin<&mut dyn* Trait>` receiver in codegen)
 - #104742 (Make `deref_into_dyn_supertrait` lint the impl and not the usage)
 - #104753 (Pass `InferCtxt` to `DropRangeVisitor` so we can resolve vars)
 - #104771 (Add regression test for issue #99938)
 - #104772 (Small accessibility improvements)
 - #104775 (Use ObligationCtxt::normalize)
 - #104778 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-11-24 09:44:46 +00:00
commit 1dda298ad3
253 changed files with 4093 additions and 1180 deletions

View file

@ -1376,7 +1376,7 @@ pub enum ExprKind {
/// Conditionless loop (can be exited with `break`, `continue`, or `return`).
///
/// `'label: loop { block }`
Loop(P<Block>, Option<Label>),
Loop(P<Block>, Option<Label>, Span),
/// A `match` block.
Match(P<Expr>, Vec<Arm>),
/// A closure (e.g., `move |a, b, c| a + b + c`).

View file

@ -1355,9 +1355,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
vis.visit_block(body);
visit_opt(label, |label| vis.visit_label(label));
}
ExprKind::Loop(body, label) => {
ExprKind::Loop(body, label, span) => {
vis.visit_block(body);
visit_opt(label, |label| vis.visit_label(label));
vis.visit_span(span);
}
ExprKind::Match(expr, arms) => {
vis.visit_expr(expr);

View file

@ -824,7 +824,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
visitor.visit_expr(subexpression);
visitor.visit_block(block);
}
ExprKind::Loop(block, opt_label) => {
ExprKind::Loop(block, opt_label, _) => {
walk_list!(visitor, visit_label, opt_label);
visitor.visit_block(block);
}

View file

@ -131,12 +131,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
let span = this.mark_span_with_reason(DesugaringKind::WhileLoop, e.span, None);
this.lower_expr_while_in_loop_scope(span, cond, body, *opt_label)
}),
ExprKind::Loop(body, opt_label) => self.with_loop_scope(e.id, |this| {
ExprKind::Loop(body, opt_label, span) => self.with_loop_scope(e.id, |this| {
hir::ExprKind::Loop(
this.lower_block(body, false),
this.lower_label(*opt_label),
hir::LoopSource::Loop,
DUMMY_SP,
this.lower_span(*span),
)
}),
ExprKind::TryBlock(body) => self.lower_expr_try_block(body),

View file

@ -377,7 +377,7 @@ impl<'a> State<'a> {
self.space();
self.print_block_with_attrs(blk, attrs);
}
ast::ExprKind::Loop(ref blk, opt_label) => {
ast::ExprKind::Loop(ref blk, opt_label, _) => {
if let Some(label) = opt_label {
self.print_ident(label.ident);
self.word_space(":");

View file

@ -167,10 +167,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
}
self.add_moved_or_invoked_closure_note(location, used_place, &mut err);
let closure = self.add_moved_or_invoked_closure_note(location, used_place, &mut err);
let mut is_loop_move = false;
let mut in_pattern = false;
let mut seen_spans = FxHashSet::default();
for move_site in &move_site_vec {
let move_out = self.move_data.moves[(*move_site).moi];
@ -191,37 +192,25 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
is_loop_move = true;
}
self.explain_captures(
&mut err,
span,
move_span,
move_spans,
*moved_place,
partially_str,
loop_message,
move_msg,
is_loop_move,
maybe_reinitialized_locations.is_empty(),
);
if let (UseSpans::PatUse(span), []) =
(move_spans, &maybe_reinitialized_locations[..])
{
if maybe_reinitialized_locations.is_empty() {
err.span_suggestion_verbose(
span.shrink_to_lo(),
&format!(
"borrow this field in the pattern to avoid moving {}",
self.describe_place(moved_place.as_ref())
.map(|n| format!("`{}`", n))
.unwrap_or_else(|| "the value".to_string())
),
"ref ",
Applicability::MachineApplicable,
);
in_pattern = true;
if !seen_spans.contains(&move_span) {
if !closure {
self.suggest_ref_or_clone(mpi, move_span, &mut err, &mut in_pattern);
}
self.explain_captures(
&mut err,
span,
move_span,
move_spans,
*moved_place,
partially_str,
loop_message,
move_msg,
is_loop_move,
maybe_reinitialized_locations.is_empty(),
);
}
seen_spans.insert(move_span);
}
use_spans.var_path_only_subdiag(&mut err, desired_action);
@ -317,6 +306,160 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}
fn suggest_ref_or_clone(
&mut self,
mpi: MovePathIndex,
move_span: Span,
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
in_pattern: &mut bool,
) {
struct ExpressionFinder<'hir> {
expr_span: Span,
expr: Option<&'hir hir::Expr<'hir>>,
pat: Option<&'hir hir::Pat<'hir>>,
parent_pat: Option<&'hir hir::Pat<'hir>>,
}
impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> {
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
if e.span == self.expr_span {
self.expr = Some(e);
}
hir::intravisit::walk_expr(self, e);
}
fn visit_pat(&mut self, p: &'hir hir::Pat<'hir>) {
if p.span == self.expr_span {
self.pat = Some(p);
}
if let hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, i, sub) = p.kind {
if i.span == self.expr_span || p.span == self.expr_span {
self.pat = Some(p);
}
// Check if we are in a situation of `ident @ ident` where we want to suggest
// `ref ident @ ref ident` or `ref ident @ Struct { ref ident }`.
if let Some(subpat) = sub && self.pat.is_none() {
self.visit_pat(subpat);
if self.pat.is_some() {
self.parent_pat = Some(p);
}
return;
}
}
hir::intravisit::walk_pat(self, p);
}
}
let hir = self.infcx.tcx.hir();
if let Some(hir::Node::Item(hir::Item {
kind: hir::ItemKind::Fn(_, _, body_id),
..
})) = hir.find(hir.local_def_id_to_hir_id(self.mir_def_id()))
&& let Some(hir::Node::Expr(expr)) = hir.find(body_id.hir_id)
{
let place = &self.move_data.move_paths[mpi].place;
let span = place.as_local()
.map(|local| self.body.local_decls[local].source_info.span);
let mut finder = ExpressionFinder {
expr_span: move_span,
expr: None,
pat: None,
parent_pat: None,
};
finder.visit_expr(expr);
if let Some(span) = span && let Some(expr) = finder.expr {
for (_, expr) in hir.parent_iter(expr.hir_id) {
if let hir::Node::Expr(expr) = expr {
if expr.span.contains(span) {
// If the let binding occurs within the same loop, then that
// loop isn't relevant, like in the following, the outermost `loop`
// doesn't play into `x` being moved.
// ```
// loop {
// let x = String::new();
// loop {
// foo(x);
// }
// }
// ```
break;
}
if let hir::ExprKind::Loop(.., loop_span) = expr.kind {
err.span_label(loop_span, "inside of this loop");
}
}
}
let typeck = self.infcx.tcx.typeck(self.mir_def_id());
let hir_id = hir.get_parent_node(expr.hir_id);
if let Some(parent) = hir.find(hir_id) {
let (def_id, args, offset) = if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::MethodCall(_, _, args, _) = parent_expr.kind
&& let Some(def_id) = typeck.type_dependent_def_id(parent_expr.hir_id)
{
(def_id.as_local(), args, 1)
} else if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::Call(call, args) = parent_expr.kind
&& let ty::FnDef(def_id, _) = typeck.node_type(call.hir_id).kind()
{
(def_id.as_local(), args, 0)
} else {
(None, &[][..], 0)
};
if let Some(def_id) = def_id
&& let Some(node) = hir.find(hir.local_def_id_to_hir_id(def_id))
&& let Some(fn_sig) = node.fn_sig()
&& let Some(ident) = node.ident()
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
&& let Some(arg) = fn_sig.decl.inputs.get(pos + offset)
{
let mut span: MultiSpan = arg.span.into();
span.push_span_label(
arg.span,
"this parameter takes ownership of the value".to_string(),
);
let descr = match node.fn_kind() {
Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function",
Some(hir::intravisit::FnKind::Method(..)) => "method",
Some(hir::intravisit::FnKind::Closure) => "closure",
};
span.push_span_label(
ident.span,
format!("in this {descr}"),
);
err.span_note(
span,
format!(
"consider changing this parameter type in {descr} `{ident}` to \
borrow instead if owning the value isn't necessary",
),
);
}
let place = &self.move_data.move_paths[mpi].place;
let ty = place.ty(self.body, self.infcx.tcx).ty;
if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::Call(call_expr, _) = parent_expr.kind
&& let hir::ExprKind::Path(
hir::QPath::LangItem(LangItem::IntoIterIntoIter, _, _)
) = call_expr.kind
{
// Do not suggest `.clone()` in a `for` loop, we already suggest borrowing.
} else {
self.suggest_cloning(err, ty, move_span);
}
}
}
if let Some(pat) = finder.pat {
*in_pattern = true;
let mut sugg = vec![(pat.span.shrink_to_lo(), "ref ".to_string())];
if let Some(pat) = finder.parent_pat {
sugg.insert(0, (pat.span.shrink_to_lo(), "ref ".to_string()));
}
err.multipart_suggestion_verbose(
"borrow this binding in the pattern to avoid moving the value",
sugg,
Applicability::MachineApplicable,
);
}
}
}
fn report_use_of_uninitialized(
&self,
mpi: MovePathIndex,
@ -590,6 +733,27 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
true
}
fn suggest_cloning(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
let tcx = self.infcx.tcx;
// Try to find predicates on *generic params* that would allow copying `ty`
let infcx = tcx.infer_ctxt().build();
if infcx
.type_implements_trait(
tcx.lang_items().clone_trait().unwrap(),
[tcx.erase_regions(ty)],
self.param_env,
)
.must_apply_modulo_regions()
{
err.span_suggestion_verbose(
span.shrink_to_hi(),
"consider cloning the value if the performance cost is acceptable",
".clone()".to_string(),
Applicability::MachineApplicable,
);
}
}
fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
let tcx = self.infcx.tcx;
let generics = tcx.generics_of(self.mir_def_id());

View file

@ -70,7 +70,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location: Location,
place: PlaceRef<'tcx>,
diag: &mut Diagnostic,
) {
) -> bool {
debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place);
let mut target = place.local_or_deref_local();
for stmt in &self.body[location.block].statements[location.statement_index..] {
@ -106,7 +106,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
{
place.local_or_deref_local().unwrap()
}
_ => return,
_ => return false,
};
debug!("add_moved_or_invoked_closure_note: closure={:?}", closure);
@ -125,7 +125,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
ty::place_to_string_for_capture(self.infcx.tcx, hir_place)
),
);
return;
return true;
}
}
}
@ -149,9 +149,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
ty::place_to_string_for_capture(self.infcx.tcx, hir_place)
),
);
return true;
}
}
}
false
}
/// End-user visible description of `place` if one can be found.

View file

@ -307,7 +307,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
| ExprKind::InlineAsm(_)
| ExprKind::Let(_, _, _)
| ExprKind::Lit(_)
| ExprKind::Loop(_, _)
| ExprKind::Loop(_, _, _)
| ExprKind::MacCall(_)
| ExprKind::Match(_, _)
| ExprKind::Path(_, _)

View file

@ -938,7 +938,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// that is understood elsewhere in the compiler as a method on
// `dyn Trait`.
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
// we get a value of a built-in pointer type
// we get a value of a built-in pointer type.
//
// This is also relevant for `Pin<&mut Self>`, where we need to peel the `Pin`.
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
&& !op.layout.ty.is_region_ptr()
{
@ -980,13 +982,29 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
continue;
}
Immediate(_) => {
let ty::Ref(_, ty, _) = op.layout.ty.kind() else {
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
};
if !ty.is_dyn_star() {
// See comment above explaining why we peel these newtypes
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
&& !op.layout.ty.is_region_ptr()
{
for i in 0..op.layout.fields.count() {
let field = op.extract_field(bx, i);
if !field.layout.is_zst() {
// we found the one non-zero-sized field that is allowed
// now find *its* non-zero-sized field, or stop if it's a
// pointer
op = field;
continue 'descend_newtypes;
}
}
span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
}
// Make sure that we've actually unwrapped the rcvr down
// to a pointer or ref to `dyn* Trait`.
if !op.layout.ty.builtin_deref(true).unwrap().ty.is_dyn_star() {
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
}
// FIXME(dyn-star): Make sure this is done on a &dyn* receiver
let place = op.deref(bx.cx());
let data_ptr = place.project_field(bx, 0);
let meta_ptr = place.project_field(bx, 1);

View file

@ -218,14 +218,11 @@ fn compare_predicate_entailment<'tcx>(
debug!("compare_impl_method: caller_bounds={:?}", param_env.caller_bounds());
let mut selcx = traits::SelectionContext::new(&infcx);
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs);
for (predicate, span) in iter::zip(impl_m_own_bounds.predicates, impl_m_own_bounds.spans) {
let normalize_cause = traits::ObligationCause::misc(span, impl_m_hir_id);
let traits::Normalized { value: predicate, obligations } =
traits::normalize(&mut selcx, param_env, normalize_cause, predicate);
let predicate = ocx.normalize(normalize_cause, param_env, predicate);
ocx.register_obligations(obligations);
let cause = ObligationCause::new(
span,
impl_m_hir_id,
@ -1555,14 +1552,11 @@ fn compare_type_predicate_entailment<'tcx>(
debug!("compare_type_predicate_entailment: caller_bounds={:?}", param_env.caller_bounds());
let mut selcx = traits::SelectionContext::new(&infcx);
assert_eq!(impl_ty_own_bounds.predicates.len(), impl_ty_own_bounds.spans.len());
for (span, predicate) in std::iter::zip(impl_ty_own_bounds.spans, impl_ty_own_bounds.predicates)
{
let cause = ObligationCause::misc(span, impl_ty_hir_id);
let traits::Normalized { value: predicate, obligations } =
traits::normalize(&mut selcx, param_env, cause, predicate);
let predicate = ocx.normalize(cause, param_env, predicate);
let cause = ObligationCause::new(
span,
@ -1573,7 +1567,6 @@ fn compare_type_predicate_entailment<'tcx>(
kind: impl_ty.kind,
},
);
ocx.register_obligations(obligations);
ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate));
}
@ -1756,7 +1749,6 @@ pub fn check_type_bounds<'tcx>(
let assumed_wf_types =
ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty.def_id.expect_local());
let mut selcx = traits::SelectionContext::new(&infcx);
let normalize_cause = ObligationCause::new(
impl_ty_span,
impl_ty_hir_id,
@ -1785,16 +1777,11 @@ pub fn check_type_bounds<'tcx>(
debug!("check_type_bounds: item_bounds={:?}", obligations);
for mut obligation in util::elaborate_obligations(tcx, obligations) {
let traits::Normalized { value: normalized_predicate, obligations } = traits::normalize(
&mut selcx,
normalize_param_env,
normalize_cause.clone(),
obligation.predicate,
);
let normalized_predicate =
ocx.normalize(normalize_cause.clone(), normalize_param_env, obligation.predicate);
debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate);
obligation.predicate = normalized_predicate;
ocx.register_obligations(obligations);
ocx.register_obligation(obligation);
}
// Check that all obligations are satisfied by the implementation's

View file

@ -755,20 +755,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
if let ty::Dynamic(a_data, _, _) = a.kind()
&& let ty::Dynamic(b_data, _, _) = b.kind()
&& a_data.principal_def_id() == b_data.principal_def_id()
{
if a_data.principal_def_id() == b_data.principal_def_id() {
return self.unify_and(a, b, |_| vec![]);
} else if !self.tcx().features().trait_upcasting {
let mut err = feature_err(
&self.tcx.sess.parse_sess,
sym::trait_upcasting,
self.cause.span,
&format!(
"cannot cast `{a}` to `{b}`, trait upcasting coercion is experimental"
),
);
err.emit();
}
return self.unify_and(a, b, |_| vec![]);
}
// Check the obligations of the cast -- for example, when casting
@ -796,19 +785,16 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
])
.collect();
// Enforce that the type is `usize`/pointer-sized. For now, only those
// can be coerced to `dyn*`, except for `dyn* -> dyn*` upcasts.
if !a.is_dyn_star() {
obligations.push(Obligation::new(
self.tcx,
self.cause.clone(),
self.param_env,
ty::Binder::dummy(
self.tcx.at(self.cause.span).mk_trait_ref(hir::LangItem::PointerSized, [a]),
)
.to_poly_trait_predicate(),
));
}
// Enforce that the type is `usize`/pointer-sized.
obligations.push(Obligation::new(
self.tcx,
self.cause.clone(),
self.param_env,
ty::Binder::dummy(
self.tcx.at(self.cause.span).mk_trait_ref(hir::LangItem::PointerSized, [a]),
)
.to_poly_trait_predicate(),
));
Ok(InferOk {
value: (vec![Adjustment { kind: Adjust::DynStar, target: b }], b),

View file

@ -9,9 +9,10 @@ use hir::{
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir as hir;
use rustc_index::vec::IndexVec;
use rustc_infer::infer::InferCtxt;
use rustc_middle::{
hir::map::Map,
ty::{TyCtxt, TypeckResults},
ty::{ParamEnv, TyCtxt, TypeVisitable, TypeckResults},
};
use std::mem::swap;
@ -21,20 +22,29 @@ use std::mem::swap;
/// The resulting structure still needs to be iterated to a fixed point, which
/// can be done with propagate_to_fixpoint in cfg_propagate.
pub(super) fn build_control_flow_graph<'tcx>(
hir: Map<'tcx>,
tcx: TyCtxt<'tcx>,
infcx: &InferCtxt<'tcx>,
typeck_results: &TypeckResults<'tcx>,
param_env: ParamEnv<'tcx>,
consumed_borrowed_places: ConsumedAndBorrowedPlaces,
body: &'tcx Body<'tcx>,
num_exprs: usize,
) -> (DropRangesBuilder, FxHashSet<HirId>) {
let mut drop_range_visitor =
DropRangeVisitor::new(hir, tcx, typeck_results, consumed_borrowed_places, num_exprs);
let mut drop_range_visitor = DropRangeVisitor::new(
infcx,
typeck_results,
param_env,
consumed_borrowed_places,
num_exprs,
);
intravisit::walk_body(&mut drop_range_visitor, body);
drop_range_visitor.drop_ranges.process_deferred_edges();
if let Some(filename) = &tcx.sess.opts.unstable_opts.dump_drop_tracking_cfg {
super::cfg_visualize::write_graph_to_file(&drop_range_visitor.drop_ranges, filename, tcx);
if let Some(filename) = &infcx.tcx.sess.opts.unstable_opts.dump_drop_tracking_cfg {
super::cfg_visualize::write_graph_to_file(
&drop_range_visitor.drop_ranges,
filename,
infcx.tcx,
);
}
(drop_range_visitor.drop_ranges, drop_range_visitor.places.borrowed_temporaries)
@ -82,40 +92,44 @@ pub(super) fn build_control_flow_graph<'tcx>(
/// ```
struct DropRangeVisitor<'a, 'tcx> {
hir: Map<'tcx>,
typeck_results: &'a TypeckResults<'tcx>,
infcx: &'a InferCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
places: ConsumedAndBorrowedPlaces,
drop_ranges: DropRangesBuilder,
expr_index: PostOrderId,
tcx: TyCtxt<'tcx>,
typeck_results: &'a TypeckResults<'tcx>,
label_stack: Vec<(Option<rustc_ast::Label>, PostOrderId)>,
}
impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
fn new(
hir: Map<'tcx>,
tcx: TyCtxt<'tcx>,
infcx: &'a InferCtxt<'tcx>,
typeck_results: &'a TypeckResults<'tcx>,
param_env: ParamEnv<'tcx>,
places: ConsumedAndBorrowedPlaces,
num_exprs: usize,
) -> Self {
debug!("consumed_places: {:?}", places.consumed);
let drop_ranges = DropRangesBuilder::new(
places.consumed.iter().flat_map(|(_, places)| places.iter().cloned()),
hir,
infcx.tcx.hir(),
num_exprs,
);
Self {
hir,
infcx,
typeck_results,
param_env,
places,
drop_ranges,
expr_index: PostOrderId::from_u32(0),
typeck_results,
tcx,
label_stack: vec![],
}
}
fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}
fn record_drop(&mut self, value: TrackedValue) {
if self.places.borrowed.contains(&value) {
debug!("not marking {:?} as dropped because it is borrowed at some point", value);
@ -137,7 +151,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
.map_or(vec![], |places| places.iter().cloned().collect());
for place in places {
trace!(?place, "consuming place");
for_each_consumable(self.hir, place, |value| self.record_drop(value));
for_each_consumable(self.tcx().hir(), place, |value| self.record_drop(value));
}
}
@ -214,10 +228,15 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
/// return.
fn handle_uninhabited_return(&mut self, expr: &Expr<'tcx>) {
let ty = self.typeck_results.expr_ty(expr);
let ty = self.tcx.erase_regions(ty);
let m = self.tcx.parent_module(expr.hir_id).to_def_id();
let param_env = self.tcx.param_env(m.expect_local());
if !ty.is_inhabited_from(self.tcx, m, param_env) {
let ty = self.infcx.resolve_vars_if_possible(ty);
if ty.has_non_region_infer() {
self.tcx()
.sess
.delay_span_bug(expr.span, format!("could not resolve infer vars in `{ty}`"));
}
let ty = self.tcx().erase_regions(ty);
let m = self.tcx().parent_module(expr.hir_id).to_def_id();
if !ty.is_inhabited_from(self.tcx(), m, self.param_env) {
// This function will not return. We model this fact as an infinite loop.
self.drop_ranges.add_control_edge(self.expr_index + 1, self.expr_index + 1);
}
@ -238,7 +257,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
destination: hir::Destination,
) -> Result<HirId, LoopIdError> {
destination.target_id.map(|target| {
let node = self.hir.get(target);
let node = self.tcx().hir().get(target);
match node {
hir::Node::Expr(_) => target,
hir::Node::Block(b) => find_last_block_expression(b),

View file

@ -43,9 +43,9 @@ pub fn compute_drop_ranges<'a, 'tcx>(
let typeck_results = &fcx.typeck_results.borrow();
let num_exprs = fcx.tcx.region_scope_tree(def_id).body_expr_count(body.id()).unwrap_or(0);
let (mut drop_ranges, borrowed_temporaries) = build_control_flow_graph(
fcx.tcx.hir(),
fcx.tcx,
&fcx,
typeck_results,
fcx.param_env,
consumed_borrowed_places,
body,
num_exprs,

View file

@ -1245,6 +1245,23 @@ impl<'tcx> LateContext<'tcx> {
AbsolutePathPrinter { tcx: self.tcx }.print_def_path(def_id, &[]).unwrap()
}
/// Returns the associated type `name` for `self_ty` as an implementation of `trait_id`.
/// Do not invoke without first verifying that the type implements the trait.
pub fn get_associated_type(
&self,
self_ty: Ty<'tcx>,
trait_id: DefId,
name: &str,
) -> Option<Ty<'tcx>> {
let tcx = self.tcx;
tcx.associated_items(trait_id)
.find_by_name_and_kind(tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id)
.and_then(|assoc| {
let proj = tcx.mk_projection(assoc.def_id, tcx.mk_substs_trait(self_ty, []));
tcx.try_normalize_erasing_regions(self.param_env, proj).ok()
})
}
}
impl<'tcx> abi::HasDataLayout for LateContext<'tcx> {

View file

@ -0,0 +1,92 @@
use crate::{LateContext, LateLintPass, LintContext};
use rustc_errors::DelayDm;
use rustc_hir as hir;
use rustc_middle::{traits::util::supertraits, ty};
use rustc_span::sym;
declare_lint! {
/// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
/// `Deref` implementation with a `dyn SuperTrait` type as `Output`.
///
/// These implementations will become shadowed when the `trait_upcasting` feature is stabilized.
/// The `deref` functions will no longer be called implicitly, so there might be behavior change.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![deny(deref_into_dyn_supertrait)]
/// #![allow(dead_code)]
///
/// use core::ops::Deref;
///
/// trait A {}
/// trait B: A {}
/// impl<'a> Deref for dyn 'a + B {
/// type Target = dyn A;
/// fn deref(&self) -> &Self::Target {
/// todo!()
/// }
/// }
///
/// fn take_a(_: &dyn A) { }
///
/// fn take_b(b: &dyn B) {
/// take_a(b);
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// The dyn upcasting coercion feature adds new coercion rules, taking priority
/// over certain other coercion rules, which will cause some behavior change.
pub DEREF_INTO_DYN_SUPERTRAIT,
Warn,
"`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",
};
}
declare_lint_pass!(DerefIntoDynSupertrait => [DEREF_INTO_DYN_SUPERTRAIT]);
impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
// `Deref` is being implemented for `t`
if let hir::ItemKind::Impl(impl_) = item.kind
&& let Some(trait_) = &impl_.of_trait
&& let t = cx.tcx.type_of(item.owner_id)
&& let opt_did @ Some(did) = trait_.trait_def_id()
&& opt_did == cx.tcx.lang_items().deref_trait()
// `t` is `dyn t_principal`
&& let ty::Dynamic(data, _, ty::Dyn) = t.kind()
&& let Some(t_principal) = data.principal()
// `<T as Deref>::Target` is `dyn target_principal`
&& let Some(target) = cx.get_associated_type(t, did, "Target")
&& let ty::Dynamic(data, _, ty::Dyn) = target.kind()
&& let Some(target_principal) = data.principal()
// `target_principal` is a supertrait of `t_principal`
&& supertraits(cx.tcx, t_principal.with_self_ty(cx.tcx, cx.tcx.types.trait_object_dummy_self))
.any(|sup| sup.map_bound(|x| ty::ExistentialTraitRef::erase_self_ty(cx.tcx, x)) == target_principal)
{
cx.struct_span_lint(
DEREF_INTO_DYN_SUPERTRAIT,
cx.tcx.def_span(item.owner_id.def_id),
DelayDm(|| {
format!(
"`{t}` implements `Deref` with supertrait `{target_principal}` as target"
)
}),
|lint| {
if let Some(target_span) = impl_.items.iter().find_map(|i| (i.ident.name == sym::Target).then_some(i.span)) {
lint.span_label(target_span, "target type is set here");
}
lint
},
)
}
}
}

View file

@ -49,6 +49,7 @@ extern crate tracing;
mod array_into_iter;
pub mod builtin;
mod context;
mod deref_into_dyn_supertrait;
mod early;
mod enum_intrinsics_non_enums;
mod errors;
@ -87,6 +88,7 @@ use rustc_span::Span;
use array_into_iter::ArrayIntoIter;
use builtin::*;
use deref_into_dyn_supertrait::*;
use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums;
use for_loops_over_fallibles::*;
use hidden_unicode_codepoints::*;
@ -192,6 +194,7 @@ macro_rules! late_lint_mod_passes {
$args,
[
ForLoopsOverFallibles: ForLoopsOverFallibles,
DerefIntoDynSupertrait: DerefIntoDynSupertrait,
HardwiredLints: HardwiredLints,
ImproperCTypesDeclarations: ImproperCTypesDeclarations,
ImproperCTypesDefinitions: ImproperCTypesDefinitions,

View file

@ -3262,7 +3262,6 @@ declare_lint_pass! {
UNUSED_TUPLE_STRUCT_FIELDS,
NON_EXHAUSTIVE_OMITTED_PATTERNS,
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
DEREF_INTO_DYN_SUPERTRAIT,
DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
DUPLICATE_MACRO_ATTRIBUTES,
SUSPICIOUS_AUTO_TRAIT_IMPLS,
@ -3764,51 +3763,6 @@ declare_lint! {
"invisible directionality-changing codepoints in comment"
}
declare_lint! {
/// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
/// `Deref` implementation with a `dyn SuperTrait` type as `Output`.
///
/// These implementations will become shadowed when the `trait_upcasting` feature is stabilized.
/// The `deref` functions will no longer be called implicitly, so there might be behavior change.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![deny(deref_into_dyn_supertrait)]
/// #![allow(dead_code)]
///
/// use core::ops::Deref;
///
/// trait A {}
/// trait B: A {}
/// impl<'a> Deref for dyn 'a + B {
/// type Target = dyn A;
/// fn deref(&self) -> &Self::Target {
/// todo!()
/// }
/// }
///
/// fn take_a(_: &dyn A) { }
///
/// fn take_b(b: &dyn B) {
/// take_a(b);
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// The dyn upcasting coercion feature adds new coercion rules, taking priority
/// over certain other coercion rules, which will cause some behavior change.
pub DEREF_INTO_DYN_SUPERTRAIT,
Warn,
"`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",
};
}
declare_lint! {
/// The `duplicate_macro_attributes` lint detects when a `#[test]`-like built-in macro
/// attribute is duplicated on an item. This lint may trigger on `bench`, `cfg_eval`, `test`

View file

@ -800,7 +800,7 @@ LLVMRustOptimize(
auto Plugin = PassPlugin::Load(PluginPath.str());
if (!Plugin) {
LLVMRustSetLastError(("Failed to load pass plugin" + PluginPath.str()).c_str());
continue;
return LLVMRustResult::Failure;
}
Plugin->registerPassBuilderCallbacks(PB);
}

View file

@ -1044,11 +1044,19 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_, '_>, pat: &Pa
name,
typeck_results.node_type(pat.hir_id),
);
sess.struct_span_err(pat.span, "borrow of moved value")
.span_label(binding_span, format!("value moved into `{}` here", name))
let mut err = sess.struct_span_err(pat.span, "borrow of moved value");
err.span_label(binding_span, format!("value moved into `{}` here", name))
.span_label(binding_span, occurs_because)
.span_labels(conflicts_ref, "value borrowed here after move")
.emit();
.span_labels(conflicts_ref, "value borrowed here after move");
if pat.span.contains(binding_span) {
err.span_suggestion_verbose(
binding_span.shrink_to_lo(),
"borrow this binding in the pattern to avoid moving the value",
"ref ".to_string(),
Applicability::MachineApplicable,
);
}
err.emit();
}
return;
}

View file

@ -1734,7 +1734,7 @@ impl<'a> Parser<'a> {
expr.kind,
ExprKind::While(_, _, None)
| ExprKind::ForLoop(_, _, _, None)
| ExprKind::Loop(_, None)
| ExprKind::Loop(_, None, _)
| ExprKind::Block(_, None)
)
{
@ -2444,10 +2444,11 @@ impl<'a> Parser<'a> {
/// Parses `loop { ... }` (`loop` token already eaten).
fn parse_loop_expr(&mut self, opt_label: Option<Label>, lo: Span) -> PResult<'a, P<Expr>> {
let loop_span = self.prev_token.span;
let (attrs, body) = self.parse_inner_attrs_and_block()?;
Ok(self.mk_expr_with_attrs(
lo.to(self.prev_token.span),
ExprKind::Loop(body, opt_label),
ExprKind::Loop(body, opt_label, loop_span),
attrs,
))
}

View file

@ -3841,7 +3841,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
}
}
ExprKind::Loop(ref block, label) => self.resolve_labeled_block(label, expr.id, &block),
ExprKind::Loop(ref block, label, _) => {
self.resolve_labeled_block(label, expr.id, &block)
}
ExprKind::While(ref cond, ref block, label) => {
self.with_resolved_label(label, expr.id, |this| {

View file

@ -6,11 +6,9 @@
//!
//! [rustc dev guide]:https://rustc-dev-guide.rust-lang.org/traits/resolution.html#candidate-assembly
use hir::LangItem;
use rustc_errors::DelayDm;
use rustc_hir as hir;
use rustc_infer::traits::ObligationCause;
use rustc_infer::traits::{Obligation, SelectionError, TraitObligation};
use rustc_lint_defs::builtin::DEREF_INTO_DYN_SUPERTRAIT;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, Ty, TypeVisitable};
use rustc_target::spec::abi::Abi;
@ -776,9 +774,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
match (source.kind(), target.kind()) {
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
(&ty::Dynamic(ref data_a, _, dyn_a), &ty::Dynamic(ref data_b, _, dyn_b))
if dyn_a == dyn_b =>
{
(&ty::Dynamic(ref data_a, _, ty::Dyn), &ty::Dynamic(ref data_b, _, ty::Dyn)) => {
// Upcast coercions permit several things:
//
// 1. Dropping auto traits, e.g., `Foo + Send` to `Foo`
@ -811,16 +807,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&obligation.cause,
) {
if deref_trait_ref.def_id() == target_trait_did {
self.tcx().struct_span_lint_hir(
DEREF_INTO_DYN_SUPERTRAIT,
obligation.cause.body_id,
obligation.cause.span,
DelayDm(|| format!(
"`{}` implements `Deref` with supertrait `{}` as output",
source, deref_trait_ref
)),
|lint| lint,
);
return;
}
}

View file

@ -803,9 +803,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let upcast_trait_ref;
match (source.kind(), target.kind()) {
// TraitA+Kx+'a -> TraitB+Ky+'b (trait upcasting coercion).
(&ty::Dynamic(ref data_a, r_a, repr_a), &ty::Dynamic(ref data_b, r_b, repr_b))
if repr_a == repr_b =>
{
(
&ty::Dynamic(ref data_a, r_a, repr_a @ ty::Dyn),
&ty::Dynamic(ref data_b, r_b, ty::Dyn),
) => {
// See `assemble_candidates_for_unsizing` for more info.
// We already checked the compatibility of auto traits within `assemble_candidates_for_unsizing`.
let principal_a = data_a.principal().unwrap();
@ -831,7 +832,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.map(ty::Binder::dummy),
);
let existential_predicates = tcx.mk_poly_existential_predicates(iter);
let source_trait = tcx.mk_dynamic(existential_predicates, r_b, repr_b);
let source_trait = tcx.mk_dynamic(existential_predicates, r_b, repr_a);
// Require that the traits involved in this upcast are **equal**;
// only the **lifetime bound** is changed.

View file

@ -1071,7 +1071,7 @@ fn write_impl_section_heading(w: &mut Buffer, title: &str, id: &str) {
w,
"<h2 id=\"{id}\" class=\"small-section-header\">\
{title}\
<a href=\"#{id}\" class=\"anchor\"></a>\
<a href=\"#{id}\" class=\"anchor\">§</a>\
</h2>"
);
}
@ -1536,7 +1536,7 @@ fn render_impl(
render_rightside(w, cx, item, containing_item, render_mode);
if trait_.is_some() {
// Anchors are only used on trait impls.
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
}
w.write_str("<h4 class=\"code-header\">");
render_assoc_item(
@ -1562,7 +1562,7 @@ fn render_impl(
render_rightside(w, cx, item, containing_item, render_mode);
if trait_.is_some() {
// Anchors are only used on trait impls.
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
}
w.write_str("<h4 class=\"code-header\">");
assoc_const(
@ -1587,7 +1587,7 @@ fn render_impl(
write!(w, "<section id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class);
if trait_.is_some() {
// Anchors are only used on trait impls.
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
}
w.write_str("<h4 class=\"code-header\">");
assoc_type(
@ -1613,7 +1613,7 @@ fn render_impl(
);
if trait_.is_some() {
// Anchors are only used on trait impls.
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
}
w.write_str("<h4 class=\"code-header\">");
assoc_type(
@ -1846,7 +1846,7 @@ pub(crate) fn render_impl_summary(
};
write!(w, "<section id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
render_rightside(w, cx, &i.impl_item, containing_item, RenderMode::Normal);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
write!(w, "<h3 class=\"code-header\">");
if let Some(use_absolute) = use_absolute {

View file

@ -717,7 +717,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
write!(
w,
"<h2 id=\"{0}\" class=\"small-section-header\">\
{1}<a href=\"#{0}\" class=\"anchor\"></a>\
{1}<a href=\"#{0}\" class=\"anchor\">§</a>\
</h2>{2}",
id, title, extra_content
)
@ -1147,7 +1147,7 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
write!(
w,
"<h2 id=\"fields\" class=\"fields small-section-header\">\
Fields<a href=\"#fields\" class=\"anchor\"></a>\
Fields<a href=\"#fields\" class=\"anchor\">§</a>\
</h2>"
);
for (field, ty) in fields {
@ -1156,7 +1156,7 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
write!(
w,
"<span id=\"{id}\" class=\"{shortty} small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<a href=\"#{id}\" class=\"anchor field\">§</a>\
<code>{name}: {ty}</code>\
</span>",
id = id,
@ -1262,7 +1262,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
write!(
w,
"<h2 id=\"variants\" class=\"variants small-section-header\">\
Variants{}<a href=\"#variants\" class=\"anchor\"></a>\
Variants{}<a href=\"#variants\" class=\"anchor\">§</a>\
</h2>",
document_non_exhaustive_header(it)
);
@ -1273,7 +1273,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
write!(
w,
"<section id=\"{id}\" class=\"variant\">\
<a href=\"#{id}\" class=\"anchor\"></a>",
<a href=\"#{id}\" class=\"anchor\">§</a>",
id = id,
);
render_stability_since_raw_with_extra(
@ -1325,7 +1325,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
w,
"<div class=\"sub-variant-field\">\
<span id=\"{id}\" class=\"small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<a href=\"#{id}\" class=\"anchor field\">§</a>\
<code>{f}:&nbsp;{t}</code>\
</span>",
id = id,
@ -1477,7 +1477,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
write!(
w,
"<h2 id=\"fields\" class=\"fields small-section-header\">\
{}{}<a href=\"#fields\" class=\"anchor\"></a>\
{}{}<a href=\"#fields\" class=\"anchor\">§</a>\
</h2>",
if s.ctor_kind.is_none() { "Fields" } else { "Tuple Fields" },
document_non_exhaustive_header(it)
@ -1490,7 +1490,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
write!(
w,
"<span id=\"{id}\" class=\"{item_type} small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<a href=\"#{id}\" class=\"anchor field\">§</a>\
<code>{name}: {ty}</code>\
</span>",
item_type = ItemType::StructField,
@ -1908,7 +1908,7 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
writeln!(
w,
"<h2 id=\"layout\" class=\"small-section-header\"> \
Layout<a href=\"#layout\" class=\"anchor\"></a></h2>"
Layout<a href=\"#layout\" class=\"anchor\">§</a></h2>"
);
writeln!(w, "<div class=\"docblock\">");

View file

@ -730,9 +730,6 @@ a {
h2.small-section-header > .anchor {
padding-right: 6px;
}
.anchor::before {
content: '§';
}
.main-heading a:hover,
.example-wrap > pre.rust a:hover,

View file

@ -115,6 +115,7 @@
<input {# -#}
class="search-input" {# -#}
name="search" {# -#}
aria-label="Run search in the documentation" {# -#}
autocomplete="off" {# -#}
spellcheck="false" {# -#}
placeholder="Click or press S to search, ? for more options…" {# -#}

View file

@ -0,0 +1,106 @@
// compile-flags: -Zdrop-tracking
// incremental
// edition: 2021
use std::future::*;
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::*;
fn send<T: Send>(_: T) {}
pub trait Stream {
type Item;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
}
struct Empty<T>(PhantomData<fn() -> T>);
impl<T> Stream for Empty<T> {
type Item = T;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
todo!()
}
}
pub trait FnOnce1<A> {
type Output;
fn call_once(self, arg: A) -> Self::Output;
}
impl<T, A, R> FnOnce1<A> for T
where
T: FnOnce(A) -> R,
{
type Output = R;
fn call_once(self, arg: A) -> R {
self(arg)
}
}
pub trait FnMut1<A>: FnOnce1<A> {
fn call_mut(&mut self, arg: A) -> Self::Output;
}
impl<T, A, R> FnMut1<A> for T
where
T: FnMut(A) -> R,
{
fn call_mut(&mut self, arg: A) -> R {
self(arg)
}
}
struct Map<St, F>(St, F);
impl<St, F> Stream for Map<St, F>
where
St: Stream,
F: FnMut1<St::Item>,
{
type Item = F::Output;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
todo!()
}
}
struct FuturesOrdered<T: Future>(PhantomData<fn() -> T::Output>);
pub struct Buffered<St: Stream>(St, FuturesOrdered<St::Item>, usize)
where
St::Item: Future;
impl<St> Stream for Buffered<St>
where
St: Stream,
St::Item: Future,
{
type Item = <St::Item as Future>::Output;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
todo!()
}
}
struct Next<'a, T: ?Sized>(&'a T);
impl<St: ?Sized + Stream + Unpin> Future for Next<'_, St> {
type Output = Option<St::Item>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
todo!()
}
}
fn main() {
send(async {
//~^ ERROR implementation of `FnOnce` is not general enough
//~| ERROR implementation of `FnOnce` is not general enough
//~| ERROR implementation of `FnOnce` is not general enough
//~| ERROR implementation of `FnOnce` is not general enough
Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
});
}

View file

@ -0,0 +1,62 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
|
LL | / send(async {
LL | |
LL | |
LL | |
LL | |
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
LL | | });
| |______^ implementation of `FnOnce` is not general enough
|
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&(),)>`
error: implementation of `FnOnce` is not general enough
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
|
LL | / send(async {
LL | |
LL | |
LL | |
LL | |
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
LL | | });
| |______^ implementation of `FnOnce` is not general enough
|
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&(),)>`
error: implementation of `FnOnce` is not general enough
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
|
LL | / send(async {
LL | |
LL | |
LL | |
LL | |
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
LL | | });
| |______^ implementation of `FnOnce` is not general enough
|
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&(),)>`
error: implementation of `FnOnce` is not general enough
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
|
LL | / send(async {
LL | |
LL | |
LL | |
LL | |
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
LL | | });
| |______^ implementation of `FnOnce` is not general enough
|
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&(),)>`
error: aborting due to 4 previous errors

View file

@ -17,6 +17,10 @@ LL | match mm { (_, _y) => { } }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | match mm { (ref _x, _) => { } }
| +++
error[E0382]: use of partially moved value: `mm`
--> $DIR/issue-53114-borrow-checks.rs:29:11
@ -28,6 +32,10 @@ LL | match mm { (_, _) => { } }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | match mm { (_, ref _y) => { } }
| +++
error[E0382]: use of moved value: `m`
--> $DIR/issue-53114-borrow-checks.rs:36:16
@ -48,6 +56,10 @@ LL | if let (_, _y) = mm { }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let (ref _x, _) = mm { }
| +++
error[E0382]: use of partially moved value: `mm`
--> $DIR/issue-53114-borrow-checks.rs:43:21
@ -59,6 +71,10 @@ LL | if let (_, _) = mm { }
| ^^ value used here after partial move
|
= note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let (_, ref _y) = mm { }
| +++
error: aborting due to 6 previous errors

View file

@ -32,6 +32,10 @@ LL | +
LL | x.clone();
| ^^^^^^^^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x.clone()
| ++++++++
help: consider further restricting this bound
|
LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) {

View file

@ -27,6 +27,11 @@ LL | a @ [.., _] => (),
...
LL | &x;
| ^^ value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ [.., _] => (),
| +++
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:28:5
@ -71,13 +76,15 @@ LL | fn bindings_after_at_or_patterns_move(x: Option<Test>) {
| - move occurs because `x` has type `Option<Test>`, which does not implement the `Copy` trait
LL | match x {
LL | foo @ Some(Test::Foo | Test::Bar) => (),
| ---
| |
| value moved here
| value moved here
| --- value moved here
...
LL | &x;
| ^^ value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref foo @ Some(Test::Foo | Test::Bar) => (),
| +++
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:86:5
@ -122,13 +129,15 @@ LL | fn bindings_after_at_slice_patterns_or_patterns_moves(x: [Option<Test>; 4])
| - move occurs because `x` has type `[Option<Test>; 4]`, which does not implement the `Copy` trait
LL | match x {
LL | a @ [.., Some(Test::Foo | Test::Bar)] => (),
| -
| |
| value moved here
| value moved here
| - value moved here
...
LL | &x;
| ^^ value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ [.., Some(Test::Foo | Test::Bar)] => (),
| +++
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:144:5

View file

@ -7,6 +7,18 @@ LL | consume(b);
| - value moved here
LL | consume(b);
| ^ value used here after move
|
note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
--> $DIR/borrowck-consume-unsize-vec.rs:3:15
|
LL | fn consume(_: Box<[i32]>) {
| ------- ^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | consume(b.clone());
| ++++++++
error: aborting due to previous error

View file

@ -7,6 +7,14 @@ LL | consume(b);
| - value moved here
LL | consume(b);
| ^ value used here after move
|
note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
--> $DIR/borrowck-consume-upcast-box.rs:5:15
|
LL | fn consume(_: Box<dyn Foo>) {
| ------- ^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
error: aborting due to previous error

View file

@ -9,6 +9,11 @@ LL | Some(_) if { drop(my_str); false } => {}
LL | Some(_) => {}
LL | None => { foo(my_str); }
| ^^^^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | Some(_) if { drop(my_str.clone()); false } => {}
| ++++++++
error: aborting due to previous error

View file

@ -7,6 +7,11 @@ LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur
| - ^^^^^^^^^ value borrowed here after move
| |
| value moved here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = {x.clone()} + x.clone(); // the `{x}` forces a move to occur
| ++++++++
error: aborting due to previous error

View file

@ -8,6 +8,10 @@ LL | [.., _y] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-match.rs:23:14
@ -19,6 +23,10 @@ LL | [.., _y] => {}
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-match.rs:33:15
@ -30,6 +38,10 @@ LL | [.., (_y, _)] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:44:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:55:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:66:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:77:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-match.rs:89:11
@ -85,6 +113,10 @@ LL | [(_x, _), _, _] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _, _] => {}
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-match.rs:99:15
@ -96,6 +128,10 @@ LL | [.., (_x, _)] => {}
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-match.rs:110:11
@ -107,6 +143,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _] => {}
| +++
error: aborting due to 10 previous errors

View file

@ -8,6 +8,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:28:11
@ -19,6 +23,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:41:11
@ -30,6 +38,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:52:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:63:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:74:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:85:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:96:11
@ -85,6 +113,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:109:11
@ -96,6 +128,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _, _] => {}
| +++
error: aborting due to 9 previous errors

View file

@ -8,6 +8,10 @@ LL | [.., ref _y] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: borrow of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use-match.rs:23:14
@ -19,6 +23,10 @@ LL | [.., ref _y] => {}
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: borrow of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-use-match.rs:33:15
@ -30,6 +38,10 @@ LL | [.., (ref _y, _)] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:44:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:55:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:66:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:77:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use-match.rs:89:11
@ -85,6 +113,10 @@ LL | [(ref _x, _), _, _] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _, _] => {}
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use-match.rs:99:15
@ -96,6 +128,10 @@ LL | [.., (ref _x, _)] => {}
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:110:11
@ -107,6 +143,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:123:5
@ -118,6 +158,10 @@ LL | a[2] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:131:5
@ -129,6 +173,10 @@ LL | a[2].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:139:5
@ -140,6 +188,10 @@ LL | a[0] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-match.rs:147:5
@ -151,6 +203,10 @@ LL | a[0].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x @ ..] => {}
| +++
error: aborting due to 14 previous errors

View file

@ -8,6 +8,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:28:11
@ -19,6 +23,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, _, (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:41:11
@ -30,6 +38,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _x, _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:52:11
@ -41,6 +53,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., ref _x] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:63:11
@ -52,6 +68,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [(ref _x, _), _, _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:74:11
@ -63,6 +83,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [.., (ref _x, _)] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:85:11
@ -74,6 +98,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [_, ref _y @ ..] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:96:11
@ -85,6 +113,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref _y @ .., _] => {}
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:109:11
@ -96,6 +128,10 @@ LL | match a {
| ^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | [ref x @ .., _, _] => {}
| +++
error: aborting due to 9 previous errors

View file

@ -7,6 +7,10 @@ LL | let [.., ref _y] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x] = a;
| +++
error[E0382]: borrow of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:16:14
@ -17,6 +21,10 @@ LL | let [.., ref _y] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: borrow of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array-use.rs:22:15
@ -27,6 +35,10 @@ LL | let [.., (ref _y, _)] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:30:10
@ -37,6 +49,10 @@ LL | let [ref _y @ .., _, _] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _x, _, _] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:36:16
@ -47,6 +63,10 @@ LL | let [_, _, ref _y @ ..] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., ref _x] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:42:10
@ -57,6 +77,10 @@ LL | let [ref _y @ .., _, _] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [(ref _x, _), _, _] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:48:16
@ -67,6 +91,10 @@ LL | let [_, _, ref _y @ ..] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., (ref _x, _)] = a;
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:54:11
@ -77,6 +105,10 @@ LL | let [(ref _x, _), _, _] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _y @ .., _, _] = a;
| +++
error[E0382]: borrow of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array-use.rs:60:15
@ -87,6 +119,10 @@ LL | let [.., (ref _x, _)] = a;
| ^^^^^^ value borrowed here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _y @ ..] = a;
| +++
error[E0382]: borrow of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:68:13
@ -97,6 +133,10 @@ LL | let [_, ref _y @ ..] = a;
| ^^^^^^ value borrowed here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref x @ .., _] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:76:5
@ -107,6 +147,10 @@ LL | a[2] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:82:5
@ -117,6 +161,10 @@ LL | a[2].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:88:5
@ -127,6 +175,10 @@ LL | a[0] = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x @ ..] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array-use.rs:94:5
@ -137,6 +189,10 @@ LL | a[0].1 = Default::default();
| ^^^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x @ ..] = a;
| +++
error: aborting due to 14 previous errors

View file

@ -7,6 +7,10 @@ LL | let [.., _y] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _x] = a;
| +++
error[E0382]: use of partially moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array.rs:16:14
@ -17,6 +21,10 @@ LL | let [.., _y] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array.rs:22:15
@ -27,6 +35,10 @@ LL | let [.., (_y, _)] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, (ref _x, _)] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:30:10
@ -37,6 +49,10 @@ LL | let [_y @ .., _, _] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _x, _, _] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:36:16
@ -47,6 +63,10 @@ LL | let [_, _, _y @ ..] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., ref _x] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:42:10
@ -57,6 +77,10 @@ LL | let [_y @ .., _, _] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [(ref _x, _), _, _] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:48:16
@ -67,6 +91,10 @@ LL | let [_, _, _y @ ..] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..].0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [.., (ref _x, _)] = a;
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array.rs:54:11
@ -77,6 +105,10 @@ LL | let [(_x, _), _, _] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref _y @ .., _, _] = a;
| +++
error[E0382]: use of moved value: `a[..].0`
--> $DIR/borrowck-move-out-from-array.rs:60:15
@ -87,6 +119,10 @@ LL | let [.., (_x, _)] = a;
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [_, _, ref _y @ ..] = a;
| +++
error[E0382]: use of partially moved value: `a`
--> $DIR/borrowck-move-out-from-array.rs:68:13
@ -97,6 +133,10 @@ LL | let [_, _y @ ..] = a;
| ^^ value used here after partial move
|
= note: partial move occurs because `a[..]` has type `(String, String)`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let [ref x @ .., _] = a;
| +++
error: aborting due to 10 previous errors

View file

@ -40,6 +40,11 @@ LL | thread::spawn(move|| {
...
LL | drop(x1);
| -- use occurs due to use in closure
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x1.clone());
| ++++++++
error[E0382]: use of moved value: `x2`
--> $DIR/borrowck-multiple-captures.rs:27:19
@ -53,6 +58,11 @@ LL | thread::spawn(move|| {
...
LL | drop(x2);
| -- use occurs due to use in closure
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x2.clone());
| ++++++++
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-multiple-captures.rs:41:14
@ -100,6 +110,11 @@ LL | thread::spawn(move|| {
LL |
LL | drop(x);
| - use occurs due to use in closure
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x.clone());
| ++++++++
error: aborting due to 8 previous errors

View file

@ -33,6 +33,11 @@ LL | println!("{}", f[s]);
...
LL | f[s] = 10;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | println!("{}", f[s.clone()]);
| ++++++++
error: aborting due to 3 previous errors

View file

@ -8,6 +8,11 @@ LL | drop(x);
| - value moved here
LL | let _ = (1,x);
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(x.clone());
| ++++++++
error: aborting due to previous error

View file

@ -8,6 +8,11 @@ LL | Some(_) if { drop(a); false } => None,
| - value moved here
LL | x => x,
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | Some(_) if { drop(a.clone()); false } => None,
| ++++++++
error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | if let Some(thing) = maybe {
| ^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `maybe.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref thing) = maybe {
| +++

View file

@ -8,6 +8,10 @@ LL | val = None;
| ---------- this reinitialization might get skipped
|
= note: move occurs because value has type `Struct`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | while let Some(ref foo) = val {
| +++
error[E0382]: use of moved value: `foo`
--> $DIR/issue-83760.rs:21:14

View file

@ -5,7 +5,7 @@ LL | if let Some(mut _x) = opt {}
| ^^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `&mut i32`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `opt.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref mut _x) = opt {}
| +++

View file

@ -8,7 +8,7 @@ LL | foo(s);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `s.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref mut x) = s {
| +++
@ -23,7 +23,7 @@ LL | bar(e);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `e.s`
help: borrow this binding in the pattern to avoid moving the value
|
LL | let E::V { s: ref mut x } = e;
| +++

View file

@ -8,7 +8,7 @@ LL | foo(s);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `s.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref x) = s {
| +++
@ -23,7 +23,7 @@ LL | bar(e);
| ^ value used here after partial move
|
= note: partial move occurs because value has type `S`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `e.s`
help: borrow this binding in the pattern to avoid moving the value
|
LL | let E::V { s: ref x } = e;
| +++

View file

@ -4,9 +4,17 @@ error[E0382]: use of moved value: `value`
LL | fn this_does_not<'a, R>(value: &'a mut Events<R>) {
| ----- move occurs because `value` has type `&mut Events<R>`, which does not implement the `Copy` trait
LL | for _ in 0..3 {
| ------------- inside of this loop
LL | Other::handle(value);
| ^^^^^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `handle` to borrow instead if owning the value isn't necessary
--> $DIR/mut-borrow-in-loop-2.rs:9:22
|
LL | fn handle(value: T) -> Self;
| ------ ^ this parameter takes ownership of the value
| |
| in this function
help: consider creating a fresh reborrow of `value` here
|
LL | Other::handle(&mut *value);

View file

@ -8,6 +8,10 @@ LL | &x.0 .0;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ((ref y, _) | (_, y),) => (),
| +++
error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:10:5
@ -19,6 +23,10 @@ LL | &x.0 .1;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ((y, _) | (_, ref y),) => (),
| +++
error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:18:5
@ -77,6 +85,10 @@ LL | &x.0 .0;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ((ref y, _) | (_, y),) = x;
| +++
error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:40:5
@ -88,6 +100,10 @@ LL | &x.0 .1;
| ^^^^^^^ value borrowed here after move
|
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ((y, _) | (_, ref y),) = x;
| +++
error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:46:5

View file

@ -15,6 +15,10 @@ note: this function takes ownership of the receiver `self`, which moves `some_ve
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | some_vec.clone().into_iter();
| ++++++++
error: aborting due to previous error

View file

@ -7,6 +7,11 @@ LL | let _bar = foo;
| --- value moved here
LL | let _baz = [foo; 0];
| ^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _bar = foo.clone();
| ++++++++
error[E0493]: destructor of `String` cannot be evaluated at compile-time
--> $DIR/repeat-drop-2.rs:7:25

View file

@ -0,0 +1,52 @@
// run-pass
// edition:2021
// check-run-results
#![feature(dyn_star)]
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
use std::future::Future;
async fn foo(f: dyn* Future<Output = i32>) {
println!("value: {}", f.await);
}
async fn async_main() {
foo(Box::pin(async { 1 })).await
}
// ------------------------------------------------------------------------- //
// Implementation Details Below...
use std::pin::Pin;
use std::task::*;
pub fn noop_waker() -> Waker {
let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE);
// SAFETY: the contracts for RawWaker and RawWakerVTable are upheld
unsafe { Waker::from_raw(raw) }
}
const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);
unsafe fn noop_clone(_p: *const ()) -> RawWaker {
RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE)
}
unsafe fn noop(_p: *const ()) {}
fn main() {
let mut fut = async_main();
// Poll loop, just to test the future...
let waker = noop_waker();
let ctx = &mut Context::from_waker(&waker);
loop {
match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
Poll::Pending => {}
Poll::Ready(()) => break,
}
}
}

View file

@ -0,0 +1 @@
value: 1

View file

@ -0,0 +1,11 @@
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/dispatch-on-pin-mut.rs:5:12
|
LL | #![feature(dyn_star)]
| ^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted

View file

@ -1,7 +1,8 @@
// check-pass
// run-pass
// check-run-results
#![feature(dyn_star)]
#![allow(incomplete_features)]
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
trait AddOne {
fn add1(&mut self) -> usize;

View file

@ -0,0 +1,2 @@
43
44

View file

@ -0,0 +1,11 @@
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/dont-unsize-coerce-dyn-star.rs:4:12
|
LL | #![feature(dyn_star)]
| ^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted

View file

@ -0,0 +1,13 @@
#![feature(dyn_star, trait_upcasting)]
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
trait A: B {}
trait B {}
impl A for usize {}
impl B for usize {}
fn main() {
let x: Box<dyn* A> = Box::new(1usize as dyn* A);
let y: Box<dyn* B> = x;
//~^ ERROR mismatched types
}

View file

@ -0,0 +1,23 @@
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/no-unsize-coerce-dyn-trait.rs:1:12
|
LL | #![feature(dyn_star, trait_upcasting)]
| ^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0308]: mismatched types
--> $DIR/no-unsize-coerce-dyn-trait.rs:11:26
|
LL | let y: Box<dyn* B> = x;
| ----------- ^ expected trait `B`, found trait `A`
| |
| expected due to this
|
= note: expected struct `Box<dyn* B>`
found struct `Box<dyn* A>`
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,7 +1,6 @@
// run-pass
// known-bug: #104800
#![feature(dyn_star, trait_upcasting)]
#![allow(incomplete_features)]
trait Foo: Bar {
fn hello(&self);

View file

@ -0,0 +1,20 @@
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/upcast.rs:3:12
|
LL | #![feature(dyn_star, trait_upcasting)]
| ^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0277]: `dyn* Foo` needs to be a pointer-sized type
--> $DIR/upcast.rs:30:23
|
LL | let w: dyn* Bar = w;
| ^ `dyn* Foo` needs to be a pointer-sized type
|
= help: the trait `PointerSized` is not implemented for `dyn* Foo`
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -9,6 +9,11 @@ LL | 0 if { drop(s); false } => String::from("oops"),
...
LL | s
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | 0 if { drop(s.clone()); false } => String::from("oops"),
| ++++++++
error: aborting due to previous error

View file

@ -10,6 +10,10 @@ LL | println!("{}", s);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut s_copy = s.clone();
| ++++++++
error: aborting due to previous error

View file

@ -3,9 +3,23 @@ error[E0382]: use of moved value: `x`
|
LL | let x: Box<isize> = Box::new(25);
| - move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait
...
LL |
LL | loop {
| ---- inside of this loop
LL | take(x);
| ^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/liveness-move-call-arg.rs:1:13
|
LL | fn take(_x: Box<isize>) {}
| ---- ^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | take(x.clone());
| ++++++++
error: aborting due to previous error

View file

@ -4,8 +4,22 @@ error[E0382]: use of moved value: `y`
LL | let y: Box<isize> = 42.into();
| - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait
...
LL | loop {
| ---- inside of this loop
LL | println!("{}", y);
LL | loop {
| ---- inside of this loop
LL | loop {
| ---- inside of this loop
LL | loop {
| ---- inside of this loop
LL | x = y;
| ^ value moved here, in previous iteration of loop
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x = y.clone();
| ++++++++
error: aborting due to previous error

View file

@ -24,12 +24,22 @@ error[E0382]: borrow of moved value: `y`
LL | let y: Box<isize> = 42.into();
| - move occurs because `y` has type `Box<isize>`, which does not implement the `Copy` trait
...
LL | loop {
| ---- inside of this loop
LL | println!("{}", y);
| ^ value borrowed here after move
LL | while true { while true { while true { x = y; x.clone(); } } }
| - value moved here, in previous iteration of loop
| ---------- ---------- ---------- - value moved here, in previous iteration of loop
| | | |
| | | inside of this loop
| | inside of this loop
| inside of this loop
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | while true { while true { while true { x = y.clone(); x.clone(); } } }
| ++++++++
error: aborting due to previous error; 3 warnings emitted

View file

@ -10,6 +10,10 @@ LL | println!("{}", *x);
| ^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | let y = x.clone();
| ++++++++
error: aborting due to previous error

View file

@ -8,7 +8,16 @@ LL | send(ch, message);
LL | println!("{}", message);
| ^^^^^^^ value borrowed here after move
|
note: consider changing this parameter type in function `send` to borrow instead if owning the value isn't necessary
--> $DIR/liveness-use-after-send.rs:3:54
|
LL | fn send<T:Send + std::fmt::Debug>(ch: Chan<T>, data: T) {
| ---- in this function ^ this parameter takes ownership of the value
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
LL | send(ch, message.clone());
| ++++++++
error: aborting due to previous error

View file

@ -4,9 +4,17 @@ error[E0382]: use of moved value: `f`
LL | fn takes_fn(f: impl Fn()) {
| - move occurs because `f` has type `impl Fn()`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL | takes_fnonce(f);
| ^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider borrowing `f`
|
LL | takes_fnonce(&f);
@ -24,6 +32,13 @@ LL | takes_fnonce(m);
LL | takes_fnonce(m);
| ^ value used here after move
|
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
--> $DIR/borrow-closures-instead-of-move.rs:34:20
|
LL | fn takes_fnonce(_: impl FnOnce()) {}
| ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider mutably borrowing `m`
|
LL | takes_fnonce(&mut m);

View file

@ -5,6 +5,11 @@ LL | let b = Box::new(true);
| - move occurs because `b` has type `Box<bool>`, which does not implement the `Copy` trait
LL | test!({b});
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | test!({b.clone()});
| ++++++++
error: aborting due to previous error

View file

@ -25,7 +25,7 @@ fn moved_here_1() {
fn moved_here_2() {
let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
loop {
loop { //~ NOTE inside of this loop
let _used = value;
//~^ NOTE value moved here
loop {
@ -38,7 +38,7 @@ fn moved_here_2() {
fn moved_loop_1() {
let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
loop {
loop { //~ NOTE inside of this loop
let _used = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop
}
@ -49,7 +49,7 @@ fn moved_loop_2() {
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
let _used = value;
value = NonCopy{};
loop {
loop { //~ NOTE inside of this loop
let _used2 = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop
}

View file

@ -15,7 +15,9 @@ error[E0382]: use of moved value: `value`
|
LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
LL |
LL | loop {
| ---- inside of this loop
LL | let _used = value;
| ----- value moved here
...
@ -27,7 +29,9 @@ error[E0382]: use of moved value: `value`
|
LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
LL |
LL | loop {
| ---- inside of this loop
LL | let _used = value;
| ^^^^^ value moved here, in previous iteration of loop
@ -37,6 +41,8 @@ error[E0382]: use of moved value: `value`
LL | let mut value = NonCopy{};
| --------- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
LL | loop {
| ---- inside of this loop
LL | let _used2 = value;
| ^^^^^ value moved here, in previous iteration of loop

View file

@ -96,6 +96,10 @@ note: this function takes ownership of the receiver `self`, which moves `rc_foo`
|
LL | fn use_rc_self(self: Rc<Self>) {}
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | rc_foo.clone().use_rc_self();
| ++++++++
error[E0382]: use of moved value: `foo_add`
--> $DIR/move-fn-self-receiver.rs:59:5
@ -137,6 +141,11 @@ LL | for _val in explicit_into_iter.into_iter() {}
| ----------- `explicit_into_iter` moved due to this method call
LL | explicit_into_iter;
| ^^^^^^^^^^^^^^^^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | for _val in explicit_into_iter.clone().into_iter() {}
| ++++++++
error[E0382]: use of moved value: `container`
--> $DIR/move-fn-self-receiver.rs:71:5
@ -160,6 +169,7 @@ error[E0382]: use of moved value: `foo2`
LL | let foo2 = Foo;
| ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL | foo2.use_self();
| ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop

View file

@ -8,6 +8,18 @@ LL | (1, 2) if take(x) => (),
| - value moved here
LL | (1, 2) if take(x) => (),
| ^ value used here after move
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/move-guard-same-consts.rs:25:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | (1, 2) if take(x.clone()) => (),
| ++++++++
error: aborting due to previous error

View file

@ -8,6 +8,18 @@ LL | (1, _) if take(x) => (),
| - value moved here
LL | (_, 2) if take(x) => (),
| ^ value used here after move
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/move-in-guard-1.rs:15:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | (1, _) if take(x.clone()) => (),
| ++++++++
error: aborting due to previous error

View file

@ -6,6 +6,18 @@ LL | let x: Box<_> = Box::new(1);
...
LL | (_, 2) if take(x) => (),
| ^ value used here after move
|
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
--> $DIR/move-in-guard-2.rs:13:15
|
LL | fn take<T>(_: T) -> bool { false }
| ---- ^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | (_, 2) if take(x.clone()) => (),
| ++++++++
error: aborting due to previous error

View file

@ -13,6 +13,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | consume(x.clone().into_iter().next().unwrap());
| ++++++++
error: aborting due to previous error

View file

@ -8,7 +8,7 @@ LL | consume(node) + r
| ^^^^ value used here after partial move
|
= note: partial move occurs because value has type `Box<List>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `node.next.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref right) => consume(right),
| +++

View file

@ -9,6 +9,11 @@ LL | let _y = Foo { f:x };
LL |
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:x.clone() };
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11
@ -21,6 +26,11 @@ LL | let _y = Foo { f:(((x))) };
LL |
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:(((x))).clone() };
| ++++++++
error: aborting due to 2 previous errors

View file

@ -7,6 +7,11 @@ LL | let _y = Foo { f:x };
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:x.clone() };
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:18:11
@ -17,6 +22,11 @@ LL | let _y = (x, 3);
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = (x.clone(), 3);
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:35:11
@ -29,6 +39,11 @@ LL | x
...
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x.clone()
| ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:36:11
@ -41,6 +56,11 @@ LL | y
...
LL | touch(&y);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | y.clone()
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:46:11
@ -53,6 +73,11 @@ LL | true => x,
...
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | true => x.clone(),
| ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:47:11
@ -65,6 +90,11 @@ LL | false => y
...
LL | touch(&y);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | false => y.clone()
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:58:11
@ -77,6 +107,18 @@ LL | _ if guard(x) => 10,
...
LL | touch(&x);
| ^^ value borrowed here after move
|
note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary
--> $DIR/moves-based-on-type-exprs.rs:6:14
|
LL | fn guard(_s: String) -> bool {panic!()}
| ----- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | _ if guard(x.clone()) => 10,
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:65:11
@ -87,6 +129,11 @@ LL | let _y = [x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = [x.clone()];
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:71:11
@ -97,6 +144,11 @@ LL | let _y = vec![x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = vec![x.clone()];
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:77:11
@ -113,6 +165,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = x.clone().into_iter().next().unwrap();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:83:11
@ -129,6 +185,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = [x.clone().into_iter().next().unwrap(); 1];
| ++++++++
error: aborting due to 11 previous errors

View file

@ -8,6 +8,10 @@ LL | touch(&x);
| ^^ value borrowed here after partial move
|
= note: partial move occurs because `x.f` has type `String`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | Foo {ref f} => {}
| +++
error: aborting due to previous error

View file

@ -8,6 +8,11 @@ LL | Box::new((x, x))
| - ^ value used here after move
| |
| value moved here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | Box::new((x.clone(), x))
| ++++++++
error: aborting due to previous error

View file

@ -7,6 +7,11 @@ LL | (t, t)
| - ^ value used here after move
| |
| value moved here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | (t.clone(), t)
| ++++++++
error: aborting due to previous error

View file

@ -67,6 +67,11 @@ LL | || x.len();
| ^^ - borrow occurs due to use in closure
| |
| value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let r = x.clone();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/closure-access-spans.rs:40:5
@ -79,6 +84,11 @@ LL | || x = String::new();
| ^^ - borrow occurs due to use in closure
| |
| value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let r = x.clone();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/closure-access-spans.rs:45:5

View file

@ -37,6 +37,11 @@ LL | let mut t: T = (0, Box::new(0)); drop(t);
| move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait
LL | t.0 = 10; t.1 = Box::new(20);
| ^^^^^^^^ value partially assigned here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut t: T = (0, Box::new(0)); drop(t.clone());
| ++++++++
error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:123:5
@ -77,6 +82,11 @@ LL | let mut t: T = (0, Box::new(0)); drop(t);
| move occurs because `t` has type `(u32, Box<u32>)`, which does not implement the `Copy` trait
LL | t.0 = 10;
| ^^^^^^^^ value partially assigned here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut t: T = (0, Box::new(0)); drop(t.clone());
| ++++++++
error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:149:5
@ -208,6 +218,11 @@ LL | c2 => {
| -- value moved here
LL | c.0 = 2;
| ^^^^^^^ value partially assigned here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref c2 => {
| +++
error[E0382]: assign to part of moved value: `c`
--> $DIR/issue-21232-partial-init-and-use.rs:255:13
@ -219,6 +234,11 @@ LL | c2 => {
| -- value moved here
LL | (c.1).0 = 2;
| ^^^^^^^^^^^ value partially assigned here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref c2 => {
| +++
error[E0382]: assign to part of moved value: `c.1`
--> $DIR/issue-21232-partial-init-and-use.rs:263:13
@ -229,6 +249,10 @@ LL | ((c.1).1).0 = 3;
| ^^^^^^^^^^^^^^^ value partially assigned here after move
|
= note: move occurs because `c.1` has type `(i32, (i32, String))`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref c2 => {
| +++
error: aborting due to 23 previous errors

View file

@ -7,6 +7,11 @@ LL | let r = range;
| ----- value moved here
LL | let x = range.start;
| ^^^^^^^^^^^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let r = range.clone();
| ++++++++
error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | if let Some(thing) = maybe {
| ^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `Vec<bool>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `maybe.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | if let Some(ref thing) = maybe {
| +++

View file

@ -26,6 +26,11 @@ LL | false if { drop(x); true } => 1,
LL | true => {
LL | x;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | false if { drop(x.clone()); true } => 1,
| ++++++++
error: aborting due to 2 previous errors

View file

@ -7,6 +7,11 @@ LL | let y = x;
| - value moved here
LL | x;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let y = x.clone();
| ++++++++
error[E0382]: use of moved value: `x`
--> $DIR/ref-suggestion.rs:8:5
@ -17,6 +22,11 @@ LL | let mut y = x;
| - value moved here
LL | x;
| ^ value used here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut y = x.clone();
| ++++++++
error[E0382]: use of partially moved value: `x`
--> $DIR/ref-suggestion.rs:16:5
@ -28,7 +38,7 @@ LL | x;
| ^ value used here after partial move
|
= note: partial move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `x.0.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | (Some(ref y), ()) => {},
| +++

View file

@ -16,6 +16,11 @@ LL | Some(_z @ ref _y) => {}
| | value borrowed here after move
| value moved into `_z` here
| move occurs because `_z` has type `X` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref _z @ ref _y) => {}
| +++
error: cannot move out of value because it is borrowed
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:26:14
@ -35,6 +40,11 @@ LL | Some(_z @ ref mut _y) => {}
| | value borrowed here after move
| value moved into `_z` here
| move occurs because `_z` has type `X` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref _z @ ref mut _y) => {}
| +++
error[E0382]: borrow of moved value
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:12:14
@ -45,7 +55,7 @@ LL | Some(ref _y @ _z) => {}
| value borrowed here after move
|
= note: move occurs because value has type `X`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `x.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref _y @ ref _z) => {}
| +++
@ -59,7 +69,7 @@ LL | Some(ref mut _y @ _z) => {}
| value borrowed here after move
|
= note: move occurs because value has type `X`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `x.0`
help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref mut _y @ ref _z) => {}
| +++

View file

@ -6,6 +6,11 @@ LL | let a @ b = U;
| | |
| | value moved here
| value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = U;
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:13:9
@ -16,6 +21,10 @@ LL | let a @ (b, c) = (U, U);
| value used here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (b, ref c) = (U, U);
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:15:9
@ -26,6 +35,10 @@ LL | let a @ (b, c) = (u(), u());
| value used here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (b, ref c) = (u(), u());
| +++ +++
error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:18:16
@ -36,6 +49,11 @@ LL | a @ Ok(b) | a @ Err(b) => {}
| - ^ value used here after move
| |
| value moved here
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Ok(b) | a @ Err(b) => {}
| +++
error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:18:29
@ -46,6 +64,11 @@ LL | a @ Ok(b) | a @ Err(b) => {}
| - ^ value used here after move
| |
| value moved here
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | a @ Ok(b) | ref a @ Err(b) => {}
| +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:25:9
@ -56,6 +79,10 @@ LL | xs @ [a, .., b] => {}
| value used here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref xs @ [a, .., ref b] => {}
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-move-and-move.rs:29:9
@ -66,6 +93,10 @@ LL | xs @ [_, ys @ .., _] => {}
| value used here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref xs @ [_, ref ys @ .., _] => {}
| +++ +++
error[E0382]: use of moved value
--> $DIR/borrowck-move-and-move.rs:22:12

View file

@ -79,6 +79,10 @@ LL | let ref a @ box b = Box::new(NC);
| value borrowed here after move
|
= note: move occurs because value has type `NC`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ box ref b = Box::new(NC);
| +++
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-at-and-box.rs:38:9

View file

@ -7,6 +7,11 @@ LL | let a @ ref b = U;
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = U;
| +++
error: aborting due to previous error

View file

@ -7,6 +7,11 @@ LL | let a @ ref b = U;
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = U;
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9
@ -18,6 +23,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:14
@ -28,6 +38,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:33
@ -38,6 +53,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:29:9
@ -49,6 +69,11 @@ LL | let a @ [ref mut b, ref c] = [U, U];
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ [ref mut b, ref c] = [U, U];
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9
@ -59,6 +84,11 @@ LL | let a @ ref b = u();
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = u();
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9
@ -70,6 +100,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:14
@ -80,6 +115,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (u(), u());
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:33
@ -90,6 +130,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u());
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9
@ -101,6 +146,11 @@ LL | let a @ [ref mut b, ref c] = [u(), u()];
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ [ref mut b, ref c] = [u(), u()];
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:42:9
@ -111,6 +161,11 @@ LL | a @ Some(ref b) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some(ref b) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:9
@ -122,6 +177,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:19
@ -132,6 +192,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38
@ -142,6 +207,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:9
@ -153,6 +223,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref mut a @ Some([ref b, ref mut c]) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9
@ -163,6 +238,11 @@ LL | a @ Some(ref b) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some(ref b) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9
@ -174,6 +254,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19
@ -184,6 +269,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38
@ -194,6 +284,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9
@ -205,6 +300,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref mut a @ Some([ref b, ref mut c]) => {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11
@ -215,6 +315,11 @@ LL | fn f1(a @ ref b: U) {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f1(ref a @ ref b: U) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
@ -226,6 +331,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20
@ -236,6 +346,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31
@ -246,6 +361,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {}
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11
@ -257,6 +377,11 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {}
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {}
| +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9
@ -267,6 +392,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| value used here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (U, U);
| +++ +++
error[E0382]: use of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9
@ -277,6 +406,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| value used here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u());
| +++ +++
error[E0382]: use of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38
@ -285,6 +418,11 @@ LL | match Some((U, U)) {
| ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait
LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| - value moved here ^ value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:30
@ -305,6 +443,11 @@ LL | a @ Some(ref b) => {}
| - ^^^^^ value borrowed here after move
| |
| value moved here
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some(ref b) => {}
| +++
error[E0382]: use of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38
@ -313,6 +456,11 @@ LL | match Some((u(), u())) {
| ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait
LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| - value moved here ^ value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:30

View file

@ -242,6 +242,10 @@ LL | let ref mut a @ [b, mut c] = [U, U];
| value borrowed here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref mut a @ [b, ref mut c] = [U, U];
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:33:9
@ -251,6 +255,11 @@ LL | let ref a @ b = u();
| | |
| | value moved here
| value borrowed here after move
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ ref b = u();
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:18
@ -261,6 +270,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
| value borrowed here after move
|
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (ref b @ ref mut c, ref d @ e) = (u(), u());
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:36:33
@ -271,6 +284,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
| value borrowed here after move
|
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (ref b @ mut c, ref d @ ref e) = (u(), u());
| +++
error[E0382]: borrow of partially moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:42:9
@ -281,6 +298,10 @@ LL | let ref mut a @ [b, mut c] = [u(), u()];
| value borrowed here after partial move
|
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref mut a @ [b, ref mut c] = [u(), u()];
| +++
error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref.rs:69:23
@ -291,7 +312,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
| value borrowed here after move
|
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving the value
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {}
| +++
@ -305,7 +326,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {}
| value borrowed here after move
|
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving the value
help: borrow this binding in the pattern to avoid moving the value
|
LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {}
| +++

View file

@ -97,6 +97,11 @@ LL | let a @ (ref mut b, ref mut c) = (U, U);
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:67:9
@ -109,6 +114,11 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ (b, [c, d]) = &mut val; // Same as ^--
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:70:9
@ -119,6 +129,11 @@ LL | let a @ &mut ref mut b = &mut U;
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut U` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ &mut ref mut b = &mut U;
| +++
error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:72:9
@ -130,6 +145,11 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait
|
help: borrow this binding in the pattern to avoid moving the value
|
LL | let ref a @ &mut (ref mut b, ref mut c) = &mut (U, U);
| +++
error: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:76:9

Some files were not shown because too many files have changed in this diff Show more