Add tests
This commit is contained in:
parent
747d288be4
commit
90ba09d299
64
src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs
Normal file
64
src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs
Normal file
@ -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() {}
|
35
src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs
Normal file
35
src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs
Normal file
@ -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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user