1 // compile-flags: -Z unstable-options
2 // NOTE: This test doesn't actually require `fulldeps`
3 // so we could instead use it as a `ui` test.
5 // Considering that all other `internal-lints` are tested here
6 // this seems like the cleaner solution though.
7 #![feature(rustc_attrs)]
8 #![deny(rustc::pass_by_value)]
11 #[rustc_pass_by_value]
16 impl<'tcx> TyCtxt<'tcx> {
17 fn by_value(self) {} // OK
18 fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference
25 #[rustc_pass_by_value]
26 type Ty<'tcx> = &'tcx TyS<'tcx>;
28 impl<'tcx> TyS<'tcx> {
29 fn by_value(self: Ty<'tcx>) {}
30 fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference
33 #[rustc_pass_by_value]
37 fn with_ref(&self) {} //~ ERROR passing `Foo` by reference
40 #[rustc_pass_by_value]
41 struct WithParameters<T, const N: usize, M = u32> {
46 impl<T> WithParameters<T, 1> {
47 fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1>` by reference
50 impl<T> WithParameters<T, 1, u8> {
51 fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1, u8>` by reference