]> git.proxmox.com Git - rustc.git/blame - src/test/ui-fulldeps/internal-lints/pass_ty_by_ref_self.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui-fulldeps / internal-lints / pass_ty_by_ref_self.rs
CommitLineData
1b1a35ee
XL
1// NOTE: This test doesn't actually require `fulldeps`
2// so we could instead use it as an `ui` test.
3//
4// Considering that all other `internal-lints` are tested here
5// this seems like the cleaner solution though.
6#![feature(rustc_attrs)]
7#![deny(rustc::ty_pass_by_reference)]
8#![allow(unused)]
9
10#[rustc_diagnostic_item = "TyCtxt"]
11struct TyCtxt<'tcx> {
12 inner: &'tcx (),
13}
14
15impl<'tcx> TyCtxt<'tcx> {
16 fn by_value(self) {} // OK
17 fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference
18}
19
20
21struct TyS<'tcx> {
22 inner: &'tcx (),
23}
24
25#[rustc_diagnostic_item = "Ty"]
26type Ty<'tcx> = &'tcx TyS<'tcx>;
27
28impl<'tcx> TyS<'tcx> {
29 fn by_value(self: Ty<'tcx>) {}
30 fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference
31}
32
33fn main() {}