]>
git.proxmox.com Git - rustc.git/blob - src/test/ui-fulldeps/internal-lints/rustc_pass_by_value.rs
1 // compile-flags: -Z unstable-options
3 #![feature(rustc_attrs)]
4 #![feature(rustc_private)]
5 #![deny(rustc::pass_by_value)]
8 extern crate rustc_middle
;
10 use rustc_middle
::ty
::{Ty, TyCtxt}
;
14 ty_ref
: &Ty
<'_
>, //~ ERROR passing `Ty<'_>` by reference
15 ty_ctxt_val
: TyCtxt
<'_
>,
16 ty_ctxt_ref
: &TyCtxt
<'_
>, //~ ERROR passing `TyCtxt<'_>` by reference
20 fn ty_multi_ref(ty_multi
: &&Ty
<'_
>, ty_ctxt_multi
: &&&&TyCtxt
<'_
>) {}
21 //~^ ERROR passing `Ty<'_>` by reference
22 //~^^ ERROR passing `TyCtxt<'_>` by reference
25 fn ty_by_ref_in_trait(
27 ty_ref
: &Ty
<'_
>, //~ ERROR passing `Ty<'_>` by reference
28 ty_ctxt_val
: TyCtxt
<'_
>,
29 ty_ctxt_ref
: &TyCtxt
<'_
>, //~ ERROR passing `TyCtxt<'_>` by reference
32 fn ty_multi_ref_in_trait(ty_multi
: &&Ty
<'_
>, ty_ctxt_multi
: &&&&TyCtxt
<'_
>);
33 //~^ ERROR passing `Ty<'_>` by reference
34 //~^^ ERROR passing `TyCtxt<'_>` by reference
40 fn ty_by_ref_in_trait(
43 ty_ctxt_val
: TyCtxt
<'_
>,
44 ty_ctxt_ref
: &TyCtxt
<'_
>,
48 fn ty_multi_ref_in_trait(ty_multi
: &&Ty
<'_
>, ty_ctxt_multi
: &&&&TyCtxt
<'_
>) {}
54 ty_ref
: &Ty
<'_
>, //~ ERROR passing `Ty<'_>` by reference
55 ty_ctxt_val
: TyCtxt
<'_
>,
56 ty_ctxt_ref
: &TyCtxt
<'_
>, //~ ERROR passing `TyCtxt<'_>` by reference
60 fn ty_multi_ref_assoc(ty_multi
: &&Ty
<'_
>, ty_ctxt_multi
: &&&&TyCtxt
<'_
>) {}
61 //~^ ERROR passing `Ty<'_>` by reference
62 //~^^ ERROR passing `TyCtxt<'_>` by reference
65 #[rustc_pass_by_value]
74 reference
: &CustomEnum
, //~ ERROR passing `CustomEnum` by reference
79 #[rustc_pass_by_value]
84 #[rustc_pass_by_value]
85 type CustomAlias
<'a
> = &'a CustomStruct
; //~ ERROR passing `CustomStruct` by reference
90 reference
: &CustomStruct
, //~ ERROR passing `CustomStruct` by reference
96 reference
: &CustomAlias
, //~ ERROR passing `CustomAlias<'_>` by reference
101 #[rustc_pass_by_value]
102 struct WithParameters
<T
, const N
: usize, M
= u32> {
107 impl<T
> WithParameters
<T
, 1> {
109 value
: WithParameters
<T
, 1>,
110 reference
: &'a WithParameters
<T
, 1>, //~ ERROR passing `WithParameters<T, 1>` by reference
111 reference_with_m
: &WithParameters
<T
, 1, u32>, //~ ERROR passing `WithParameters<T, 1, u32>` by reference
112 ) -> &'a WithParameters
<T
, 1> {
113 //~^ ERROR passing `WithParameters<T, 1>` by reference
114 reference
as &WithParameters
<_
, 1> //~ ERROR passing `WithParameters<_, 1>` by reference