From 0b033fbdc557248e59c14878289ecd187cfbdc64 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Wed, 13 May 2026 13:55:18 +0300 Subject: [PATCH 01/14] Remove method call generation in delegation --- compiler/rustc_ast_lowering/src/delegation.rs | 149 +- compiler/rustc_hir/src/hir.rs | 10 +- compiler/rustc_hir_analysis/src/delegation.rs | 18 +- compiler/rustc_hir_analysis/src/lib.rs | 2 +- compiler/rustc_hir_typeck/src/callee.rs | 109 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 10 +- .../rustc_hir_typeck/src/method/confirm.rs | 31 +- compiler/rustc_hir_typeck/src/method/mod.rs | 2 +- tests/pretty/delegation-inline-attribute.pp | 31 +- tests/pretty/delegation-self-rename.pp | 2 +- ...y_owner_parent_found_in_diagnostics.stderr | 47 +- .../delegation/generics/generics-aux-pass.rs | 5 - .../generics/impl-to-trait-method.rs | 1 - .../generics/impl-to-trait-method.stderr | 11 +- tests/ui/delegation/self-coercion-errors.rs | 232 ++ .../ui/delegation/self-coercion-errors.stderr | 1916 +++++++++++++++++ tests/ui/delegation/self-coercion.rs | 38 +- tests/ui/delegation/target-expr.stderr | 10 +- 18 files changed, 2445 insertions(+), 179 deletions(-) create mode 100644 tests/ui/delegation/self-coercion-errors.rs create mode 100644 tests/ui/delegation/self-coercion-errors.stderr diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index df5ea7c3168ff..7c8a0ffda4f6a 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -58,8 +58,8 @@ use smallvec::SmallVec; use crate::delegation::generics::{GenericsGenerationResult, GenericsGenerationResults}; use crate::errors::{CycleInDelegationSignatureResolution, UnresolvedDelegationCallee}; use crate::{ - AllowReturnTypeNotation, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext, - ParamMode, ResolverAstLoweringExt, + AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode, + ResolverAstLoweringExt, }; mod generics; @@ -152,8 +152,14 @@ impl<'hir> LoweringContext<'_, 'hir> { span, ); - let decl = - self.lower_delegation_decl(sig_id, param_count, c_variadic, span, &generics); + let decl = self.lower_delegation_decl( + sig_id, + param_count, + c_variadic, + span, + &generics, + delegation.id, + ); let sig = self.lower_delegation_sig(sig_id, decl, span); let ident = self.lower_ident(delegation.ident); @@ -280,6 +286,7 @@ impl<'hir> LoweringContext<'_, 'hir> { c_variadic: bool, span: Span, generics: &GenericsGenerationResults<'hir>, + call_path_node_id: NodeId, ) -> &'hir hir::FnDecl<'hir> { // The last parameter in C variadic functions is skipped in the signature, // like during regular lowering. @@ -297,7 +304,8 @@ impl<'hir> LoweringContext<'_, 'hir> { hir_id: self.next_id(), kind: hir::TyKind::InferDelegation(hir::InferDelegation::Sig( sig_id, - hir::InferDelegationSig::Output(self.arena.alloc(hir::DelegationGenerics { + hir::InferDelegationSig::Output(self.arena.alloc(hir::DelegationInfo { + call_path_res: self.get_resolution_id(call_path_node_id), child_args_segment_id: generics.child.args_segment_id, parent_args_segment_id: generics.parent.args_segment_id, self_ty_id: generics.self_ty_id, @@ -459,21 +467,6 @@ impl<'hir> LoweringContext<'_, 'hir> { self.mk_expr(hir::ExprKind::Block(block, None), block.span) } - // Generates expression for the resulting body. If possible, `MethodCall` is used - // to allow autoref/autoderef for target expression. For example in: - // - // trait Trait : Sized { - // fn by_value(self) -> i32 { 1 } - // fn by_mut_ref(&mut self) -> i32 { 2 } - // fn by_ref(&self) -> i32 { 3 } - // } - // - // struct NewType(SomeType); - // impl Trait for NewType { - // reuse Trait::* { self.0 } - // } - // - // `self.0` will automatically coerce. fn finalize_body_lowering( &mut self, delegation: &Delegation, @@ -481,86 +474,52 @@ impl<'hir> LoweringContext<'_, 'hir> { generics: &mut GenericsGenerationResults<'hir>, span: Span, ) -> hir::Expr<'hir> { - let args = self.arena.alloc_from_iter(args); - - let has_generic_args = - delegation.path.segments.iter().rev().skip(1).any(|segment| segment.args.is_some()); - - let call = if self - .get_resolution_id(delegation.id) - .map(|def_id| self.is_method(def_id, span)) - .unwrap_or_default() - && delegation.qself.is_none() - && !has_generic_args - && !args.is_empty() - { - let ast_segment = delegation.path.segments.last().unwrap(); - let segment = self.lower_path_segment( - delegation.path.span, - ast_segment, - ParamMode::Optional, - GenericArgsMode::Err, - ImplTraitContext::Disallowed(ImplTraitPosition::Path), - None, - ); - - // FIXME(fn_delegation): proper support for parent generics propagation - // in method call scenario. - let segment = self.process_segment(span, &segment, &mut generics.child); - let segment = self.arena.alloc(segment); - - self.arena.alloc(hir::Expr { - hir_id: self.next_id(), - kind: hir::ExprKind::MethodCall(segment, &args[0], &args[1..], span), - span, - }) - } else { - let path = self.lower_qpath( - delegation.id, - &delegation.qself, - &delegation.path, - ParamMode::Optional, - AllowReturnTypeNotation::No, - ImplTraitContext::Disallowed(ImplTraitPosition::Path), - None, - ); - - let new_path = match path { - hir::QPath::Resolved(ty, path) => { - let mut new_path = path.clone(); - let len = new_path.segments.len(); - - new_path.segments = self.arena.alloc_from_iter( - new_path.segments.iter().enumerate().map(|(idx, segment)| { - if idx + 2 == len { - self.process_segment(span, segment, &mut generics.parent) - } else if idx + 1 == len { - self.process_segment(span, segment, &mut generics.child) - } else { - segment.clone() - } - }), - ); - - hir::QPath::Resolved(ty, self.arena.alloc(new_path)) - } - hir::QPath::TypeRelative(ty, segment) => { - let segment = self.process_segment(span, segment, &mut generics.child); - - hir::QPath::TypeRelative(ty, self.arena.alloc(segment)) - } - }; + let path = self.lower_qpath( + delegation.id, + &delegation.qself, + &delegation.path, + ParamMode::Optional, + AllowReturnTypeNotation::No, + ImplTraitContext::Disallowed(ImplTraitPosition::Path), + None, + ); + + let new_path = match path { + hir::QPath::Resolved(ty, path) => { + let mut new_path = path.clone(); + let len = new_path.segments.len(); + + new_path.segments = self.arena.alloc_from_iter( + new_path.segments.iter().enumerate().map(|(idx, segment)| { + if idx + 2 == len { + self.process_segment(span, segment, &mut generics.parent) + } else if idx + 1 == len { + self.process_segment(span, segment, &mut generics.child) + } else { + segment.clone() + } + }), + ); - generics.self_ty_id = match new_path { - hir::QPath::Resolved(ty, _) => ty, - hir::QPath::TypeRelative(ty, _) => Some(ty), + hir::QPath::Resolved(ty, self.arena.alloc(new_path)) } - .map(|ty| ty.hir_id); + hir::QPath::TypeRelative(ty, segment) => { + let segment = self.process_segment(span, segment, &mut generics.child); - let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span)); - self.arena.alloc(self.mk_expr(hir::ExprKind::Call(callee_path, args), span)) + hir::QPath::TypeRelative(ty, self.arena.alloc(segment)) + } }; + generics.self_ty_id = match new_path { + hir::QPath::Resolved(ty, _) => ty, + hir::QPath::TypeRelative(ty, _) => Some(ty), + } + .map(|ty| ty.hir_id); + + let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span)); + let args = self.arena.alloc_from_iter(args); + let call = self.arena.alloc(self.mk_expr(hir::ExprKind::Call(callee_path, args), span)); + let block = self.arena.alloc(hir::Block { stmts: &[], expr: Some(call), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 0569c1b986d1a..07ad75f555310 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3864,9 +3864,9 @@ pub enum OpaqueTyOrigin { }, } -// Ids of parent (or child) path segment that contains user-specified args #[derive(Debug, Clone, Copy, PartialEq, Eq, StableHash)] -pub struct DelegationGenerics { +pub struct DelegationInfo { + pub call_path_res: Option, pub parent_args_segment_id: Option, pub child_args_segment_id: Option, pub self_ty_id: Option, @@ -3876,8 +3876,8 @@ pub struct DelegationGenerics { #[derive(Debug, Clone, Copy, PartialEq, Eq, StableHash)] pub enum InferDelegationSig<'hir> { Input(usize), - // Place generics info here, as we always specify output type for delegations. - Output(&'hir DelegationGenerics), + // Place delegation info here, as we always specify output type for delegations. + Output(&'hir DelegationInfo), } #[derive(Debug, Clone, Copy, PartialEq, Eq, StableHash)] @@ -4164,7 +4164,7 @@ impl<'hir> FnDecl<'hir> { None } - pub fn opt_delegation_generics(&self) -> Option<&'hir DelegationGenerics> { + pub fn opt_delegation_info(&self) -> Option<&'hir DelegationInfo> { if let FnRetTy::Return(ty) = self.output && let TyKind::InferDelegation(InferDelegation::Sig(_, kind)) = ty.kind && let InferDelegationSig::Output(generics) = kind diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index 2d6d5a5d81f9a..8c3a89c238540 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -7,7 +7,7 @@ use std::debug_assert_matches; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::{DelegationGenerics, HirId, PathSegment}; +use rustc_hir::{DelegationInfo, HirId, PathSegment}; use rustc_middle::ty::{ self, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; @@ -71,12 +71,18 @@ enum SelfPositionKind { None, } -fn get_delegation_generics(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> &DelegationGenerics { +pub fn is_delegation(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { + tcx.hir_node(tcx.local_def_id_to_hir_id(def_id)) + .fn_sig() + .is_some_and(|sig| sig.decl.opt_delegation_sig_id().is_some()) +} + +pub fn get_delegation_info(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> &DelegationInfo { tcx.hir_node(tcx.local_def_id_to_hir_id(delegation_id)) .fn_sig() .expect("processing delegation") .decl - .opt_delegation_generics() + .opt_delegation_info() .expect("processing delegation") } @@ -92,7 +98,7 @@ fn create_self_position_kind( | (FnKind::AssocTrait, FnKind::Free) => SelfPositionKind::Zero, (FnKind::Free, FnKind::AssocTrait) => { - let propagate_self_ty = get_delegation_generics(tcx, delegation_id).propagate_self_ty; + let propagate_self_ty = get_delegation_info(tcx, delegation_id).propagate_self_ty; SelfPositionKind::AfterLifetimes(propagate_self_ty) } @@ -278,7 +284,7 @@ fn get_parent_and_inheritance_kind<'tcx>( } fn get_delegation_self_ty_or_err(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> Ty<'_> { - get_delegation_generics(tcx, delegation_id) + get_delegation_info(tcx, delegation_id) .self_ty_id .map(|id| { let ctx = ItemCtxt::new(tcx, delegation_id); @@ -640,7 +646,7 @@ fn get_delegation_user_specified_args<'tcx>( tcx: TyCtxt<'tcx>, delegation_id: LocalDefId, ) -> (&'tcx [ty::GenericArg<'tcx>], &'tcx [ty::GenericArg<'tcx>]) { - let info = get_delegation_generics(tcx, delegation_id); + let info = get_delegation_info(tcx, delegation_id); let get_segment = |hir_id: HirId| -> Option<(&'tcx PathSegment<'tcx>, DefId)> { let segment = tcx.hir_node(hir_id).expect_path_segment(); diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 9cadaef8f886b..1e9bc80749881 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -73,7 +73,7 @@ mod check_unused; mod coherence; mod collect; mod constrained_generic_params; -mod delegation; +pub mod delegation; pub mod errors; pub mod hir_ty_lowering; pub mod hir_wf_check; diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index e15c9fe661641..f28b2ad8dea8f 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -3,19 +3,20 @@ use std::iter; use rustc_abi::{CanonAbi, ExternAbi}; use rustc_ast::util::parser::ExprPrecedence; use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey, msg}; -use rustc_hir::def::{self, CtorKind, Namespace, Res}; +use rustc_hir::def::{self, CtorKind, DefKind, Namespace, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId, LangItem, find_attr}; use rustc_hir_analysis::autoderef::Autoderef; +use rustc_hir_analysis::delegation::{get_delegation_info, is_delegation}; use rustc_infer::infer::BoundRegionConversionTime; use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode}; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, }; -use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt, Unnormalized}; +use rustc_middle::ty::{self, FnSig, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt, Unnormalized}; use rustc_middle::{bug, span_bug}; use rustc_span::def_id::LocalDefId; -use rustc_span::{Span, sym}; +use rustc_span::{Ident, Span, sym}; use rustc_target::spec::{AbiMap, AbiMapping}; use rustc_trait_selection::error_reporting::traits::DefIdOrName; use rustc_trait_selection::infer::InferCtxtExt as _; @@ -27,6 +28,8 @@ use super::method::probe::ProbeScope; use super::{Expectation, FnCtxt, TupleArgumentsFlag}; use crate::errors; use crate::method::TreatNotYetDefinedOpaques; +use crate::method::confirm::ConfirmContext; +use crate::method::probe::{IsSuggestion, Mode}; /// Checks that it is legal to call methods of the trait corresponding /// to `trait_id` (this only cares about the trait, not the specific @@ -591,16 +594,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let fn_sig = self.normalize(call_expr.span, Unnormalized::new_wip(fn_sig)); - self.check_argument_types( - call_expr.span, - call_expr, - fn_sig.inputs(), - fn_sig.output(), - expected, - arg_exprs, - fn_sig.c_variadic(), - TupleArgumentsFlag::DontTupleArguments, - def_id, + self.execute_delegation_aware_arguments_check( + &fn_sig, call_expr, arg_exprs, expected, def_id, ); if fn_sig.abi() == rustc_abi::ExternAbi::RustCall { @@ -620,6 +615,94 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn_sig.output() } + fn execute_delegation_aware_arguments_check( + &self, + fn_sig: &FnSig<'tcx>, + call_expr: &'tcx hir::Expr<'tcx>, + arg_exprs: &'tcx [hir::Expr<'tcx>], + expected: Expectation<'tcx>, + def_id: Option, + ) { + let do_check = || { + self.check_argument_types( + call_expr.span, + call_expr, + fn_sig.inputs(), + fn_sig.output(), + expected, + arg_exprs, + fn_sig.c_variadic(), + TupleArgumentsFlag::DontTupleArguments, + def_id, + ); + }; + + // Check that we are inside delegation and processing its call. Firstly we check that + // the parent of call expr. is delegation and then make sure that it is compiler-generated + // by comparing their spans (otherwise we will encounter errors in nested delegations, + // see tests\ui\delegation\impl-reuse-pass.rs:237). + let parent_def = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id; + if !is_delegation(self.tcx, parent_def) || self.tcx.def_span(parent_def) != call_expr.span { + return do_check(); + }; + + let Some(path_res_id) = get_delegation_info(self.tcx, parent_def).call_path_res else { + return do_check(); + }; + + // Check that delegation has first param, first provided arg and that the call path + // resolves to a trait function, we do not support free functions yet. + // FIXME(fn_delegation): support adjustments for free functions + if fn_sig.inputs().is_empty() + || arg_exprs.is_empty() + || !matches!(self.tcx.def_kind(path_res_id), DefKind::AssocFn) + || !matches!(self.tcx.def_kind(self.tcx.parent(path_res_id)), DefKind::Trait) + { + return do_check(); + }; + + let first_expr = &arg_exprs[0]; + let first_arg_type = self.check_expr(first_expr); + + // Reuse method probing that is used during method call, as all this code pretends that + // we generated method call. + let pick = self.probe_for_name( + Mode::MethodCall, + Ident::dummy(), + None, + IsSuggestion(false), + first_arg_type, + call_expr.hir_id, + ProbeScope::Single(path_res_id), + ); + + let Ok(ref pick) = pick else { return do_check() }; + + // Fool typechecker by placing an adjusted type of the first arg to avoid errors. + // We already wrote type of `first_expr` during `self.check_expr(first_expr)` above. + let first_arg_type = self + .typeck_results + .borrow_mut() + .node_types_mut() + .insert(first_expr.hir_id, pick.self_ty) + .expect("must be set"); + + do_check(); + + let mut results = self.typeck_results.borrow_mut(); + + // Remove any added adjustments for `first_expr` during `do_check` and replace them with ours. + let mut adjustments = results.adjustments_mut(); + let adjustments = adjustments.entry(first_expr.hir_id).or_default(); + adjustments.clear(); + + let mut ctx = ConfirmContext::new(self, first_expr.span, first_expr, first_expr); + adjustments.extend(ctx.create_ty_adjustments_from_pick(first_arg_type, pick).1); + + // Restore original first provided arg type. + results.node_types_mut().insert(first_expr.hir_id, first_arg_type); + } + /// Attempts to reinterpret `method(rcvr, args...)` as `rcvr.method(args...)` /// and suggesting the fix if the method probe is successful. fn suggest_call_as_method( diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 415630dab38b3..523871aa27953 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -13,6 +13,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::intravisit::Visitor; use rustc_hir::{Expr, ExprKind, FnRetTy, HirId, LangItem, Node, QPath, is_range_literal}; use rustc_hir_analysis::check::potentially_plural_count; +use rustc_hir_analysis::delegation::is_delegation; use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, ResolvedStructPath}; use rustc_index::IndexVec; use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk, TypeTrace}; @@ -329,7 +330,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let demand_compatible = |idx| { let formal_input_ty: Ty<'tcx> = formal_input_tys[idx]; let expected_input_ty: Ty<'tcx> = expected_input_tys[idx]; - let provided_arg = &provided_args[idx]; + let provided_arg: &hir::Expr<'tcx> = &provided_args[idx]; debug!("checking argument {}: {:?} = {:?}", idx, provided_arg, formal_input_ty); @@ -338,7 +339,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // 1. Unify the provided argument with the expected type let expectation = Expectation::rvalue_hint(self, expected_input_ty); - let checked_ty = self.check_expr_with_expectation(provided_arg, expectation); + // If we are processing first arg of delegation then we could have adjusted it + // in `execute_delegation_aware_arguments_check`. + let checked_ty = is_delegation(self.tcx, self.body_id) + .then(|| self.typeck_results.borrow().node_type_opt(provided_arg.hir_id)) + .flatten() + .unwrap_or_else(|| self.check_expr_with_expectation(provided_arg, expectation)); // 2. Coerce to the most detailed type that could be coerced // to, which is `expected_ty` if `rvalue_hint` returns an diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 0c83c1948d6f2..4ef6de12f7623 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -34,7 +34,7 @@ use super::{MethodCallee, probe}; use crate::errors::{SupertraitItemShadowee, SupertraitItemShadower, SupertraitItemShadowing}; use crate::{FnCtxt, callee}; -struct ConfirmContext<'a, 'tcx> { +pub(crate) struct ConfirmContext<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, span: Span, self_expr: &'tcx hir::Expr<'tcx>, @@ -90,7 +90,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { - fn new( + pub(crate) fn new( fcx: &'a FnCtxt<'a, 'tcx>, span: Span, self_expr: &'tcx hir::Expr<'tcx>, @@ -178,14 +178,32 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { ) -> Ty<'tcx> { // Commit the autoderefs by calling `autoderef` again, but this // time writing the results into the various typeck results. + let (target, adjustments) = self.create_ty_adjustments_from_pick(unadjusted_self_ty, pick); + + // Write out the final adjustments. + if !self.skip_record_for_diagnostics { + self.apply_adjustments(self.self_expr, adjustments); + } + + target + } + + pub(crate) fn create_ty_adjustments_from_pick( + &mut self, + unadjusted_self_ty: Ty<'tcx>, + pick: &probe::Pick<'tcx>, + ) -> (Ty<'tcx>, Vec>) { let mut autoderef = self.autoderef(self.call_expr.span, unadjusted_self_ty); let Some((mut target, n)) = autoderef.nth(pick.autoderefs) else { - return Ty::new_error_with_message( + let error_ty = Ty::new_error_with_message( self.tcx, DUMMY_SP, format!("failed autoderef {}", pick.autoderefs), ); + + return (error_ty, vec![]); }; + assert_eq!(n, pick.autoderefs); let mut adjustments = self.adjust_steps(&autoderef); @@ -260,12 +278,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.register_predicates(autoderef.into_obligations()); - // Write out the final adjustments. - if !self.skip_record_for_diagnostics { - self.apply_adjustments(self.self_expr, adjustments); - } - - target + (target, adjustments) } /// Returns a set of generic parameters for the method *receiver* where all type and region diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index 49126ff0e964c..2ebff26ff9822 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -2,7 +2,7 @@ //! //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir-typeck/method-lookup.html -mod confirm; +pub(crate) mod confirm; mod prelude_edition_lints; pub(crate) mod probe; mod suggest; diff --git a/tests/pretty/delegation-inline-attribute.pp b/tests/pretty/delegation-inline-attribute.pp index 125ed1c298262..fc409aa636d5c 100644 --- a/tests/pretty/delegation-inline-attribute.pp +++ b/tests/pretty/delegation-inline-attribute.pp @@ -38,33 +38,34 @@ fn foo(self: _) -> _ { - { - // Check that #[inline(hint)] is added to foo0 reuse inside another reuse + Trait::foo( + // Check that #[inline(hint)] is added to foo0 reuse inside another reuse + + // Check that #[inline(hint)] is added when other attributes present in inner reuse + + // Check that #[inline(never)] is preserved in inner reuse + + // Check that #[inline(always)] is preserved in inner reuse + + // Check that #[inline(never)] is preserved when there are other attributes in inner reuse + { #[attr = Inline(Hint)] fn foo0(arg0: _) -> _ { to_reuse::foo(self + 1) } - - // Check that #[inline(hint)] is added when other attributes present in inner reuse #[attr = Cold] #[attr = MustUse] #[attr = Deprecated {deprecation: Deprecation {since: Unspecified}}] #[attr = Inline(Hint)] fn foo1(arg0: _) -> _ { to_reuse::foo(self / 2) } - - // Check that #[inline(never)] is preserved in inner reuse #[attr = Inline(Never)] fn foo2(arg0: _) -> _ { to_reuse::foo(self / 2) } - - // Check that #[inline(always)] is preserved in inner reuse #[attr = Inline(Always)] fn foo3(arg0: _) -> _ { to_reuse::foo(self / 2) } - - // Check that #[inline(never)] is preserved when there are other attributes in inner reuse #[attr = Cold] #[attr = MustUse] #[attr = Inline(Never)] #[attr = Deprecated {deprecation: Deprecation {since: Unspecified}}] fn foo4(arg0: _) -> _ { to_reuse::foo(self / 2) } - }.foo() + }) } // Check that #[inline(hint)] is added when there are other attributes present in trait reuse @@ -72,22 +73,22 @@ #[attr = MustUse] #[attr = Deprecated {deprecation: Deprecation {since: Unspecified}}] #[attr = Inline(Hint)] - fn foo1(self: _) -> _ { self.0.foo1() } + fn foo1(self: _) -> _ { Trait::foo1(self.0) } // Check that #[inline(never)] is preserved in trait reuse #[attr = Inline(Never)] - fn foo2(self: _) -> _ { self.0.foo2() } + fn foo2(self: _) -> _ { Trait::foo2(self.0) } // Check that #[inline(always)] is preserved in trait reuse #[attr = Inline(Always)] - fn foo3(self: _) -> _ { self.0.foo3() } + fn foo3(self: _) -> _ { Trait::foo3(self.0) } // Check that #[inline(never)] is preserved when there are other attributes in trait reuse #[attr = Cold] #[attr = MustUse] #[attr = Inline(Never)] #[attr = Deprecated {deprecation: Deprecation {since: Unspecified}}] - fn foo4(self: _) -> _ { self.0.foo4() } + fn foo4(self: _) -> _ { Trait::foo4(self.0) } } fn main() { } diff --git a/tests/pretty/delegation-self-rename.pp b/tests/pretty/delegation-self-rename.pp index 59a07315185c7..7f7afc403607b 100644 --- a/tests/pretty/delegation-self-rename.pp +++ b/tests/pretty/delegation-self-rename.pp @@ -19,7 +19,7 @@ #[attr = Inline(Hint)] fn foo<'a, Self, A, const B: _, const B2: _, T, U, impl FnOnce() -> usize>(self: _, arg1: _) -> _ where - 'a:'a { self.foo::(arg1) } + 'a:'a { Trait::<'a, A, B>::foo::(self, arg1) } #[attr = Inline(Hint)] fn bar usize>(self: _, arg1: _) -> _ { Trait::<'static, (), true>::foo::(self, arg1) } diff --git a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr index ab0c6d66e9c51..9537e45f3b8f0 100644 --- a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr +++ b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr @@ -65,13 +65,20 @@ LL | impl Trait for Z { | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:44 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>` + | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&u8`, found `&InvariantRef<'_, ()>` + | | + | arguments to this function are incorrect | - = note: expected type `u8` - found struct `InvariantRef<'_, ()>` + = note: expected reference `&u8` + found reference `&InvariantRef<'_, ()>` +note: method defined here + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:13:8 + | +LL | fn foo(&self) -> u8 { 0 } + | ^^^ ----- error[E0277]: the trait bound `u8: Trait` is not satisfied --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12 @@ -87,14 +94,20 @@ LL | impl Trait for Z { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:44 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>` + | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&u8`, found `&InvariantRef<'_, ()>` + | | + | arguments to this function are incorrect | - = note: expected type `u8` - found struct `InvariantRef<'_, ()>` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: expected reference `&u8` + found reference `&InvariantRef<'_, ()>` +note: method defined here + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:14:8 + | +LL | fn bar(&self) -> u8 { 1 } + | ^^^ ----- error[E0277]: the trait bound `u8: Trait` is not satisfied --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12 @@ -110,14 +123,20 @@ LL | impl Trait for Z { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:44 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>` + | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&u8`, found `&InvariantRef<'_, ()>` + | | + | arguments to this function are incorrect | - = note: expected type `u8` - found struct `InvariantRef<'_, ()>` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: expected reference `&u8` + found reference `&InvariantRef<'_, ()>` +note: method defined here + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:15:8 + | +LL | fn meh(&self) -> u8 { 2 } + | ^^^ ----- error: aborting due to 10 previous errors diff --git a/tests/ui/delegation/generics/generics-aux-pass.rs b/tests/ui/delegation/generics/generics-aux-pass.rs index 06f5c6d4d212e..f5d49c03a6137 100644 --- a/tests/ui/delegation/generics/generics-aux-pass.rs +++ b/tests/ui/delegation/generics/generics-aux-pass.rs @@ -16,20 +16,17 @@ impl generics::Trait<'static, i32, 1> for X {} impl X { reuse generics::foo as bar; - reuse generics::Trait::foo as trait_foo; reuse generics::foo::<'static, 'static, i32, i32, 1> as bar1; reuse generics::Trait::<'static, i32, 1>::foo::<'static, i32, false> as trait_foo1; } trait LocalTrait { - fn get() -> u8 { 123 } fn get_self(&self) -> u8 { 123 } reuse generics::foo as bar; reuse generics::foo::<'static, 'static, i32, i32, 1> as bar1; - reuse generics::Trait::foo as trait_foo { Self::get() } reuse generics::Trait::<'static, i32, 1>::foo::<'static, i32, false> as trait_foo1 { Self::get_self(&self) } @@ -50,13 +47,11 @@ fn main() { X::bar::(); X::bar::<'static, 'static, i32, i32, 1>(); X::bar1(); - x.trait_foo::<'static, 'static, i32, 1, String, true>(); x.trait_foo1(); ::bar::(); ::bar::<'static, 'static, i32, i32, 1>(); ::bar1(); - 1usize.trait_foo::<'static, 'static, i32, 1, String, true>(); 1usize.trait_foo1(); } diff --git a/tests/ui/delegation/generics/impl-to-trait-method.rs b/tests/ui/delegation/generics/impl-to-trait-method.rs index 102e905068e2a..88d6e4fdaabef 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.rs +++ b/tests/ui/delegation/generics/impl-to-trait-method.rs @@ -36,7 +36,6 @@ mod unconstrained_parameter { struct S(F); impl S { reuse Trait::foo { &self.0 } - //~^ ERROR type annotations needed } } diff --git a/tests/ui/delegation/generics/impl-to-trait-method.stderr b/tests/ui/delegation/generics/impl-to-trait-method.stderr index 114ebf48cca06..34259d49a1bd9 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.stderr +++ b/tests/ui/delegation/generics/impl-to-trait-method.stderr @@ -46,13 +46,6 @@ LL | fn foo(&self) LL | Self: Trait0, | ^^^^^^ required by this bound in `Trait1::foo` -error[E0282]: type annotations needed - --> $DIR/impl-to-trait-method.rs:38:22 - | -LL | reuse Trait::foo { &self.0 } - | ^^^ cannot infer type for type parameter `T` declared on the trait `Trait` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0282. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/self-coercion-errors.rs b/tests/ui/delegation/self-coercion-errors.rs new file mode 100644 index 0000000000000..5a8cf886cd05a --- /dev/null +++ b/tests/ui/delegation/self-coercion-errors.rs @@ -0,0 +1,232 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +use std::sync::Arc; +use std::pin::Pin; +use std::rc::Rc; + +trait Trait: Sized { + fn by_value(self) -> i32 { 1 } + fn by_mut_ref(&mut self) -> i32 { 2 } + fn by_ref(&self) -> i32 { 3 } + fn r#box(self: Box) -> i32 { 4 } + fn arc(self: Arc) -> i32 { 5 } + fn rc(self: Rc) -> i32 { 6 } + fn pin_box(self: Pin>) -> i32 { 7 } + fn pin_rc(self: Pin>) -> i32 { 8 } + fn pin_arc(self: Pin>) -> i32 { 9 } + fn box_box(self: Box>) -> i32 { 10 } +} + +struct F; +impl Trait for F {} + +struct S(F); + +fn foo() -> F { + F +} + +impl S { + reuse Trait::{by_value, by_mut_ref, by_ref} { + println!("123"); + let x = &self.0; + foo() + } +} + +struct S1(F); + +impl S1 { + reuse Trait::{by_value, by_mut_ref, by_ref} { + //~^ ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: the trait bound `fn() -> F {foo}: Trait` is not satisfied + println!("123"); + let x = &self.0; + foo + } +} + +struct S2(F); + +impl S2 { + reuse Trait::{by_value, by_mut_ref, by_ref} { + println!("123"); + let x = &self.0; + let x = foo(); + + x + } +} + +struct S3(F); + +impl S3 { + reuse Trait::{by_value, by_mut_ref, by_ref} { + println!("123"); + let x = &self.0; + let x = foo(); + + &mut x + //~^ ERROR: cannot borrow `x` as mutable, as it is not declared as mutable + //~| ERROR: cannot borrow `x` as mutable, as it is not declared as mutable + //~| ERROR: cannot borrow `x` as mutable, as it is not declared as mutable + //~| ERROR: cannot move out of a mutable reference + } +} + +struct X(F); + +impl X { + reuse Trait::* { &mut self.0 } + //~^ ERROR: cannot borrow `self.0` as mutable, as it is behind a `&` reference + //~| ERROR: cannot borrow `self.0` as mutable, as `self` is not declared as mutable + //~| ERROR: cannot move out of a mutable reference + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X1(F); + +impl X1 { + reuse Trait::* { &self.0 } + //~^ ERROR: cannot borrow data in a `&` reference as mutable + //~| ERROR: cannot move out of a shared reference + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X2(F); + +impl X2 { + reuse Trait::* { &&&&self.0 } + //~^ ERROR: cannot move out of a shared reference + //~| ERROR: cannot borrow data in a `&` reference as mutable + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X3(Box); + +impl X3 { + reuse Trait::* { self.0.as_ref() } + //~^ ERROR: cannot borrow data in a `&` reference as mutable + //~| ERROR: cannot move out of a shared reference + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X4(F); + +impl X4 { + reuse Trait::* { &mut &mut &mut self.0 } + //~^ ERROR: cannot move out of a mutable reference + //~| ERROR: cannot borrow `self.0` as mutable, as `self` is not declared as mutable + //~| ERROR: cannot borrow `self.0` as mutable, as it is behind a `&` reference + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X5(F); + +impl X5 { + reuse Trait::* { &&mut self.0 } + //~^ ERROR: cannot borrow `self.0` as mutable, as it is behind a `&` reference + //~| ERROR: cannot borrow data in a `&` reference as mutable [E0596] + //~| ERROR: cannot borrow `self.0` as mutable, as `self` is not declared as mutable + //~| ERROR: cannot move out of a shared reference + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X6(Box); + +impl X6 { + reuse Trait::* { self.0 } + //~^ ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X7(Box>>); + +impl X7 { + reuse Trait::* { self.0 } + //~^ ERROR: cannot borrow data in an `Arc` as mutable + //~| ERROR: cannot move out of an `Arc` + //~| ERROR: cannot move out of an `Arc` + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct X8(Pin>); + +impl X8 { + reuse Trait::* { self.0 } + //~^ ERROR: cannot move out of dereference of `Pin>` + //~| ERROR: cannot borrow data in dereference of `Pin>` as mutable + //~| ERROR: cannot move out of dereference of `Pin>` + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +struct OtherStruct; +struct X9(OtherStruct); + +impl X9 { + reuse Trait::* { self.0 } + //~^ ERROR: the trait bound `OtherStruct: Trait` is not satisfied + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types + //~| ERROR: mismatched types +} + +fn main() {} diff --git a/tests/ui/delegation/self-coercion-errors.stderr b/tests/ui/delegation/self-coercion-errors.stderr new file mode 100644 index 0000000000000..993dd55314398 --- /dev/null +++ b/tests/ui/delegation/self-coercion-errors.stderr @@ -0,0 +1,1916 @@ +error[E0277]: the trait bound `fn() -> F {foo}: Trait` is not satisfied + --> $DIR/self-coercion-errors.rs:41:49 + | +LL | reuse Trait::{by_value, by_mut_ref, by_ref} { + | ___________________--------______________________^ + | | | + | | required by a bound introduced by this call +... | +LL | | foo + | | --- this tail expression is of type `fn() -> F {foo}` +LL | | } + | |_____^ the trait `Trait` is not implemented for fn item `fn() -> F {foo}` + | +help: use parentheses to call this function + | +LL | }() + | ++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:41:49 + | +LL | reuse Trait::{by_value, by_mut_ref, by_ref} { + | _____________________________----------__________^ + | | | + | | arguments to this function are incorrect +... | +LL | | foo +LL | | } + | |_____^ expected `&mut _`, found fn item + | + = note: expected mutable reference `&mut _` + found fn item `fn() -> F {foo}` +note: method defined here + --> $DIR/self-coercion-errors.rs:10:8 + | +LL | fn by_mut_ref(&mut self) -> i32 { 2 } + | ^^^^^^^^^^ --------- +help: consider mutably borrowing here + | +LL | &mut foo + | ++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:41:49 + | +LL | reuse Trait::{by_value, by_mut_ref, by_ref} { + | _________________________________________------__^ + | | | + | | arguments to this function are incorrect +... | +LL | | foo +LL | | } + | |_____^ expected `&_`, found fn item + | + = note: expected reference `&_` + found fn item `fn() -> F {foo}` +note: method defined here + --> $DIR/self-coercion-errors.rs:11:8 + | +LL | fn by_ref(&self) -> i32 { 3 } + | ^^^^^^ ----- +help: consider borrowing here + | +LL | &foo + | + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Box<_>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<_>` + found mutable reference `&mut F` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: store this in the heap by calling `Box::new` + | +LL | reuse Trait::* { Box::new(&mut self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Arc<_>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found mutable reference `&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: call `Into::into` on this expression to convert `&mut F` into `Arc<_>` + | +LL | reuse Trait::* { (&mut self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Rc<_>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found mutable reference `&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: call `Into::into` on this expression to convert `&mut F` into `Rc<_>` + | +LL | reuse Trait::* { (&mut self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found mutable reference `&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: you need to pin and box this expression + | +LL | reuse Trait::* { Box::pin(&mut self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found mutable reference `&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found mutable reference `&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ expected `Box>`, found `&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box>` + found mutable reference `&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Box<_>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<_>` + found reference `&F` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: store this in the heap by calling `Box::new` + | +LL | reuse Trait::* { Box::new(&self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Arc<_>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: call `Into::into` on this expression to convert `&F` into `Arc<_>` + | +LL | reuse Trait::* { (&self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Rc<_>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: call `Into::into` on this expression to convert `&F` into `Rc<_>` + | +LL | reuse Trait::* { (&self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Pin>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: you need to pin and box this expression + | +LL | reuse Trait::* { Box::pin(&self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Pin>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Pin>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ expected `Box>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Box<_>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<_>` + found reference `&&&&F` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: store this in the heap by calling `Box::new` + | +LL | reuse Trait::* { Box::new(&&&&self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Arc<_>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found reference `&&&&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: call `Into::into` on this expression to convert `&&&&F` into `Arc<_>` + | +LL | reuse Trait::* { (&&&&self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Rc<_>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found reference `&&&&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: call `Into::into` on this expression to convert `&&&&F` into `Rc<_>` + | +LL | reuse Trait::* { (&&&&self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&&&&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: you need to pin and box this expression + | +LL | reuse Trait::* { Box::pin(&&&&self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&&&&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&&&&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ expected `Box>`, found `&&&&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box>` + found reference `&&&&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Box<_>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<_>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: try removing the method call + | +LL - reuse Trait::* { self.0.as_ref() } +LL + reuse Trait::* { self.0 } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Arc<_>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: call `Into::into` on this expression to convert `&F` into `Arc<_>` + | +LL | reuse Trait::* { self.0.as_ref().into() } + | +++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Rc<_>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: call `Into::into` on this expression to convert `&F` into `Rc<_>` + | +LL | reuse Trait::* { self.0.as_ref().into() } + | +++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: you need to pin and box this expression + | +LL | reuse Trait::* { Box::pin(self.0.as_ref()) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ expected `Box>`, found `&F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box>` + found reference `&F` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Box<_>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<_>` + found mutable reference `&mut &mut &mut F` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: store this in the heap by calling `Box::new` + | +LL | reuse Trait::* { Box::new(&mut &mut &mut self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Arc<_>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found mutable reference `&mut &mut &mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: call `Into::into` on this expression to convert `&mut &mut &mut F` into `Arc<_>` + | +LL | reuse Trait::* { (&mut &mut &mut self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Rc<_>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found mutable reference `&mut &mut &mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: call `Into::into` on this expression to convert `&mut &mut &mut F` into `Rc<_>` + | +LL | reuse Trait::* { (&mut &mut &mut self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found mutable reference `&mut &mut &mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: you need to pin and box this expression + | +LL | reuse Trait::* { Box::pin(&mut &mut &mut self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found mutable reference `&mut &mut &mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found mutable reference `&mut &mut &mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ expected `Box>`, found `&mut &mut &mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box>` + found mutable reference `&mut &mut &mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Box<_>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<_>` + found reference `&&mut F` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: store this in the heap by calling `Box::new` + | +LL | reuse Trait::* { Box::new(&&mut self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Arc<_>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found reference `&&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: call `Into::into` on this expression to convert `&&mut F` into `Arc<_>` + | +LL | reuse Trait::* { (&&mut self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Rc<_>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found reference `&&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: call `Into::into` on this expression to convert `&&mut F` into `Rc<_>` + | +LL | reuse Trait::* { (&&mut self.0).into() } + | + ++++++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: you need to pin and box this expression + | +LL | reuse Trait::* { Box::pin(&&mut self.0) } + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found reference `&&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ expected `Box>`, found `&&mut F` + | | + | arguments to this function are incorrect + | + = note: expected struct `Box>` + found reference `&&mut F` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:176:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Arc<_>`, found `Box` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found struct `Box` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:176:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Rc<_>`, found `Box` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found struct `Box` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:176:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Box` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Box` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:176:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Box` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Box` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:176:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Box` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Box` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:176:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Box>`, found `Box` + | | + | arguments to this function are incorrect + | +note: there is a field `0` on `Box>` with type `std::ptr::Unique>` but it is private; `0` from `X6` was accessed through auto-deref instead + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: in this struct + ::: $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: if this field wasn't private, it would be accessible + | + ::: $DIR/self-coercion-errors.rs:173:8 + | +LL | struct X6(Box); + | -- ------ this is the field that was accessed + | | + | this struct is accessible through auto-deref + = note: expected struct `Box>` + found struct `Box` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Arc<_>`, found `Box>>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found struct `Box>>` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: consider unboxing the value + | +LL | reuse Trait::* { *self.0 } + | + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Rc<_>`, found `Box>>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found struct `Box>>` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Box>>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Box>>` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Box>>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Box>>` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Box>>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Box>>` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Box>`, found `Box>>` + | | + | arguments to this function are incorrect + | +note: there is a field `0` on `Box>` with type `std::ptr::Unique>` but it is private; `0` from `X7` was accessed through auto-deref instead + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: in this struct + ::: $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: if this field wasn't private, it would be accessible + | + ::: $DIR/self-coercion-errors.rs:185:8 + | +LL | struct X7(Box>>); + | -- ---------------- this is the field that was accessed + | | + | this struct is accessible through auto-deref + = note: expected struct `Box>` + found struct `Box>>` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Box<_>`, found `Pin>` + | | + | arguments to this function are incorrect + | +note: there is a field `0` on `Box` with type `std::ptr::Unique` but it is private; `0` from `X8` was accessed through auto-deref instead + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: in this struct + ::: $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: if this field wasn't private, it would be accessible + | + ::: $DIR/self-coercion-errors.rs:200:8 + | +LL | struct X8(Pin>); + | -- ----------- this is the field that was accessed + | | + | this struct is accessible through auto-deref + = note: expected struct `Box<_>` + found struct `Pin>` +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Arc<_>`, found `Pin>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found struct `Pin>` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Rc<_>`, found `Pin>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found struct `Pin>` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Pin>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Pin>` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `Pin>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `Pin>` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Box>`, found `Pin>` + | | + | arguments to this function are incorrect + | +note: there is a field `0` on `Box>` with type `std::ptr::Unique>` but it is private; `0` from `X8` was accessed through auto-deref instead + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: in this struct + ::: $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: if this field wasn't private, it would be accessible + | + ::: $DIR/self-coercion-errors.rs:200:8 + | +LL | struct X8(Pin>); + | -- ----------- this is the field that was accessed + | | + | this struct is accessible through auto-deref + = note: expected struct `Box>` + found struct `Pin>` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0277]: the trait bound `OtherStruct: Trait` is not satisfied + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | +help: the trait `Trait` is not implemented for `OtherStruct` + --> $DIR/self-coercion-errors.rs:215:1 + | +LL | struct OtherStruct; + | ^^^^^^^^^^^^^^^^^^ +help: the trait `Trait` is implemented for `F` + --> $DIR/self-coercion-errors.rs:22:1 + | +LL | impl Trait for F {} + | ^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `&mut _`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected mutable reference `&mut _` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:10:8 + | +LL | fn by_mut_ref(&mut self) -> i32 { 2 } + | ^^^^^^^^^^ --------- +help: consider mutably borrowing here + | +LL | reuse Trait::* { &mut self.0 } + | ++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `&_`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected reference `&_` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:11:8 + | +LL | fn by_ref(&self) -> i32 { 3 } + | ^^^^^^ ----- +help: consider borrowing here + | +LL | reuse Trait::* { &self.0 } + | + + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Box<_>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | +note: there is a field `0` on `Box` with type `std::ptr::Unique` but it is private; `0` from `X9` was accessed through auto-deref instead + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: in this struct + ::: $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: if this field wasn't private, it would be accessible + | + ::: $DIR/self-coercion-errors.rs:216:8 + | +LL | struct X9(OtherStruct); + | -- ----------- this is the field that was accessed + | | + | this struct is accessible through auto-deref + = note: expected struct `Box<_>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:12:8 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Arc<_>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected struct `Arc<_>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:13:8 + | +LL | fn arc(self: Arc) -> i32 { 5 } + | ^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Rc<_>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected struct `Rc<_>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:14:8 + | +LL | fn rc(self: Rc) -> i32 { 6 } + | ^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:15:8 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:16:8 + | +LL | fn pin_rc(self: Pin>) -> i32 { 8 } + | ^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Pin>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | + = note: expected struct `Pin>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:17:8 + | +LL | fn pin_arc(self: Pin>) -> i32 { 9 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0308]: mismatched types + --> $DIR/self-coercion-errors.rs:219:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ expected `Box>`, found `OtherStruct` + | | + | arguments to this function are incorrect + | +note: there is a field `0` on `Box>` with type `std::ptr::Unique>` but it is private; `0` from `X9` was accessed through auto-deref instead + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: in this struct + ::: $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: if this field wasn't private, it would be accessible + | + ::: $DIR/self-coercion-errors.rs:216:8 + | +LL | struct X9(OtherStruct); + | -- ----------- this is the field that was accessed + | | + | this struct is accessible through auto-deref + = note: expected struct `Box>` + found struct `OtherStruct` +note: method defined here + --> $DIR/self-coercion-errors.rs:18:8 + | +LL | fn box_box(self: Box>) -> i32 { 10 } + | ^^^^^^^ ---- +help: consider removing the tuple struct field `0` + | +LL - reuse Trait::* { self.0 } +LL + reuse Trait::* { self } + | + +error[E0507]: cannot move out of a mutable reference + --> $DIR/self-coercion-errors.rs:71:9 + | +LL | reuse Trait::{by_value, by_mut_ref, by_ref} { + | -------- value moved due to this method call +... +LL | &mut x + | ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | &mut x + | ------ you could clone this value + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/self-coercion-errors.rs:71:9 + | +LL | &mut x + | ^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | let mut x = foo(); + | +++ + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/self-coercion-errors.rs:71:9 + | +LL | &mut x + | ^^^^^^ cannot borrow as mutable + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider changing this to be mutable + | +LL | let mut x = foo(); + | +++ + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/self-coercion-errors.rs:71:9 + | +LL | &mut x + | ^^^^^^ cannot borrow as mutable + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider changing this to be mutable + | +LL | let mut x = foo(); + | +++ + +error[E0507]: cannot move out of a mutable reference + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | - ^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { &mut self.0 } + | ----------- you could clone this value + +error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | ^^^^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | reuse Trait::mut * { &mut self.0 } + | +++ + +error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference + --> $DIR/self-coercion-errors.rs:82:22 + | +LL | reuse Trait::* { &mut self.0 } + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +LL - reuse Trait::* { &mut self.0 } +LL + reuse Trait::&mut self { &mut self.0 } + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | - ^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { &self.0 } + | ------- you could clone this value + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/self-coercion-errors.rs:98:22 + | +LL | reuse Trait::* { &self.0 } + | ^^^^^^^ cannot borrow as mutable + +error[E0507]: cannot move out of a shared reference + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | - ^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { &&&&self.0 } + | ---------- you could clone this value + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/self-coercion-errors.rs:113:22 + | +LL | reuse Trait::* { &&&&self.0 } + | ^^^^^^^^^^ cannot borrow as mutable + +error[E0507]: cannot move out of a shared reference + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | - ^^^^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { self.0.as_ref() } + | --------------- you could clone this value + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/self-coercion-errors.rs:128:22 + | +LL | reuse Trait::* { self.0.as_ref() } + | ^^^^^^^^^^^^^^^ cannot borrow as mutable + +error[E0507]: cannot move out of a mutable reference + --> $DIR/self-coercion-errors.rs:143:22 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | - ^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { &mut &mut &mut self.0 } + | --------------------- you could clone this value + +error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable + --> $DIR/self-coercion-errors.rs:143:32 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | ^^^^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | reuse Trait::mut * { &mut &mut &mut self.0 } + | +++ + +error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference + --> $DIR/self-coercion-errors.rs:143:32 + | +LL | reuse Trait::* { &mut &mut &mut self.0 } + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +LL - reuse Trait::* { &mut &mut &mut self.0 } +LL + reuse Trait::&mut self { &mut &mut &mut self.0 } + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | - ^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { &&mut self.0 } + | ------------ you could clone this value + +error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable + --> $DIR/self-coercion-errors.rs:159:23 + | +LL | reuse Trait::* { &&mut self.0 } + | ^^^^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | reuse Trait::mut * { &&mut self.0 } + | +++ + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/self-coercion-errors.rs:159:22 + | +LL | reuse Trait::* { &&mut self.0 } + | ^^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference + --> $DIR/self-coercion-errors.rs:159:23 + | +LL | reuse Trait::* { &&mut self.0 } + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +LL - reuse Trait::* { &&mut self.0 } +LL + reuse Trait::&mut self { &&mut self.0 } + | + +error[E0507]: cannot move out of an `Arc` + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { self.0 } + | ------ you could clone this value + +error[E0596]: cannot borrow data in an `Arc` as mutable + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | ^^^^^^ cannot borrow as mutable + | + = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Arc>` + +error[E0507]: cannot move out of an `Arc` + --> $DIR/self-coercion-errors.rs:188:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ move occurs because value has type `Box`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::r#box` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:12:14 + | +LL | fn r#box(self: Box) -> i32 { 4 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { self.0 } + | ------ you could clone this value +help: you could `clone` the value and consume it, if the `F: Clone` trait bound could be satisfied + | +LL | reuse Trait::* { as Clone>::clone(&self.0) } + | ++++++++++++++++++++++++++ + +help: consider annotating `F` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct F; + | + +error[E0507]: cannot move out of dereference of `Pin>` + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::by_value` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:9:17 + | +LL | fn by_value(self) -> i32 { 1 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { self.0 } + | ------ you could clone this value + +error[E0596]: cannot borrow data in dereference of `Pin>` as mutable + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | ^^^^^^ cannot borrow as mutable + | + = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Pin>` + +error[E0507]: cannot move out of dereference of `Pin>` + --> $DIR/self-coercion-errors.rs:203:22 + | +LL | reuse Trait::* { self.0 } + | - ^^^^^^ move occurs because value has type `Pin>`, which does not implement the `Copy` trait + | | + | value moved due to this method call + | +note: `Trait::pin_box` takes ownership of the receiver `self`, which moves value + --> $DIR/self-coercion-errors.rs:15:16 + | +LL | fn pin_box(self: Pin>) -> i32 { 7 } + | ^^^^ +note: if `F` implemented `Clone`, you could clone the value + --> $DIR/self-coercion-errors.rs:21:1 + | +LL | struct F; + | ^^^^^^^^ consider implementing `Clone` for this type +... +LL | reuse Trait::* { self.0 } + | ------ you could clone this value +help: you could `clone` the value and consume it, if the `F: Clone` trait bound could be satisfied + | +LL | reuse Trait::* { > as Clone>::clone(&self.0) } + | +++++++++++++++++++++++++++++++ + +help: consider annotating `F` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct F; + | + +error: aborting due to 99 previous errors + +Some errors have detailed explanations: E0277, E0308, E0507, E0596. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/self-coercion.rs b/tests/ui/delegation/self-coercion.rs index e6c71ec1e257b..b1d4d8a810c44 100644 --- a/tests/ui/delegation/self-coercion.rs +++ b/tests/ui/delegation/self-coercion.rs @@ -2,12 +2,19 @@ #![feature(fn_delegation)] -trait Trait : Sized { +trait Trait: Sized { + fn static_self() -> F { F } + fn by_value(self) -> i32 { 1 } fn by_mut_ref(&mut self) -> i32 { 2 } fn by_ref(&self) -> i32 { 3 } + + fn static_value(_: Self) -> i32 { 1 } + fn static_mut_ref(_: &mut Self) -> i32 { 2 } + fn static_ref(_: &Self) -> i32 { 3 } } +#[derive(Default)] struct F; impl Trait for F {} @@ -15,6 +22,20 @@ struct S(F); impl Trait for S { reuse Trait::{by_value, by_mut_ref, by_ref} { self.0 } + reuse ::{static_value, static_mut_ref, static_ref} { + let _ = self; + S::static_self() + } +} + +struct S1(Box>>>>>); + +impl Trait for S1 { + reuse Trait::{by_value, by_mut_ref, by_ref} { self.0 } + reuse ::{static_value, static_mut_ref, static_ref} { + let _ = self; + S1::static_self() + } } fn main() { @@ -22,4 +43,19 @@ fn main() { assert_eq!(s.by_ref(), 3); assert_eq!(s.by_mut_ref(), 2); assert_eq!(s.by_value(), 1); + + let mut ssss = S(F); + assert_eq!(S::static_ref(&ssss), 3); + assert_eq!(S::static_mut_ref(&mut ssss), 2); + assert_eq!(S::static_value(ssss), 1); + + let mut s = S1(Default::default()); + assert_eq!(s.by_ref(), 3); + assert_eq!(s.by_mut_ref(), 2); + assert_eq!(s.by_value(), 1); + + let mut ssss = S1(Default::default()); + assert_eq!(S1::static_ref(&ssss), 3); + assert_eq!(S1::static_mut_ref(&mut ssss), 2); + assert_eq!(S1::static_value(ssss), 1); } diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index 8965a1a060786..4ae82bc6305a7 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -52,13 +52,21 @@ error[E0308]: mismatched types --> $DIR/target-expr.rs:17:32 | LL | reuse Trait::static_method { - | ________________________________^ + | __________________-------------_^ + | | | + | | arguments to this function are incorrect LL | | LL | | LL | | let _ = T::Default(); LL | | LL | | } | |_____^ expected `i32`, found `()` + | +note: associated function defined here + --> $DIR/target-expr.rs:4:8 + | +LL | fn static_method(x: i32) -> i32 { x } + | ^^^^^^^^^^^^^ ------ error: aborting due to 6 previous errors From b300820ad82ffbf772b2d6e826ebb85904d32382 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Thu, 14 May 2026 09:19:00 +0300 Subject: [PATCH 02/14] Cleanups --- compiler/rustc_hir_typeck/src/callee.rs | 2 +- tests/ui/delegation/self-coercion-errors.rs | 1 - .../ui/delegation/self-coercion-errors.stderr | 400 +++++++++--------- 3 files changed, 201 insertions(+), 202 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index f28b2ad8dea8f..19bd1fd695ed2 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -637,7 +637,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); }; - // Check that we are inside delegation and processing its call. Firstly we check that + // Check that we are inside delegation and processing its call. First, we check that // the parent of call expr. is delegation and then make sure that it is compiler-generated // by comparing their spans (otherwise we will encounter errors in nested delegations, // see tests\ui\delegation\impl-reuse-pass.rs:237). diff --git a/tests/ui/delegation/self-coercion-errors.rs b/tests/ui/delegation/self-coercion-errors.rs index 5a8cf886cd05a..7dc5a0b1de304 100644 --- a/tests/ui/delegation/self-coercion-errors.rs +++ b/tests/ui/delegation/self-coercion-errors.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] use std::sync::Arc; use std::pin::Pin; diff --git a/tests/ui/delegation/self-coercion-errors.stderr b/tests/ui/delegation/self-coercion-errors.stderr index 993dd55314398..c871eddd1ac9d 100644 --- a/tests/ui/delegation/self-coercion-errors.stderr +++ b/tests/ui/delegation/self-coercion-errors.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `fn() -> F {foo}: Trait` is not satisfied - --> $DIR/self-coercion-errors.rs:41:49 + --> $DIR/self-coercion-errors.rs:40:49 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | ___________________--------______________________^ @@ -17,7 +17,7 @@ LL | }() | ++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:41:49 + --> $DIR/self-coercion-errors.rs:40:49 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | _____________________________----------__________^ @@ -31,7 +31,7 @@ LL | | } = note: expected mutable reference `&mut _` found fn item `fn() -> F {foo}` note: method defined here - --> $DIR/self-coercion-errors.rs:10:8 + --> $DIR/self-coercion-errors.rs:9:8 | LL | fn by_mut_ref(&mut self) -> i32 { 2 } | ^^^^^^^^^^ --------- @@ -41,7 +41,7 @@ LL | &mut foo | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:41:49 + --> $DIR/self-coercion-errors.rs:40:49 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | _________________________________________------__^ @@ -55,7 +55,7 @@ LL | | } = note: expected reference `&_` found fn item `fn() -> F {foo}` note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:10:8 | LL | fn by_ref(&self) -> i32 { 3 } | ^^^^^^ ----- @@ -65,7 +65,7 @@ LL | &foo | + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Box<_>`, found `&mut F` @@ -76,7 +76,7 @@ LL | reuse Trait::* { &mut self.0 } found mutable reference `&mut F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -86,7 +86,7 @@ LL | reuse Trait::* { Box::new(&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Arc<_>`, found `&mut F` @@ -96,7 +96,7 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Arc<_>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -106,7 +106,7 @@ LL | reuse Trait::* { (&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Rc<_>`, found `&mut F` @@ -116,7 +116,7 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Rc<_>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -126,7 +126,7 @@ LL | reuse Trait::* { (&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` @@ -136,7 +136,7 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -146,7 +146,7 @@ LL | reuse Trait::* { Box::pin(&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` @@ -156,13 +156,13 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` @@ -172,13 +172,13 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Box>`, found `&mut F` @@ -188,13 +188,13 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Box>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Box<_>`, found `&F` @@ -205,7 +205,7 @@ LL | reuse Trait::* { &self.0 } found reference `&F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -215,7 +215,7 @@ LL | reuse Trait::* { Box::new(&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Arc<_>`, found `&F` @@ -225,7 +225,7 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Arc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -235,7 +235,7 @@ LL | reuse Trait::* { (&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Rc<_>`, found `&F` @@ -245,7 +245,7 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Rc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -255,7 +255,7 @@ LL | reuse Trait::* { (&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Pin>`, found `&F` @@ -265,7 +265,7 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -275,7 +275,7 @@ LL | reuse Trait::* { Box::pin(&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Pin>`, found `&F` @@ -285,13 +285,13 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Pin>`, found `&F` @@ -301,13 +301,13 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Box>`, found `&F` @@ -317,13 +317,13 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Box>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Box<_>`, found `&&&&F` @@ -334,7 +334,7 @@ LL | reuse Trait::* { &&&&self.0 } found reference `&&&&F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -344,7 +344,7 @@ LL | reuse Trait::* { Box::new(&&&&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Arc<_>`, found `&&&&F` @@ -354,7 +354,7 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Arc<_>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -364,7 +364,7 @@ LL | reuse Trait::* { (&&&&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Rc<_>`, found `&&&&F` @@ -374,7 +374,7 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Rc<_>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -384,7 +384,7 @@ LL | reuse Trait::* { (&&&&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` @@ -394,7 +394,7 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Pin>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -404,7 +404,7 @@ LL | reuse Trait::* { Box::pin(&&&&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` @@ -414,13 +414,13 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Pin>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` @@ -430,13 +430,13 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Pin>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Box>`, found `&&&&F` @@ -446,13 +446,13 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Box>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Box<_>`, found `&F` @@ -462,7 +462,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Box<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -473,7 +473,7 @@ LL + reuse Trait::* { self.0 } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Arc<_>`, found `&F` @@ -483,7 +483,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Arc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -493,7 +493,7 @@ LL | reuse Trait::* { self.0.as_ref().into() } | +++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Rc<_>`, found `&F` @@ -503,7 +503,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Rc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -513,7 +513,7 @@ LL | reuse Trait::* { self.0.as_ref().into() } | +++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` @@ -523,7 +523,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -533,7 +533,7 @@ LL | reuse Trait::* { Box::pin(self.0.as_ref()) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` @@ -543,13 +543,13 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` @@ -559,13 +559,13 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Box>`, found `&F` @@ -575,13 +575,13 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Box>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Box<_>`, found `&mut &mut &mut F` @@ -592,7 +592,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } found mutable reference `&mut &mut &mut F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -602,7 +602,7 @@ LL | reuse Trait::* { Box::new(&mut &mut &mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Arc<_>`, found `&mut &mut &mut F` @@ -612,7 +612,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Arc<_>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -622,7 +622,7 @@ LL | reuse Trait::* { (&mut &mut &mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Rc<_>`, found `&mut &mut &mut F` @@ -632,7 +632,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Rc<_>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -642,7 +642,7 @@ LL | reuse Trait::* { (&mut &mut &mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` @@ -652,7 +652,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -662,7 +662,7 @@ LL | reuse Trait::* { Box::pin(&mut &mut &mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` @@ -672,13 +672,13 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` @@ -688,13 +688,13 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Box>`, found `&mut &mut &mut F` @@ -704,13 +704,13 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Box>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Box<_>`, found `&&mut F` @@ -721,7 +721,7 @@ LL | reuse Trait::* { &&mut self.0 } found reference `&&mut F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -731,7 +731,7 @@ LL | reuse Trait::* { Box::new(&&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Arc<_>`, found `&&mut F` @@ -741,7 +741,7 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Arc<_>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -751,7 +751,7 @@ LL | reuse Trait::* { (&&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Rc<_>`, found `&&mut F` @@ -761,7 +761,7 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Rc<_>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -771,7 +771,7 @@ LL | reuse Trait::* { (&&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` @@ -781,7 +781,7 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Pin>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -791,7 +791,7 @@ LL | reuse Trait::* { Box::pin(&&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` @@ -801,13 +801,13 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Pin>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` @@ -817,13 +817,13 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Pin>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Box>`, found `&&mut F` @@ -833,13 +833,13 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Box>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:176:22 + --> $DIR/self-coercion-errors.rs:175:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `Box` @@ -849,7 +849,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -860,7 +860,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:176:22 + --> $DIR/self-coercion-errors.rs:175:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `Box` @@ -870,7 +870,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -881,7 +881,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:176:22 + --> $DIR/self-coercion-errors.rs:175:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box` @@ -891,7 +891,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -902,7 +902,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:176:22 + --> $DIR/self-coercion-errors.rs:175:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box` @@ -912,7 +912,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -923,7 +923,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:176:22 + --> $DIR/self-coercion-errors.rs:175:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box` @@ -933,7 +933,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -944,7 +944,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:176:22 + --> $DIR/self-coercion-errors.rs:175:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `Box` @@ -959,7 +959,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:173:8 + ::: $DIR/self-coercion-errors.rs:172:8 | LL | struct X6(Box); | -- ------ this is the field that was accessed @@ -968,7 +968,7 @@ LL | struct X6(Box); = note: expected struct `Box>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -979,7 +979,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `Box>>` @@ -989,7 +989,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -999,7 +999,7 @@ LL | reuse Trait::* { *self.0 } | + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `Box>>` @@ -1009,7 +1009,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -1020,7 +1020,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box>>` @@ -1030,7 +1030,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -1041,7 +1041,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box>>` @@ -1051,7 +1051,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -1062,7 +1062,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box>>` @@ -1072,7 +1072,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -1083,7 +1083,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `Box>>` @@ -1098,7 +1098,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:185:8 + ::: $DIR/self-coercion-errors.rs:184:8 | LL | struct X7(Box>>); | -- ---------------- this is the field that was accessed @@ -1107,7 +1107,7 @@ LL | struct X7(Box>>); = note: expected struct `Box>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -1118,7 +1118,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box<_>`, found `Pin>` @@ -1133,7 +1133,7 @@ note: there is a field `0` on `Box` with type `std::ptr::Unique` but it | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:200:8 + ::: $DIR/self-coercion-errors.rs:199:8 | LL | struct X8(Pin>); | -- ----------- this is the field that was accessed @@ -1142,7 +1142,7 @@ LL | struct X8(Pin>); = note: expected struct `Box<_>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -1153,7 +1153,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `Pin>` @@ -1163,7 +1163,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -1174,7 +1174,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `Pin>` @@ -1184,7 +1184,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -1195,7 +1195,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Pin>` @@ -1205,7 +1205,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -1216,7 +1216,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Pin>` @@ -1226,7 +1226,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -1237,7 +1237,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `Pin>` @@ -1252,7 +1252,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:200:8 + ::: $DIR/self-coercion-errors.rs:199:8 | LL | struct X8(Pin>); | -- ----------- this is the field that was accessed @@ -1261,7 +1261,7 @@ LL | struct X8(Pin>); = note: expected struct `Box>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -1272,7 +1272,7 @@ LL + reuse Trait::* { self } | error[E0277]: the trait bound `OtherStruct: Trait` is not satisfied - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ unsatisfied trait bound @@ -1280,18 +1280,18 @@ LL | reuse Trait::* { self.0 } | required by a bound introduced by this call | help: the trait `Trait` is not implemented for `OtherStruct` - --> $DIR/self-coercion-errors.rs:215:1 + --> $DIR/self-coercion-errors.rs:214:1 | LL | struct OtherStruct; | ^^^^^^^^^^^^^^^^^^ help: the trait `Trait` is implemented for `F` - --> $DIR/self-coercion-errors.rs:22:1 + --> $DIR/self-coercion-errors.rs:21:1 | LL | impl Trait for F {} | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `&mut _`, found `OtherStruct` @@ -1301,7 +1301,7 @@ LL | reuse Trait::* { self.0 } = note: expected mutable reference `&mut _` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:10:8 + --> $DIR/self-coercion-errors.rs:9:8 | LL | fn by_mut_ref(&mut self) -> i32 { 2 } | ^^^^^^^^^^ --------- @@ -1311,7 +1311,7 @@ LL | reuse Trait::* { &mut self.0 } | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `&_`, found `OtherStruct` @@ -1321,7 +1321,7 @@ LL | reuse Trait::* { self.0 } = note: expected reference `&_` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:10:8 | LL | fn by_ref(&self) -> i32 { 3 } | ^^^^^^ ----- @@ -1331,7 +1331,7 @@ LL | reuse Trait::* { &self.0 } | + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box<_>`, found `OtherStruct` @@ -1346,7 +1346,7 @@ note: there is a field `0` on `Box` with type `std::ptr::Unique` but it | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:216:8 + ::: $DIR/self-coercion-errors.rs:215:8 | LL | struct X9(OtherStruct); | -- ----------- this is the field that was accessed @@ -1355,7 +1355,7 @@ LL | struct X9(OtherStruct); = note: expected struct `Box<_>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:11:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -1366,7 +1366,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `OtherStruct` @@ -1376,7 +1376,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -1387,7 +1387,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `OtherStruct` @@ -1397,7 +1397,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -1408,7 +1408,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `OtherStruct` @@ -1418,7 +1418,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -1429,7 +1429,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `OtherStruct` @@ -1439,7 +1439,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -1450,7 +1450,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `OtherStruct` @@ -1460,7 +1460,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -1471,7 +1471,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:219:22 + --> $DIR/self-coercion-errors.rs:218:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `OtherStruct` @@ -1486,7 +1486,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:216:8 + ::: $DIR/self-coercion-errors.rs:215:8 | LL | struct X9(OtherStruct); | -- ----------- this is the field that was accessed @@ -1495,7 +1495,7 @@ LL | struct X9(OtherStruct); = note: expected struct `Box>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:18:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -1506,7 +1506,7 @@ LL + reuse Trait::* { self } | error[E0507]: cannot move out of a mutable reference - --> $DIR/self-coercion-errors.rs:71:9 + --> $DIR/self-coercion-errors.rs:70:9 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | -------- value moved due to this method call @@ -1515,12 +1515,12 @@ LL | &mut x | ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1529,7 +1529,7 @@ LL | &mut x | ------ you could clone this value error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/self-coercion-errors.rs:71:9 + --> $DIR/self-coercion-errors.rs:70:9 | LL | &mut x | ^^^^^^ cannot borrow as mutable @@ -1540,7 +1540,7 @@ LL | let mut x = foo(); | +++ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/self-coercion-errors.rs:71:9 + --> $DIR/self-coercion-errors.rs:70:9 | LL | &mut x | ^^^^^^ cannot borrow as mutable @@ -1552,7 +1552,7 @@ LL | let mut x = foo(); | +++ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/self-coercion-errors.rs:71:9 + --> $DIR/self-coercion-errors.rs:70:9 | LL | &mut x | ^^^^^^ cannot borrow as mutable @@ -1564,7 +1564,7 @@ LL | let mut x = foo(); | +++ error[E0507]: cannot move out of a mutable reference - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1572,12 +1572,12 @@ LL | reuse Trait::* { &mut self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1586,7 +1586,7 @@ LL | reuse Trait::* { &mut self.0 } | ----------- you could clone this value error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | ^^^^^^^^^^^ cannot borrow as mutable @@ -1597,7 +1597,7 @@ LL | reuse Trait::mut * { &mut self.0 } | +++ error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference - --> $DIR/self-coercion-errors.rs:82:22 + --> $DIR/self-coercion-errors.rs:81:22 | LL | reuse Trait::* { &mut self.0 } | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable @@ -1609,7 +1609,7 @@ LL + reuse Trait::&mut self { &mut self.0 } | error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1617,12 +1617,12 @@ LL | reuse Trait::* { &self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1631,13 +1631,13 @@ LL | reuse Trait::* { &self.0 } | ------- you could clone this value error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:98:22 + --> $DIR/self-coercion-errors.rs:97:22 | LL | reuse Trait::* { &self.0 } | ^^^^^^^ cannot borrow as mutable error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1645,12 +1645,12 @@ LL | reuse Trait::* { &&&&self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1659,13 +1659,13 @@ LL | reuse Trait::* { &&&&self.0 } | ---------- you could clone this value error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:113:22 + --> $DIR/self-coercion-errors.rs:112:22 | LL | reuse Trait::* { &&&&self.0 } | ^^^^^^^^^^ cannot borrow as mutable error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1673,12 +1673,12 @@ LL | reuse Trait::* { self.0.as_ref() } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1687,13 +1687,13 @@ LL | reuse Trait::* { self.0.as_ref() } | --------------- you could clone this value error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:128:22 + --> $DIR/self-coercion-errors.rs:127:22 | LL | reuse Trait::* { self.0.as_ref() } | ^^^^^^^^^^^^^^^ cannot borrow as mutable error[E0507]: cannot move out of a mutable reference - --> $DIR/self-coercion-errors.rs:143:22 + --> $DIR/self-coercion-errors.rs:142:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1701,12 +1701,12 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1715,7 +1715,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } | --------------------- you could clone this value error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable - --> $DIR/self-coercion-errors.rs:143:32 + --> $DIR/self-coercion-errors.rs:142:32 | LL | reuse Trait::* { &mut &mut &mut self.0 } | ^^^^^^^^^^^ cannot borrow as mutable @@ -1726,7 +1726,7 @@ LL | reuse Trait::mut * { &mut &mut &mut self.0 } | +++ error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference - --> $DIR/self-coercion-errors.rs:143:32 + --> $DIR/self-coercion-errors.rs:142:32 | LL | reuse Trait::* { &mut &mut &mut self.0 } | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable @@ -1738,7 +1738,7 @@ LL + reuse Trait::&mut self { &mut &mut &mut self.0 } | error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1746,12 +1746,12 @@ LL | reuse Trait::* { &&mut self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1760,7 +1760,7 @@ LL | reuse Trait::* { &&mut self.0 } | ------------ you could clone this value error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable - --> $DIR/self-coercion-errors.rs:159:23 + --> $DIR/self-coercion-errors.rs:158:23 | LL | reuse Trait::* { &&mut self.0 } | ^^^^^^^^^^^ cannot borrow as mutable @@ -1771,13 +1771,13 @@ LL | reuse Trait::mut * { &&mut self.0 } | +++ error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:159:22 + --> $DIR/self-coercion-errors.rs:158:22 | LL | reuse Trait::* { &&mut self.0 } | ^^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference - --> $DIR/self-coercion-errors.rs:159:23 + --> $DIR/self-coercion-errors.rs:158:23 | LL | reuse Trait::* { &&mut self.0 } | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable @@ -1789,7 +1789,7 @@ LL + reuse Trait::&mut self { &&mut self.0 } | error[E0507]: cannot move out of an `Arc` - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1797,12 +1797,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1811,7 +1811,7 @@ LL | reuse Trait::* { self.0 } | ------ you could clone this value error[E0596]: cannot borrow data in an `Arc` as mutable - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | ^^^^^^ cannot borrow as mutable @@ -1819,7 +1819,7 @@ LL | reuse Trait::* { self.0 } = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Arc>` error[E0507]: cannot move out of an `Arc` - --> $DIR/self-coercion-errors.rs:188:22 + --> $DIR/self-coercion-errors.rs:187:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `Box`, which does not implement the `Copy` trait @@ -1827,12 +1827,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::r#box` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:12:14 + --> $DIR/self-coercion-errors.rs:11:14 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1850,7 +1850,7 @@ LL | struct F; | error[E0507]: cannot move out of dereference of `Pin>` - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1858,12 +1858,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:9:17 + --> $DIR/self-coercion-errors.rs:8:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1872,7 +1872,7 @@ LL | reuse Trait::* { self.0 } | ------ you could clone this value error[E0596]: cannot borrow data in dereference of `Pin>` as mutable - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | ^^^^^^ cannot borrow as mutable @@ -1880,7 +1880,7 @@ LL | reuse Trait::* { self.0 } = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Pin>` error[E0507]: cannot move out of dereference of `Pin>` - --> $DIR/self-coercion-errors.rs:203:22 + --> $DIR/self-coercion-errors.rs:202:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `Pin>`, which does not implement the `Copy` trait @@ -1888,12 +1888,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::pin_box` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:15:16 + --> $DIR/self-coercion-errors.rs:14:16 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:20:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type From 6db9ae281fa1f3d8659f71cbc76fceb90de38671 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 15 May 2026 12:32:20 +0300 Subject: [PATCH 03/14] Always call `into_hir_generics` during propagation, fix `all_params` and `all_predicates` --- compiler/rustc_ast_lowering/src/delegation.rs | 8 ++-- .../src/delegation/generics.rs | 45 +++++-------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 7c8a0ffda4f6a..827ed8f7666ad 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -166,8 +166,8 @@ impl<'hir> LoweringContext<'_, 'hir> { let generics = self.arena.alloc(hir::Generics { has_where_clause_predicates: false, - params: self.arena.alloc_from_iter(generics.all_params(span, self)), - predicates: self.arena.alloc_from_iter(generics.all_predicates(span, self)), + params: self.arena.alloc_from_iter(generics.all_params()), + predicates: self.arena.alloc_from_iter(generics.all_predicates()), span, where_clause_span: span, }); @@ -540,8 +540,10 @@ impl<'hir> LoweringContext<'_, 'hir> { ) -> hir::PathSegment<'hir> { let details = result.generics.args_propagation_details(); + // Always uplift generic params, as if they are not empty then they + // should be generated in delegation. + let generics = result.generics.into_hir_generics(self, span); let segment = if details.should_propagate { - let generics = result.generics.into_hir_generics(self, span); let args = generics.into_generic_args(self, span); // Needed for better error messages (`trait-impl-wrong-args-count.rs` test). diff --git a/compiler/rustc_ast_lowering/src/delegation/generics.rs b/compiler/rustc_ast_lowering/src/delegation/generics.rs index c2c3bd740e3cf..f8e3528750035 100644 --- a/compiler/rustc_ast_lowering/src/delegation/generics.rs +++ b/compiler/rustc_ast_lowering/src/delegation/generics.rs @@ -171,22 +171,9 @@ impl<'hir> GenericsGenerationResult<'hir> { } impl<'hir> GenericsGenerationResults<'hir> { - pub(super) fn all_params( - &mut self, - span: Span, - ctx: &mut LoweringContext<'_, 'hir>, - ) -> impl Iterator> { - // Now we always call `into_hir_generics` both on child and parent, - // however in future we would not do that, when scenarios like - // method call will be supported (if HIR generics were not obtained - // then it means that we did not propagated them, thus we do not need - // to generate params). - let mut create_params = |result: &mut GenericsGenerationResult<'hir>| { - result.generics.into_hir_generics(ctx, span).hir_generics_or_empty().params - }; - - let parent = create_params(&mut self.parent); - let child = create_params(&mut self.child); + pub(super) fn all_params(&self) -> impl Iterator> { + let parent = self.parent.generics.hir_generics_or_empty().params; + let child = self.child.generics.hir_generics_or_empty().params; // Order generics, first we have parent and child lifetimes, // then parent and child types and consts. @@ -205,24 +192,14 @@ impl<'hir> GenericsGenerationResults<'hir> { /// and `generate_lifetime_predicate` functions) we need to add them to delegation generics. /// Those predicates will not affect resulting predicate inheritance and folding /// in `rustc_hir_analysis`, as we inherit all predicates from delegation signature. - pub(super) fn all_predicates( - &mut self, - span: Span, - ctx: &mut LoweringContext<'_, 'hir>, - ) -> impl Iterator> { - // Now we always call `into_hir_generics` both on child and parent, - // however in future we would not do that, when scenarios like - // method call will be supported (if HIR generics were not obtained - // then it means that we did not propagated them, thus we do not need - // to generate predicates). - let mut create_predicates = |result: &mut GenericsGenerationResult<'hir>| { - result.generics.into_hir_generics(ctx, span).hir_generics_or_empty().predicates - }; - - let parent = create_predicates(&mut self.parent); - let child = create_predicates(&mut self.child); - - parent.into_iter().chain(child).copied() + pub(super) fn all_predicates(&self) -> impl Iterator> { + self.parent + .generics + .hir_generics_or_empty() + .predicates + .into_iter() + .chain(self.child.generics.hir_generics_or_empty().predicates) + .copied() } } From f023fab28d382a9adc75831e3e7f418c18e25083 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 15 May 2026 13:18:41 +0300 Subject: [PATCH 04/14] Use HirId for call_expr check --- compiler/rustc_ast_lowering/src/delegation.rs | 25 +++++++++++++------ compiler/rustc_hir/src/hir.rs | 1 + compiler/rustc_hir_typeck/src/callee.rs | 12 ++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 827ed8f7666ad..6f39cf928174e 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -144,7 +144,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let mut generics = self.uplift_delegation_generics(delegation, sig_id, is_method); - let body_id = self.lower_delegation_body( + let (body_id, call_expr_id) = self.lower_delegation_body( delegation, is_method, param_count, @@ -159,6 +159,7 @@ impl<'hir> LoweringContext<'_, 'hir> { span, &generics, delegation.id, + call_expr_id, ); let sig = self.lower_delegation_sig(sig_id, decl, span); @@ -287,6 +288,7 @@ impl<'hir> LoweringContext<'_, 'hir> { span: Span, generics: &GenericsGenerationResults<'hir>, call_path_node_id: NodeId, + call_expr_id: HirId, ) -> &'hir hir::FnDecl<'hir> { // The last parameter in C variadic functions is skipped in the signature, // like during regular lowering. @@ -305,6 +307,7 @@ impl<'hir> LoweringContext<'_, 'hir> { kind: hir::TyKind::InferDelegation(hir::InferDelegation::Sig( sig_id, hir::InferDelegationSig::Output(self.arena.alloc(hir::DelegationInfo { + call_expr_id, call_path_res: self.get_resolution_id(call_path_node_id), child_args_segment_id: generics.child.args_segment_id, parent_args_segment_id: generics.parent.args_segment_id, @@ -408,10 +411,11 @@ impl<'hir> LoweringContext<'_, 'hir> { param_count: usize, generics: &mut GenericsGenerationResults<'hir>, span: Span, - ) -> BodyId { + ) -> (BodyId, HirId) { let block = delegation.body.as_deref(); + let mut call_expr_id = HirId::INVALID; - self.lower_body(|this| { + let block_id = self.lower_body(|this| { let mut parameters: Vec> = Vec::with_capacity(param_count); let mut args: Vec> = Vec::with_capacity(param_count); @@ -448,10 +452,17 @@ impl<'hir> LoweringContext<'_, 'hir> { args.push(this.lower_target_expr(&block)); } - let final_expr = this.finalize_body_lowering(delegation, args, generics, span); + let (final_expr, hir_id) = + this.finalize_body_lowering(delegation, args, generics, span); + + call_expr_id = hir_id; (this.arena.alloc_from_iter(parameters), final_expr) - }) + }); + + debug_assert_ne!(call_expr_id, HirId::INVALID); + + (block_id, call_expr_id) } // FIXME(fn_delegation): Alternatives for target expression lowering: @@ -473,7 +484,7 @@ impl<'hir> LoweringContext<'_, 'hir> { args: Vec>, generics: &mut GenericsGenerationResults<'hir>, span: Span, - ) -> hir::Expr<'hir> { + ) -> (hir::Expr<'hir>, HirId) { let path = self.lower_qpath( delegation.id, &delegation.qself, @@ -529,7 +540,7 @@ impl<'hir> LoweringContext<'_, 'hir> { targeted_by_break: false, }); - self.mk_expr(hir::ExprKind::Block(block, None), span) + (self.mk_expr(hir::ExprKind::Block(block, None), span), call.hir_id) } fn process_segment( diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 07ad75f555310..59d1b4b5576ee 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3866,6 +3866,7 @@ pub enum OpaqueTyOrigin { #[derive(Debug, Clone, Copy, PartialEq, Eq, StableHash)] pub struct DelegationInfo { + pub call_expr_id: HirId, pub call_path_res: Option, pub parent_args_segment_id: Option, pub child_args_segment_id: Option, diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 19bd1fd695ed2..568c62034272b 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -639,14 +639,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check that we are inside delegation and processing its call. First, we check that // the parent of call expr. is delegation and then make sure that it is compiler-generated - // by comparing their spans (otherwise we will encounter errors in nested delegations, + // by comparing their hir ids (otherwise we will encounter errors in nested delegations, // see tests\ui\delegation\impl-reuse-pass.rs:237). let parent_def = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id; - if !is_delegation(self.tcx, parent_def) || self.tcx.def_span(parent_def) != call_expr.span { + if !is_delegation(self.tcx, parent_def) { return do_check(); }; - let Some(path_res_id) = get_delegation_info(self.tcx, parent_def).call_path_res else { + let info = get_delegation_info(self.tcx, parent_def); + + if call_expr.hir_id != info.call_expr_id { + return do_check(); + }; + + let Some(path_res_id) = info.call_path_res else { return do_check(); }; From cd9a24f57654712f3ac562f2ae9acded1505ab56 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 15 May 2026 15:07:08 +0300 Subject: [PATCH 05/14] Use autoderefs only for methods --- compiler/rustc_hir_typeck/src/callee.rs | 4 +- .../delegation/self-coercion-static-free.rs | 48 ++++++++++ .../self-coercion-static-free.stderr | 87 +++++++++++++++++++ tests/ui/delegation/self-coercion.rs | 24 ----- tests/ui/delegation/target-expr.stderr | 10 +-- 5 files changed, 138 insertions(+), 35 deletions(-) create mode 100644 tests/ui/delegation/self-coercion-static-free.rs create mode 100644 tests/ui/delegation/self-coercion-static-free.stderr diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 568c62034272b..bdf264ce4ffbd 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -657,12 +657,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // Check that delegation has first param, first provided arg and that the call path - // resolves to a trait function, we do not support free functions yet. - // FIXME(fn_delegation): support adjustments for free functions + // resolves to a trait method. if fn_sig.inputs().is_empty() || arg_exprs.is_empty() || !matches!(self.tcx.def_kind(path_res_id), DefKind::AssocFn) || !matches!(self.tcx.def_kind(self.tcx.parent(path_res_id)), DefKind::Trait) + || !self.tcx.associated_item(path_res_id).is_method() { return do_check(); }; diff --git a/tests/ui/delegation/self-coercion-static-free.rs b/tests/ui/delegation/self-coercion-static-free.rs new file mode 100644 index 0000000000000..bc9f6d91c5e8d --- /dev/null +++ b/tests/ui/delegation/self-coercion-static-free.rs @@ -0,0 +1,48 @@ +#![feature(fn_delegation)] + +pub trait Trait: Sized { + fn static_self() -> F { F } + + fn static_value(_: Self) -> i32 { 1 } + fn static_mut_ref(_: &mut Self) -> i32 { 2 } + fn static_ref(_: &Self) -> i32 { 3 } +} + +#[derive(Default)] +struct F; +impl Trait for F {} + +struct S(F); + +impl Trait for S { + reuse ::{static_value, static_mut_ref, static_ref} { + let _ = self; + S::static_self() + //~^ ERROR: mismatched types + //~| ERROR: mismatched types + } +} + +struct S1(Box>>>>>); + +impl Trait for S1 { + reuse ::{static_value, static_mut_ref, static_ref} { + let _ = self; + S1::static_self() + //~^ ERROR: mismatched types + //~| ERROR: mismatched types + } +} + +mod to_reuse { + use super::Trait; + pub fn value(_: impl Trait) -> i32 { 1 } + pub fn mut_ref(_: &mut impl Trait) -> i32 { 2 } + pub fn r#ref(_: &impl Trait) -> i32 { 3 } +} + +reuse to_reuse::{value, mut_ref, r#ref} { F } +//~^ ERROR: mismatched types +//~| ERROR: mismatched types + +fn main() {} diff --git a/tests/ui/delegation/self-coercion-static-free.stderr b/tests/ui/delegation/self-coercion-static-free.stderr new file mode 100644 index 0000000000000..276cd2d874e60 --- /dev/null +++ b/tests/ui/delegation/self-coercion-static-free.stderr @@ -0,0 +1,87 @@ +error[E0308]: mismatched types + --> $DIR/self-coercion-static-free.rs:20:9 + | +LL | S::static_self() + | ^^^^^^^^^^^^^^^^ expected `&mut F`, found `F` + | +help: consider mutably borrowing here + | +LL | &mut S::static_self() + | ++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-static-free.rs:20:9 + | +LL | S::static_self() + | ^^^^^^^^^^^^^^^^ expected `&F`, found `F` + | +help: consider borrowing here + | +LL | &S::static_self() + | + + +error[E0308]: mismatched types + --> $DIR/self-coercion-static-free.rs:31:9 + | +LL | S1::static_self() + | ^^^^^^^^^^^^^^^^^ expected `&mut F`, found `F` + | +help: consider mutably borrowing here + | +LL | &mut S1::static_self() + | ++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-static-free.rs:31:9 + | +LL | S1::static_self() + | ^^^^^^^^^^^^^^^^^ expected `&F`, found `F` + | +help: consider borrowing here + | +LL | &S1::static_self() + | + + +error[E0308]: mismatched types + --> $DIR/self-coercion-static-free.rs:44:43 + | +LL | reuse to_reuse::{value, mut_ref, r#ref} { F } + | ------- ^ expected `&mut _`, found `F` + | | + | arguments to this function are incorrect + | + = note: expected mutable reference `&mut _` + found struct `F` +note: function defined here + --> $DIR/self-coercion-static-free.rs:40:12 + | +LL | pub fn mut_ref(_: &mut impl Trait) -> i32 { 2 } + | ^^^^^^^ ------------------ +help: consider mutably borrowing here + | +LL | reuse to_reuse::{value, mut_ref, r#ref} { &mut F } + | ++++ + +error[E0308]: mismatched types + --> $DIR/self-coercion-static-free.rs:44:43 + | +LL | reuse to_reuse::{value, mut_ref, r#ref} { F } + | ----- ^ expected `&_`, found `F` + | | + | arguments to this function are incorrect + | + = note: expected reference `&_` + found struct `F` +note: function defined here + --> $DIR/self-coercion-static-free.rs:41:12 + | +LL | pub fn r#ref(_: &impl Trait) -> i32 { 3 } + | ^^^^^ -------------- +help: consider borrowing here + | +LL | reuse to_reuse::{value, mut_ref, r#ref} { &F } + | + + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/delegation/self-coercion.rs b/tests/ui/delegation/self-coercion.rs index b1d4d8a810c44..21b2b0cd2f56b 100644 --- a/tests/ui/delegation/self-coercion.rs +++ b/tests/ui/delegation/self-coercion.rs @@ -3,15 +3,9 @@ #![feature(fn_delegation)] trait Trait: Sized { - fn static_self() -> F { F } - fn by_value(self) -> i32 { 1 } fn by_mut_ref(&mut self) -> i32 { 2 } fn by_ref(&self) -> i32 { 3 } - - fn static_value(_: Self) -> i32 { 1 } - fn static_mut_ref(_: &mut Self) -> i32 { 2 } - fn static_ref(_: &Self) -> i32 { 3 } } #[derive(Default)] @@ -22,20 +16,12 @@ struct S(F); impl Trait for S { reuse Trait::{by_value, by_mut_ref, by_ref} { self.0 } - reuse ::{static_value, static_mut_ref, static_ref} { - let _ = self; - S::static_self() - } } struct S1(Box>>>>>); impl Trait for S1 { reuse Trait::{by_value, by_mut_ref, by_ref} { self.0 } - reuse ::{static_value, static_mut_ref, static_ref} { - let _ = self; - S1::static_self() - } } fn main() { @@ -44,18 +30,8 @@ fn main() { assert_eq!(s.by_mut_ref(), 2); assert_eq!(s.by_value(), 1); - let mut ssss = S(F); - assert_eq!(S::static_ref(&ssss), 3); - assert_eq!(S::static_mut_ref(&mut ssss), 2); - assert_eq!(S::static_value(ssss), 1); - let mut s = S1(Default::default()); assert_eq!(s.by_ref(), 3); assert_eq!(s.by_mut_ref(), 2); assert_eq!(s.by_value(), 1); - - let mut ssss = S1(Default::default()); - assert_eq!(S1::static_ref(&ssss), 3); - assert_eq!(S1::static_mut_ref(&mut ssss), 2); - assert_eq!(S1::static_value(ssss), 1); } diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index 4ae82bc6305a7..8965a1a060786 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -52,21 +52,13 @@ error[E0308]: mismatched types --> $DIR/target-expr.rs:17:32 | LL | reuse Trait::static_method { - | __________________-------------_^ - | | | - | | arguments to this function are incorrect + | ________________________________^ LL | | LL | | LL | | let _ = T::Default(); LL | | LL | | } | |_____^ expected `i32`, found `()` - | -note: associated function defined here - --> $DIR/target-expr.rs:4:8 - | -LL | fn static_method(x: i32) -> i32 { x } - | ^^^^^^^^^^^^^ ------ error: aborting due to 6 previous errors From c2779e9c2b31066ae6e2879c3e2ae564a61dfe25 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Mon, 18 May 2026 12:32:41 +0300 Subject: [PATCH 06/14] Remove `is_delegation` + minor cleanups --- compiler/rustc_ast_lowering/src/delegation.rs | 2 +- compiler/rustc_hir_analysis/src/delegation.rs | 18 ++++++++---------- compiler/rustc_hir_typeck/src/callee.rs | 8 ++------ .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 7 +++---- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 6f39cf928174e..8accaa8c3125c 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -551,7 +551,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ) -> hir::PathSegment<'hir> { let details = result.generics.args_propagation_details(); - // Always uplift generic params, as if they are not empty then they + // Always uplift generic params, because if they are not empty then they // should be generated in delegation. let generics = result.generics.into_hir_generics(self, span); let segment = if details.should_propagate { diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index 8c3a89c238540..f67181a4655b9 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -71,19 +71,17 @@ enum SelfPositionKind { None, } -pub fn is_delegation(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { - tcx.hir_node(tcx.local_def_id_to_hir_id(def_id)) +pub fn opt_get_delegation_info( + tcx: TyCtxt<'_>, + delegation_id: LocalDefId, +) -> Option<&DelegationInfo> { + tcx.hir_node(tcx.local_def_id_to_hir_id(delegation_id)) .fn_sig() - .is_some_and(|sig| sig.decl.opt_delegation_sig_id().is_some()) + .and_then(|sig| sig.decl.opt_delegation_info()) } -pub fn get_delegation_info(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> &DelegationInfo { - tcx.hir_node(tcx.local_def_id_to_hir_id(delegation_id)) - .fn_sig() - .expect("processing delegation") - .decl - .opt_delegation_info() - .expect("processing delegation") +fn get_delegation_info(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> &DelegationInfo { + opt_get_delegation_info(tcx, delegation_id).expect("processing delegation") } fn create_self_position_kind( diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index bdf264ce4ffbd..33a2a82ede37d 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -7,7 +7,7 @@ use rustc_hir::def::{self, CtorKind, DefKind, Namespace, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId, LangItem, find_attr}; use rustc_hir_analysis::autoderef::Autoderef; -use rustc_hir_analysis::delegation::{get_delegation_info, is_delegation}; +use rustc_hir_analysis::delegation::opt_get_delegation_info; use rustc_infer::infer::BoundRegionConversionTime; use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode}; use rustc_middle::ty::adjustment::{ @@ -642,11 +642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // by comparing their hir ids (otherwise we will encounter errors in nested delegations, // see tests\ui\delegation\impl-reuse-pass.rs:237). let parent_def = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id; - if !is_delegation(self.tcx, parent_def) { - return do_check(); - }; - - let info = get_delegation_info(self.tcx, parent_def); + let Some(info) = opt_get_delegation_info(self.tcx, parent_def) else { return do_check() }; if call_expr.hir_id != info.call_expr_id { return do_check(); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 523871aa27953..d62ba9cf804eb 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -13,7 +13,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::intravisit::Visitor; use rustc_hir::{Expr, ExprKind, FnRetTy, HirId, LangItem, Node, QPath, is_range_literal}; use rustc_hir_analysis::check::potentially_plural_count; -use rustc_hir_analysis::delegation::is_delegation; +use rustc_hir_analysis::delegation::opt_get_delegation_info; use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, ResolvedStructPath}; use rustc_index::IndexVec; use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk, TypeTrace}; @@ -341,9 +341,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If we are processing first arg of delegation then we could have adjusted it // in `execute_delegation_aware_arguments_check`. - let checked_ty = is_delegation(self.tcx, self.body_id) - .then(|| self.typeck_results.borrow().node_type_opt(provided_arg.hir_id)) - .flatten() + let checked_ty = opt_get_delegation_info(self.tcx, self.body_id) + .and_then(|_| self.typeck_results.borrow().node_type_opt(provided_arg.hir_id)) .unwrap_or_else(|| self.check_expr_with_expectation(provided_arg, expectation)); // 2. Coerce to the most detailed type that could be coerced From bfec29b7b6b5e1171660317d2f6245afbbc756c0 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 22 May 2026 15:20:53 +0300 Subject: [PATCH 07/14] Review: execute_delegation_aware_arguments_check -> check_argument_types_maybe_method_like --- compiler/rustc_hir_typeck/src/callee.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 33a2a82ede37d..da657e23a8de9 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let fn_sig = self.normalize(call_expr.span, Unnormalized::new_wip(fn_sig)); - self.execute_delegation_aware_arguments_check( + self.check_argument_types_maybe_method_like( &fn_sig, call_expr, arg_exprs, expected, def_id, ); @@ -615,7 +615,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn_sig.output() } - fn execute_delegation_aware_arguments_check( + fn check_argument_types_maybe_method_like( &self, fn_sig: &FnSig<'tcx>, call_expr: &'tcx hir::Expr<'tcx>, From 301b1cc4d536f91c992b7a9f807af44726c3e1b1 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 22 May 2026 15:32:00 +0300 Subject: [PATCH 08/14] Review: comment + shorten check --- compiler/rustc_hir_typeck/src/callee.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index da657e23a8de9..e88c863240467 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -3,7 +3,7 @@ use std::iter; use rustc_abi::{CanonAbi, ExternAbi}; use rustc_ast::util::parser::ExprPrecedence; use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey, msg}; -use rustc_hir::def::{self, CtorKind, DefKind, Namespace, Res}; +use rustc_hir::def::{self, CtorKind, Namespace, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId, LangItem, find_attr}; use rustc_hir_analysis::autoderef::Autoderef; @@ -615,6 +615,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn_sig.output() } + /// Performs arguments check with an additional routine of adjusting the first argument, + /// so it corresponds to the first parameter of the function. We reuse adjustments + /// that are obtained from `probe_for_name`, where the first argument pretends to be + /// a receiver like in a method call. At this point this routine is used for delegations, + /// as from this moment we always generate a call (earlier method calls were generated), + /// so we can both propagate parent generics and get benefits from adjustments from method call. fn check_argument_types_maybe_method_like( &self, fn_sig: &FnSig<'tcx>, @@ -652,13 +658,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return do_check(); }; - // Check that delegation has first param, first provided arg and that the call path - // resolves to a trait method. - if fn_sig.inputs().is_empty() - || arg_exprs.is_empty() - || !matches!(self.tcx.def_kind(path_res_id), DefKind::AssocFn) - || !matches!(self.tcx.def_kind(self.tcx.parent(path_res_id)), DefKind::Trait) - || !self.tcx.associated_item(path_res_id).is_method() + // Check that delegation has first provided arg and that the call path + // resolves to a trait method (inherent methods are not yet supported) + if arg_exprs.is_empty() + || !self.tcx.opt_associated_item(path_res_id).is_some_and(|i| i.is_method()) { return do_check(); }; From dc30c687e601d224f64871e42024f4204f110cf8 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 22 May 2026 15:40:22 +0300 Subject: [PATCH 09/14] Review: separate delegation checks into separate function --- compiler/rustc_hir_typeck/src/callee.rs | 52 +++++++++++++++---------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index e88c863240467..f28cbd2234a13 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -643,26 +643,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); }; - // Check that we are inside delegation and processing its call. First, we check that - // the parent of call expr. is delegation and then make sure that it is compiler-generated - // by comparing their hir ids (otherwise we will encounter errors in nested delegations, - // see tests\ui\delegation\impl-reuse-pass.rs:237). - let parent_def = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id; - let Some(info) = opt_get_delegation_info(self.tcx, parent_def) else { return do_check() }; - - if call_expr.hir_id != info.call_expr_id { - return do_check(); - }; - - let Some(path_res_id) = info.call_path_res else { - return do_check(); - }; - - // Check that delegation has first provided arg and that the call path - // resolves to a trait method (inherent methods are not yet supported) - if arg_exprs.is_empty() - || !self.tcx.opt_associated_item(path_res_id).is_some_and(|i| i.is_method()) - { + let Some(scope) = self.try_get_scope_for_call_adjustments(call_expr, arg_exprs) else { return do_check(); }; @@ -678,7 +659,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { IsSuggestion(false), first_arg_type, call_expr.hir_id, - ProbeScope::Single(path_res_id), + scope, ); let Ok(ref pick) = pick else { return do_check() }; @@ -708,6 +689,35 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { results.node_types_mut().insert(first_expr.hir_id, first_arg_type); } + fn try_get_scope_for_call_adjustments( + &self, + call_expr: &'tcx hir::Expr<'tcx>, + arg_exprs: &'tcx [hir::Expr<'tcx>], + ) -> Option { + // Check that we are inside delegation and processing its call. First, we check that + // the parent of call expr. is delegation and then make sure that it is compiler-generated + // by comparing their hir ids (otherwise we will encounter errors in nested delegations, + // see tests\ui\delegation\impl-reuse-pass.rs:237). + let parent_def = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id; + let Some(info) = opt_get_delegation_info(self.tcx, parent_def) else { return None }; + + if call_expr.hir_id != info.call_expr_id { + return None; + }; + + let Some(path_res_id) = info.call_path_res else { return None }; + + // Check that delegation has first provided arg and that the call path + // resolves to a trait method (inherent methods are not yet supported) + if arg_exprs.is_empty() + || !self.tcx.opt_associated_item(path_res_id).is_some_and(|i| i.is_method()) + { + return None; + } + + Some(ProbeScope::Single(path_res_id)) + } + /// Attempts to reinterpret `method(rcvr, args...)` as `rcvr.method(args...)` /// and suggesting the fix if the method probe is successful. fn suggest_call_as_method( From 2ed8f698711f26a6d848a7fcf991c628171878ea Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 22 May 2026 15:42:39 +0300 Subject: [PATCH 10/14] Review: update adjustments directly --- compiler/rustc_hir_typeck/src/callee.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index f28cbd2234a13..cd3804e82ebd5 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -680,10 +680,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Remove any added adjustments for `first_expr` during `do_check` and replace them with ours. let mut adjustments = results.adjustments_mut(); let adjustments = adjustments.entry(first_expr.hir_id).or_default(); - adjustments.clear(); let mut ctx = ConfirmContext::new(self, first_expr.span, first_expr, first_expr); - adjustments.extend(ctx.create_ty_adjustments_from_pick(first_arg_type, pick).1); + *adjustments = ctx.create_ty_adjustments_from_pick(first_arg_type, pick).1; // Restore original first provided arg type. results.node_types_mut().insert(first_expr.hir_id, first_arg_type); From 01c74b7b74c8417ab71598db509324f34175717c Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 22 May 2026 15:48:43 +0300 Subject: [PATCH 11/14] Review: add test comments --- tests/ui/delegation/self-coercion-errors.rs | 3 +++ tests/ui/delegation/self-coercion-static-free.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tests/ui/delegation/self-coercion-errors.rs b/tests/ui/delegation/self-coercion-errors.rs index 7dc5a0b1de304..20991867abf60 100644 --- a/tests/ui/delegation/self-coercion-errors.rs +++ b/tests/ui/delegation/self-coercion-errors.rs @@ -1,3 +1,6 @@ +// Tests above represent situations when type of the first argument can not be adjusted +// to the type of first parameter (i.e., Rc -> &mut T). + #![feature(fn_delegation)] use std::sync::Arc; diff --git a/tests/ui/delegation/self-coercion-static-free.rs b/tests/ui/delegation/self-coercion-static-free.rs index bc9f6d91c5e8d..f61d4247a1d94 100644 --- a/tests/ui/delegation/self-coercion-static-free.rs +++ b/tests/ui/delegation/self-coercion-static-free.rs @@ -1,3 +1,7 @@ +// Test that we do not adjust first argument type to first parameter type +// in delegations to static associated functions (we only do it for methods). +// Also test that we do not adjust first arg. type in delegations to free function. + #![feature(fn_delegation)] pub trait Trait: Sized { From 14041ff352e0a349586c1ade043a6d9fff6b8dcf Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Mon, 25 May 2026 08:06:40 +0300 Subject: [PATCH 12/14] Fix tests --- tests/ui/delegation/self-coercion-errors.rs | 2 +- .../ui/delegation/self-coercion-errors.stderr | 400 +++++++++--------- .../self-coercion-static-free.stderr | 16 +- 3 files changed, 209 insertions(+), 209 deletions(-) diff --git a/tests/ui/delegation/self-coercion-errors.rs b/tests/ui/delegation/self-coercion-errors.rs index 20991867abf60..6c8356bd7495b 100644 --- a/tests/ui/delegation/self-coercion-errors.rs +++ b/tests/ui/delegation/self-coercion-errors.rs @@ -1,4 +1,4 @@ -// Tests above represent situations when type of the first argument can not be adjusted +// Tests below represent situations when type of the first argument can not be adjusted // to the type of first parameter (i.e., Rc -> &mut T). #![feature(fn_delegation)] diff --git a/tests/ui/delegation/self-coercion-errors.stderr b/tests/ui/delegation/self-coercion-errors.stderr index c871eddd1ac9d..89308b15d2d84 100644 --- a/tests/ui/delegation/self-coercion-errors.stderr +++ b/tests/ui/delegation/self-coercion-errors.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `fn() -> F {foo}: Trait` is not satisfied - --> $DIR/self-coercion-errors.rs:40:49 + --> $DIR/self-coercion-errors.rs:43:49 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | ___________________--------______________________^ @@ -17,7 +17,7 @@ LL | }() | ++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:40:49 + --> $DIR/self-coercion-errors.rs:43:49 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | _____________________________----------__________^ @@ -31,7 +31,7 @@ LL | | } = note: expected mutable reference `&mut _` found fn item `fn() -> F {foo}` note: method defined here - --> $DIR/self-coercion-errors.rs:9:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn by_mut_ref(&mut self) -> i32 { 2 } | ^^^^^^^^^^ --------- @@ -41,7 +41,7 @@ LL | &mut foo | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:40:49 + --> $DIR/self-coercion-errors.rs:43:49 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | _________________________________________------__^ @@ -55,7 +55,7 @@ LL | | } = note: expected reference `&_` found fn item `fn() -> F {foo}` note: method defined here - --> $DIR/self-coercion-errors.rs:10:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn by_ref(&self) -> i32 { 3 } | ^^^^^^ ----- @@ -65,7 +65,7 @@ LL | &foo | + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Box<_>`, found `&mut F` @@ -76,7 +76,7 @@ LL | reuse Trait::* { &mut self.0 } found mutable reference `&mut F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -86,7 +86,7 @@ LL | reuse Trait::* { Box::new(&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Arc<_>`, found `&mut F` @@ -96,7 +96,7 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Arc<_>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -106,7 +106,7 @@ LL | reuse Trait::* { (&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Rc<_>`, found `&mut F` @@ -116,7 +116,7 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Rc<_>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -126,7 +126,7 @@ LL | reuse Trait::* { (&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` @@ -136,7 +136,7 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -146,7 +146,7 @@ LL | reuse Trait::* { Box::pin(&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` @@ -156,13 +156,13 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Pin>`, found `&mut F` @@ -172,13 +172,13 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ expected `Box>`, found `&mut F` @@ -188,13 +188,13 @@ LL | reuse Trait::* { &mut self.0 } = note: expected struct `Box>` found mutable reference `&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Box<_>`, found `&F` @@ -205,7 +205,7 @@ LL | reuse Trait::* { &self.0 } found reference `&F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -215,7 +215,7 @@ LL | reuse Trait::* { Box::new(&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Arc<_>`, found `&F` @@ -225,7 +225,7 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Arc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -235,7 +235,7 @@ LL | reuse Trait::* { (&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Rc<_>`, found `&F` @@ -245,7 +245,7 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Rc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -255,7 +255,7 @@ LL | reuse Trait::* { (&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Pin>`, found `&F` @@ -265,7 +265,7 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -275,7 +275,7 @@ LL | reuse Trait::* { Box::pin(&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Pin>`, found `&F` @@ -285,13 +285,13 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Pin>`, found `&F` @@ -301,13 +301,13 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ expected `Box>`, found `&F` @@ -317,13 +317,13 @@ LL | reuse Trait::* { &self.0 } = note: expected struct `Box>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Box<_>`, found `&&&&F` @@ -334,7 +334,7 @@ LL | reuse Trait::* { &&&&self.0 } found reference `&&&&F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -344,7 +344,7 @@ LL | reuse Trait::* { Box::new(&&&&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Arc<_>`, found `&&&&F` @@ -354,7 +354,7 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Arc<_>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -364,7 +364,7 @@ LL | reuse Trait::* { (&&&&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Rc<_>`, found `&&&&F` @@ -374,7 +374,7 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Rc<_>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -384,7 +384,7 @@ LL | reuse Trait::* { (&&&&self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` @@ -394,7 +394,7 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Pin>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -404,7 +404,7 @@ LL | reuse Trait::* { Box::pin(&&&&self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` @@ -414,13 +414,13 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Pin>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Pin>`, found `&&&&F` @@ -430,13 +430,13 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Pin>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ expected `Box>`, found `&&&&F` @@ -446,13 +446,13 @@ LL | reuse Trait::* { &&&&self.0 } = note: expected struct `Box>` found reference `&&&&F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Box<_>`, found `&F` @@ -462,7 +462,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Box<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -473,7 +473,7 @@ LL + reuse Trait::* { self.0 } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Arc<_>`, found `&F` @@ -483,7 +483,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Arc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -493,7 +493,7 @@ LL | reuse Trait::* { self.0.as_ref().into() } | +++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Rc<_>`, found `&F` @@ -503,7 +503,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Rc<_>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -513,7 +513,7 @@ LL | reuse Trait::* { self.0.as_ref().into() } | +++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` @@ -523,7 +523,7 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -533,7 +533,7 @@ LL | reuse Trait::* { Box::pin(self.0.as_ref()) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` @@ -543,13 +543,13 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Pin>`, found `&F` @@ -559,13 +559,13 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Pin>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ expected `Box>`, found `&F` @@ -575,13 +575,13 @@ LL | reuse Trait::* { self.0.as_ref() } = note: expected struct `Box>` found reference `&F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Box<_>`, found `&mut &mut &mut F` @@ -592,7 +592,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } found mutable reference `&mut &mut &mut F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -602,7 +602,7 @@ LL | reuse Trait::* { Box::new(&mut &mut &mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Arc<_>`, found `&mut &mut &mut F` @@ -612,7 +612,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Arc<_>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -622,7 +622,7 @@ LL | reuse Trait::* { (&mut &mut &mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Rc<_>`, found `&mut &mut &mut F` @@ -632,7 +632,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Rc<_>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -642,7 +642,7 @@ LL | reuse Trait::* { (&mut &mut &mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` @@ -652,7 +652,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -662,7 +662,7 @@ LL | reuse Trait::* { Box::pin(&mut &mut &mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` @@ -672,13 +672,13 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Pin>`, found `&mut &mut &mut F` @@ -688,13 +688,13 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Pin>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ expected `Box>`, found `&mut &mut &mut F` @@ -704,13 +704,13 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } = note: expected struct `Box>` found mutable reference `&mut &mut &mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Box<_>`, found `&&mut F` @@ -721,7 +721,7 @@ LL | reuse Trait::* { &&mut self.0 } found reference `&&mut F` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -731,7 +731,7 @@ LL | reuse Trait::* { Box::new(&&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Arc<_>`, found `&&mut F` @@ -741,7 +741,7 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Arc<_>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -751,7 +751,7 @@ LL | reuse Trait::* { (&&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Rc<_>`, found `&&mut F` @@ -761,7 +761,7 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Rc<_>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -771,7 +771,7 @@ LL | reuse Trait::* { (&&mut self.0).into() } | + ++++++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` @@ -781,7 +781,7 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Pin>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -791,7 +791,7 @@ LL | reuse Trait::* { Box::pin(&&mut self.0) } | +++++++++ + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` @@ -801,13 +801,13 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Pin>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Pin>`, found `&&mut F` @@ -817,13 +817,13 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Pin>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ expected `Box>`, found `&&mut F` @@ -833,13 +833,13 @@ LL | reuse Trait::* { &&mut self.0 } = note: expected struct `Box>` found reference `&&mut F` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:175:22 + --> $DIR/self-coercion-errors.rs:178:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `Box` @@ -849,7 +849,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -860,7 +860,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:175:22 + --> $DIR/self-coercion-errors.rs:178:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `Box` @@ -870,7 +870,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -881,7 +881,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:175:22 + --> $DIR/self-coercion-errors.rs:178:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box` @@ -891,7 +891,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -902,7 +902,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:175:22 + --> $DIR/self-coercion-errors.rs:178:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box` @@ -912,7 +912,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -923,7 +923,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:175:22 + --> $DIR/self-coercion-errors.rs:178:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box` @@ -933,7 +933,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -944,7 +944,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:175:22 + --> $DIR/self-coercion-errors.rs:178:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `Box` @@ -959,7 +959,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:172:8 + ::: $DIR/self-coercion-errors.rs:175:8 | LL | struct X6(Box); | -- ------ this is the field that was accessed @@ -968,7 +968,7 @@ LL | struct X6(Box); = note: expected struct `Box>` found struct `Box` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -979,7 +979,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `Box>>` @@ -989,7 +989,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -999,7 +999,7 @@ LL | reuse Trait::* { *self.0 } | + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `Box>>` @@ -1009,7 +1009,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -1020,7 +1020,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box>>` @@ -1030,7 +1030,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -1041,7 +1041,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box>>` @@ -1051,7 +1051,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -1062,7 +1062,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Box>>` @@ -1072,7 +1072,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -1083,7 +1083,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `Box>>` @@ -1098,7 +1098,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:184:8 + ::: $DIR/self-coercion-errors.rs:187:8 | LL | struct X7(Box>>); | -- ---------------- this is the field that was accessed @@ -1107,7 +1107,7 @@ LL | struct X7(Box>>); = note: expected struct `Box>` found struct `Box>>` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -1118,7 +1118,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box<_>`, found `Pin>` @@ -1133,7 +1133,7 @@ note: there is a field `0` on `Box` with type `std::ptr::Unique` but it | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:199:8 + ::: $DIR/self-coercion-errors.rs:202:8 | LL | struct X8(Pin>); | -- ----------- this is the field that was accessed @@ -1142,7 +1142,7 @@ LL | struct X8(Pin>); = note: expected struct `Box<_>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -1153,7 +1153,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `Pin>` @@ -1163,7 +1163,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -1174,7 +1174,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `Pin>` @@ -1184,7 +1184,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -1195,7 +1195,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Pin>` @@ -1205,7 +1205,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -1216,7 +1216,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `Pin>` @@ -1226,7 +1226,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -1237,7 +1237,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `Pin>` @@ -1252,7 +1252,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:199:8 + ::: $DIR/self-coercion-errors.rs:202:8 | LL | struct X8(Pin>); | -- ----------- this is the field that was accessed @@ -1261,7 +1261,7 @@ LL | struct X8(Pin>); = note: expected struct `Box>` found struct `Pin>` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -1272,7 +1272,7 @@ LL + reuse Trait::* { self } | error[E0277]: the trait bound `OtherStruct: Trait` is not satisfied - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ unsatisfied trait bound @@ -1280,18 +1280,18 @@ LL | reuse Trait::* { self.0 } | required by a bound introduced by this call | help: the trait `Trait` is not implemented for `OtherStruct` - --> $DIR/self-coercion-errors.rs:214:1 + --> $DIR/self-coercion-errors.rs:217:1 | LL | struct OtherStruct; | ^^^^^^^^^^^^^^^^^^ help: the trait `Trait` is implemented for `F` - --> $DIR/self-coercion-errors.rs:21:1 + --> $DIR/self-coercion-errors.rs:24:1 | LL | impl Trait for F {} | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `&mut _`, found `OtherStruct` @@ -1301,7 +1301,7 @@ LL | reuse Trait::* { self.0 } = note: expected mutable reference `&mut _` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:9:8 + --> $DIR/self-coercion-errors.rs:12:8 | LL | fn by_mut_ref(&mut self) -> i32 { 2 } | ^^^^^^^^^^ --------- @@ -1311,7 +1311,7 @@ LL | reuse Trait::* { &mut self.0 } | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `&_`, found `OtherStruct` @@ -1321,7 +1321,7 @@ LL | reuse Trait::* { self.0 } = note: expected reference `&_` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:10:8 + --> $DIR/self-coercion-errors.rs:13:8 | LL | fn by_ref(&self) -> i32 { 3 } | ^^^^^^ ----- @@ -1331,7 +1331,7 @@ LL | reuse Trait::* { &self.0 } | + error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box<_>`, found `OtherStruct` @@ -1346,7 +1346,7 @@ note: there is a field `0` on `Box` with type `std::ptr::Unique` but it | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:215:8 + ::: $DIR/self-coercion-errors.rs:218:8 | LL | struct X9(OtherStruct); | -- ----------- this is the field that was accessed @@ -1355,7 +1355,7 @@ LL | struct X9(OtherStruct); = note: expected struct `Box<_>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:11:8 + --> $DIR/self-coercion-errors.rs:14:8 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^^ ---- @@ -1366,7 +1366,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Arc<_>`, found `OtherStruct` @@ -1376,7 +1376,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Arc<_>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:12:8 + --> $DIR/self-coercion-errors.rs:15:8 | LL | fn arc(self: Arc) -> i32 { 5 } | ^^^ ---- @@ -1387,7 +1387,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Rc<_>`, found `OtherStruct` @@ -1397,7 +1397,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Rc<_>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:13:8 + --> $DIR/self-coercion-errors.rs:16:8 | LL | fn rc(self: Rc) -> i32 { 6 } | ^^ ---- @@ -1408,7 +1408,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `OtherStruct` @@ -1418,7 +1418,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:14:8 + --> $DIR/self-coercion-errors.rs:17:8 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^^^^ ---- @@ -1429,7 +1429,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `OtherStruct` @@ -1439,7 +1439,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:15:8 + --> $DIR/self-coercion-errors.rs:18:8 | LL | fn pin_rc(self: Pin>) -> i32 { 8 } | ^^^^^^ ---- @@ -1450,7 +1450,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Pin>`, found `OtherStruct` @@ -1460,7 +1460,7 @@ LL | reuse Trait::* { self.0 } = note: expected struct `Pin>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:16:8 + --> $DIR/self-coercion-errors.rs:19:8 | LL | fn pin_arc(self: Pin>) -> i32 { 9 } | ^^^^^^^ ---- @@ -1471,7 +1471,7 @@ LL + reuse Trait::* { self } | error[E0308]: mismatched types - --> $DIR/self-coercion-errors.rs:218:22 + --> $DIR/self-coercion-errors.rs:221:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ expected `Box>`, found `OtherStruct` @@ -1486,7 +1486,7 @@ note: there is a field `0` on `Box>` with type `std::ptr::Unique | = note: if this field wasn't private, it would be accessible | - ::: $DIR/self-coercion-errors.rs:215:8 + ::: $DIR/self-coercion-errors.rs:218:8 | LL | struct X9(OtherStruct); | -- ----------- this is the field that was accessed @@ -1495,7 +1495,7 @@ LL | struct X9(OtherStruct); = note: expected struct `Box>` found struct `OtherStruct` note: method defined here - --> $DIR/self-coercion-errors.rs:17:8 + --> $DIR/self-coercion-errors.rs:20:8 | LL | fn box_box(self: Box>) -> i32 { 10 } | ^^^^^^^ ---- @@ -1506,7 +1506,7 @@ LL + reuse Trait::* { self } | error[E0507]: cannot move out of a mutable reference - --> $DIR/self-coercion-errors.rs:70:9 + --> $DIR/self-coercion-errors.rs:73:9 | LL | reuse Trait::{by_value, by_mut_ref, by_ref} { | -------- value moved due to this method call @@ -1515,12 +1515,12 @@ LL | &mut x | ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1529,7 +1529,7 @@ LL | &mut x | ------ you could clone this value error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/self-coercion-errors.rs:70:9 + --> $DIR/self-coercion-errors.rs:73:9 | LL | &mut x | ^^^^^^ cannot borrow as mutable @@ -1540,7 +1540,7 @@ LL | let mut x = foo(); | +++ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/self-coercion-errors.rs:70:9 + --> $DIR/self-coercion-errors.rs:73:9 | LL | &mut x | ^^^^^^ cannot borrow as mutable @@ -1552,7 +1552,7 @@ LL | let mut x = foo(); | +++ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/self-coercion-errors.rs:70:9 + --> $DIR/self-coercion-errors.rs:73:9 | LL | &mut x | ^^^^^^ cannot borrow as mutable @@ -1564,7 +1564,7 @@ LL | let mut x = foo(); | +++ error[E0507]: cannot move out of a mutable reference - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | - ^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1572,12 +1572,12 @@ LL | reuse Trait::* { &mut self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1586,7 +1586,7 @@ LL | reuse Trait::* { &mut self.0 } | ----------- you could clone this value error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | ^^^^^^^^^^^ cannot borrow as mutable @@ -1597,7 +1597,7 @@ LL | reuse Trait::mut * { &mut self.0 } | +++ error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference - --> $DIR/self-coercion-errors.rs:81:22 + --> $DIR/self-coercion-errors.rs:84:22 | LL | reuse Trait::* { &mut self.0 } | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable @@ -1609,7 +1609,7 @@ LL + reuse Trait::&mut self { &mut self.0 } | error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | - ^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1617,12 +1617,12 @@ LL | reuse Trait::* { &self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1631,13 +1631,13 @@ LL | reuse Trait::* { &self.0 } | ------- you could clone this value error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:97:22 + --> $DIR/self-coercion-errors.rs:100:22 | LL | reuse Trait::* { &self.0 } | ^^^^^^^ cannot borrow as mutable error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | - ^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1645,12 +1645,12 @@ LL | reuse Trait::* { &&&&self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1659,13 +1659,13 @@ LL | reuse Trait::* { &&&&self.0 } | ---------- you could clone this value error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:112:22 + --> $DIR/self-coercion-errors.rs:115:22 | LL | reuse Trait::* { &&&&self.0 } | ^^^^^^^^^^ cannot borrow as mutable error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | - ^^^^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1673,12 +1673,12 @@ LL | reuse Trait::* { self.0.as_ref() } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1687,13 +1687,13 @@ LL | reuse Trait::* { self.0.as_ref() } | --------------- you could clone this value error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:127:22 + --> $DIR/self-coercion-errors.rs:130:22 | LL | reuse Trait::* { self.0.as_ref() } | ^^^^^^^^^^^^^^^ cannot borrow as mutable error[E0507]: cannot move out of a mutable reference - --> $DIR/self-coercion-errors.rs:142:22 + --> $DIR/self-coercion-errors.rs:145:22 | LL | reuse Trait::* { &mut &mut &mut self.0 } | - ^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1701,12 +1701,12 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1715,7 +1715,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } | --------------------- you could clone this value error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable - --> $DIR/self-coercion-errors.rs:142:32 + --> $DIR/self-coercion-errors.rs:145:32 | LL | reuse Trait::* { &mut &mut &mut self.0 } | ^^^^^^^^^^^ cannot borrow as mutable @@ -1726,7 +1726,7 @@ LL | reuse Trait::mut * { &mut &mut &mut self.0 } | +++ error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference - --> $DIR/self-coercion-errors.rs:142:32 + --> $DIR/self-coercion-errors.rs:145:32 | LL | reuse Trait::* { &mut &mut &mut self.0 } | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable @@ -1738,7 +1738,7 @@ LL + reuse Trait::&mut self { &mut &mut &mut self.0 } | error[E0507]: cannot move out of a shared reference - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | - ^^^^^^^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1746,12 +1746,12 @@ LL | reuse Trait::* { &&mut self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1760,7 +1760,7 @@ LL | reuse Trait::* { &&mut self.0 } | ------------ you could clone this value error[E0596]: cannot borrow `self.0` as mutable, as `self` is not declared as mutable - --> $DIR/self-coercion-errors.rs:158:23 + --> $DIR/self-coercion-errors.rs:161:23 | LL | reuse Trait::* { &&mut self.0 } | ^^^^^^^^^^^ cannot borrow as mutable @@ -1771,13 +1771,13 @@ LL | reuse Trait::mut * { &&mut self.0 } | +++ error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/self-coercion-errors.rs:158:22 + --> $DIR/self-coercion-errors.rs:161:22 | LL | reuse Trait::* { &&mut self.0 } | ^^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `self.0` as mutable, as it is behind a `&` reference - --> $DIR/self-coercion-errors.rs:158:23 + --> $DIR/self-coercion-errors.rs:161:23 | LL | reuse Trait::* { &&mut self.0 } | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable @@ -1789,7 +1789,7 @@ LL + reuse Trait::&mut self { &&mut self.0 } | error[E0507]: cannot move out of an `Arc` - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1797,12 +1797,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1811,7 +1811,7 @@ LL | reuse Trait::* { self.0 } | ------ you could clone this value error[E0596]: cannot borrow data in an `Arc` as mutable - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | ^^^^^^ cannot borrow as mutable @@ -1819,7 +1819,7 @@ LL | reuse Trait::* { self.0 } = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Arc>` error[E0507]: cannot move out of an `Arc` - --> $DIR/self-coercion-errors.rs:187:22 + --> $DIR/self-coercion-errors.rs:190:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `Box`, which does not implement the `Copy` trait @@ -1827,12 +1827,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::r#box` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:11:14 + --> $DIR/self-coercion-errors.rs:14:14 | LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1850,7 +1850,7 @@ LL | struct F; | error[E0507]: cannot move out of dereference of `Pin>` - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `F`, which does not implement the `Copy` trait @@ -1858,12 +1858,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::by_value` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:8:17 + --> $DIR/self-coercion-errors.rs:11:17 | LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type @@ -1872,7 +1872,7 @@ LL | reuse Trait::* { self.0 } | ------ you could clone this value error[E0596]: cannot borrow data in dereference of `Pin>` as mutable - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | ^^^^^^ cannot borrow as mutable @@ -1880,7 +1880,7 @@ LL | reuse Trait::* { self.0 } = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Pin>` error[E0507]: cannot move out of dereference of `Pin>` - --> $DIR/self-coercion-errors.rs:202:22 + --> $DIR/self-coercion-errors.rs:205:22 | LL | reuse Trait::* { self.0 } | - ^^^^^^ move occurs because value has type `Pin>`, which does not implement the `Copy` trait @@ -1888,12 +1888,12 @@ LL | reuse Trait::* { self.0 } | value moved due to this method call | note: `Trait::pin_box` takes ownership of the receiver `self`, which moves value - --> $DIR/self-coercion-errors.rs:14:16 + --> $DIR/self-coercion-errors.rs:17:16 | LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value - --> $DIR/self-coercion-errors.rs:20:1 + --> $DIR/self-coercion-errors.rs:23:1 | LL | struct F; | ^^^^^^^^ consider implementing `Clone` for this type diff --git a/tests/ui/delegation/self-coercion-static-free.stderr b/tests/ui/delegation/self-coercion-static-free.stderr index 276cd2d874e60..5f78272815aa5 100644 --- a/tests/ui/delegation/self-coercion-static-free.stderr +++ b/tests/ui/delegation/self-coercion-static-free.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/self-coercion-static-free.rs:20:9 + --> $DIR/self-coercion-static-free.rs:24:9 | LL | S::static_self() | ^^^^^^^^^^^^^^^^ expected `&mut F`, found `F` @@ -10,7 +10,7 @@ LL | &mut S::static_self() | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-static-free.rs:20:9 + --> $DIR/self-coercion-static-free.rs:24:9 | LL | S::static_self() | ^^^^^^^^^^^^^^^^ expected `&F`, found `F` @@ -21,7 +21,7 @@ LL | &S::static_self() | + error[E0308]: mismatched types - --> $DIR/self-coercion-static-free.rs:31:9 + --> $DIR/self-coercion-static-free.rs:35:9 | LL | S1::static_self() | ^^^^^^^^^^^^^^^^^ expected `&mut F`, found `F` @@ -32,7 +32,7 @@ LL | &mut S1::static_self() | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-static-free.rs:31:9 + --> $DIR/self-coercion-static-free.rs:35:9 | LL | S1::static_self() | ^^^^^^^^^^^^^^^^^ expected `&F`, found `F` @@ -43,7 +43,7 @@ LL | &S1::static_self() | + error[E0308]: mismatched types - --> $DIR/self-coercion-static-free.rs:44:43 + --> $DIR/self-coercion-static-free.rs:48:43 | LL | reuse to_reuse::{value, mut_ref, r#ref} { F } | ------- ^ expected `&mut _`, found `F` @@ -53,7 +53,7 @@ LL | reuse to_reuse::{value, mut_ref, r#ref} { F } = note: expected mutable reference `&mut _` found struct `F` note: function defined here - --> $DIR/self-coercion-static-free.rs:40:12 + --> $DIR/self-coercion-static-free.rs:44:12 | LL | pub fn mut_ref(_: &mut impl Trait) -> i32 { 2 } | ^^^^^^^ ------------------ @@ -63,7 +63,7 @@ LL | reuse to_reuse::{value, mut_ref, r#ref} { &mut F } | ++++ error[E0308]: mismatched types - --> $DIR/self-coercion-static-free.rs:44:43 + --> $DIR/self-coercion-static-free.rs:48:43 | LL | reuse to_reuse::{value, mut_ref, r#ref} { F } | ----- ^ expected `&_`, found `F` @@ -73,7 +73,7 @@ LL | reuse to_reuse::{value, mut_ref, r#ref} { F } = note: expected reference `&_` found struct `F` note: function defined here - --> $DIR/self-coercion-static-free.rs:41:12 + --> $DIR/self-coercion-static-free.rs:45:12 | LL | pub fn r#ref(_: &impl Trait) -> i32 { 3 } | ^^^^^ -------------- From 1e9e8221e375400ef967fa0d735f30fea04df577 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Mon, 25 May 2026 08:19:41 +0300 Subject: [PATCH 13/14] Cleanups --- compiler/rustc_hir_typeck/src/callee.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index cd3804e82ebd5..d51a0bf2c3ef4 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -643,7 +643,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); }; - let Some(scope) = self.try_get_scope_for_call_adjustments(call_expr, arg_exprs) else { + let Some(scope) = self.get_scope_for_method_call_adjustments(call_expr, arg_exprs) else { return do_check(); }; @@ -688,7 +688,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { results.node_types_mut().insert(first_expr.hir_id, first_arg_type); } - fn try_get_scope_for_call_adjustments( + /// Gets scope for method-call like adjustments for the first argument of the call. + /// Now only delegations are processed this way. + fn get_scope_for_method_call_adjustments( &self, call_expr: &'tcx hir::Expr<'tcx>, arg_exprs: &'tcx [hir::Expr<'tcx>], @@ -707,7 +709,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let Some(path_res_id) = info.call_path_res else { return None }; // Check that delegation has first provided arg and that the call path - // resolves to a trait method (inherent methods are not yet supported) + // resolves to a trait method (inherent methods are not yet supported). if arg_exprs.is_empty() || !self.tcx.opt_associated_item(path_res_id).is_some_and(|i| i.is_method()) { From 0c5f5bdce18322f4e7ea0791e53ad2d2106a519a Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Mon, 25 May 2026 09:19:18 +0300 Subject: [PATCH 14/14] Fix tests --- tests/ui/delegation/wrong-lifetime-rib.rs | 2 +- tests/ui/delegation/wrong-lifetime-rib.stderr | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/tests/ui/delegation/wrong-lifetime-rib.rs b/tests/ui/delegation/wrong-lifetime-rib.rs index 825ac6a64008a..01645f20bf7b1 100644 --- a/tests/ui/delegation/wrong-lifetime-rib.rs +++ b/tests/ui/delegation/wrong-lifetime-rib.rs @@ -33,7 +33,7 @@ mod ice_156806 { trait X {} impl X { //~ ERROR: expected a type, found a trait - reuse Iterator::fold { //~ ERROR: `()` is not an iterator + reuse Iterator::fold { let _: &X; //~ ERROR: expected a type, found a trait } } diff --git a/tests/ui/delegation/wrong-lifetime-rib.stderr b/tests/ui/delegation/wrong-lifetime-rib.stderr index 07ddc94f7a4ae..0c4499eec192d 100644 --- a/tests/ui/delegation/wrong-lifetime-rib.stderr +++ b/tests/ui/delegation/wrong-lifetime-rib.stderr @@ -66,17 +66,7 @@ help: you can add the `dyn` keyword if you want a trait object LL | let _: &dyn X; | +++ -error[E0599]: `()` is not an iterator - --> $DIR/wrong-lifetime-rib.rs:36:25 - | -LL | reuse Iterator::fold { - | ^^^^ `()` is not an iterator - | - = note: the following trait bounds were not satisfied: - `(): Iterator` - which is required by `&mut (): Iterator` - -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0116, E0223, E0423, E0599, E0782. +Some errors have detailed explanations: E0116, E0223, E0423, E0782. For more information about an error, try `rustc --explain E0116`.