From: flip1995 Date: Wed, 24 Apr 2019 21:23:44 +0000 (+0200) Subject: Add tests X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=90ba09d299809389d1f7c362cdc356157ff02130;p=rust.git Add tests --- diff --git a/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs b/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs new file mode 100644 index 00000000000..075ce8b1a1c --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs @@ -0,0 +1,64 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![deny(ty_pass_by_reference)] +#![allow(unused)] + +extern crate rustc; + +use rustc::ty::{Ty, TyCtxt}; + +fn ty_by_ref( + ty_val: Ty<'_>, + ty_ref: &Ty<'_>, //~ ERROR passing `Ty<'_>` by reference + ty_ctxt_val: TyCtxt<'_, '_, '_>, + ty_ctxt_ref: &TyCtxt<'_, '_, '_>, //~ ERROR passing `TyCtxt<'_, '_, '_>` by reference +) { +} + +fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_, '_>) {} +//~^ ERROR passing `Ty<'_>` by reference +//~^^ ERROR passing `TyCtxt<'_, '_, '_>` by reference + +trait T { + fn ty_by_ref_in_trait( + ty_val: Ty<'_>, + ty_ref: &Ty<'_>, //~ ERROR passing `Ty<'_>` by reference + ty_ctxt_val: TyCtxt<'_, '_, '_>, + ty_ctxt_ref: &TyCtxt<'_, '_, '_>, //~ ERROR passing `TyCtxt<'_, '_, '_>` by reference + ); + + fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_, '_>); + //~^ ERROR passing `Ty<'_>` by reference + //~^^ ERROR passing `TyCtxt<'_, '_, '_>` by reference +} + +struct Foo; + +impl T for Foo { + fn ty_by_ref_in_trait( + ty_val: Ty<'_>, + ty_ref: &Ty<'_>, + ty_ctxt_val: TyCtxt<'_, '_, '_>, + ty_ctxt_ref: &TyCtxt<'_, '_, '_>, + ) { + } + + fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_, '_>) {} +} + +impl Foo { + fn ty_by_ref_assoc( + ty_val: Ty<'_>, + ty_ref: &Ty<'_>, //~ ERROR passing `Ty<'_>` by reference + ty_ctxt_val: TyCtxt<'_, '_, '_>, + ty_ctxt_ref: &TyCtxt<'_, '_, '_>, //~ ERROR passing `TyCtxt<'_, '_, '_>` by reference + ) { + } + + fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_, '_>) {} + //~^ ERROR passing `Ty<'_>` by reference + //~^^ ERROR passing `TyCtxt<'_, '_, '_>` by reference +} + +fn main() {} diff --git a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs new file mode 100644 index 00000000000..5e10697ec66 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs @@ -0,0 +1,35 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![deny(usage_of_qualified_ty)] +#![allow(unused)] + +extern crate rustc; + +use rustc::ty::{self, Ty, TyCtxt}; + +macro_rules! qualified_macro { + ($a:ident) => { + fn ty_in_macro( + ty_q: ty::Ty<'_>, + ty: Ty<'_>, + ty_ctxt_q: ty::TyCtxt<'_, '_, '_>, + ty_ctxt: TyCtxt<'_, '_, '_>, + ) { + println!("{}", stringify!($a)); + } + }; +} + +fn ty_qualified( + ty_q: ty::Ty<'_>, //~ ERROR usage of qualified `ty::Ty<'_>` + ty: Ty<'_>, + ty_ctxt_q: ty::TyCtxt<'_, '_, '_>, //~ ERROR usage of qualified `ty::TyCtxt<'_, '_, '_>` + ty_ctxt: TyCtxt<'_, '_, '_>, +) { +} + + +fn main() { + qualified_macro!(a); +}