diff options
| author | jyn <jyn.nelson@redjack.com> | 2023-04-02 18:09:11 -0400 |
|---|---|---|
| committer | jyn <github@jyn.dev> | 2023-04-13 22:08:07 -0500 |
| commit | 2ffb0de8cfda57cafdfd71a690f14c2e17216d85 (patch) | |
| tree | 6532dfe5f6e108c4e6a61b69cca66bda65e6827a /tests/ui/internal-lints/rustc_pass_by_value_self.rs | |
| parent | 9693b178fcebe3cc27129b7bc1237ee5eb706af8 (diff) | |
| download | rust-2ffb0de8cfda57cafdfd71a690f14c2e17216d85.tar.gz rust-2ffb0de8cfda57cafdfd71a690f14c2e17216d85.zip | |
Move most ui-fulldeps tests to ui
They pass fine. Only tests that required `extern crate rustc_*` or were marked `ignore-stage1` have been keep in fulldeps.
Diffstat (limited to 'tests/ui/internal-lints/rustc_pass_by_value_self.rs')
| -rw-r--r-- | tests/ui/internal-lints/rustc_pass_by_value_self.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.rs b/tests/ui/internal-lints/rustc_pass_by_value_self.rs new file mode 100644 index 00000000000..6ce67dcaf1d --- /dev/null +++ b/tests/ui/internal-lints/rustc_pass_by_value_self.rs @@ -0,0 +1,54 @@ +// compile-flags: -Z unstable-options +// NOTE: This test doesn't actually require `fulldeps` +// so we could instead use it as a `ui` test. +// +// Considering that all other `internal-lints` are tested here +// this seems like the cleaner solution though. +#![feature(rustc_attrs)] +#![deny(rustc::pass_by_value)] +#![allow(unused)] + +#[rustc_pass_by_value] +struct TyCtxt<'tcx> { + inner: &'tcx (), +} + +impl<'tcx> TyCtxt<'tcx> { + fn by_value(self) {} // OK + fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference +} + +struct TyS<'tcx> { + inner: &'tcx (), +} + +#[rustc_pass_by_value] +type Ty<'tcx> = &'tcx TyS<'tcx>; + +impl<'tcx> TyS<'tcx> { + fn by_value(self: Ty<'tcx>) {} + fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference +} + +#[rustc_pass_by_value] +struct Foo; + +impl Foo { + fn with_ref(&self) {} //~ ERROR passing `Foo` by reference +} + +#[rustc_pass_by_value] +struct WithParameters<T, const N: usize, M = u32> { + slice: [T; N], + m: M, +} + +impl<T> WithParameters<T, 1> { + fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1>` by reference +} + +impl<T> WithParameters<T, 1, u8> { + fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1, u8>` by reference +} + +fn main() {} |
