summaryrefslogtreecommitdiffstats
path: root/src/test/ui/autoref-autoderef
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/autoref-autoderef
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/autoref-autoderef')
-rw-r--r--src/test/ui/autoref-autoderef/auto-ref-bounded-ty-param.rs29
-rw-r--r--src/test/ui/autoref-autoderef/auto-ref-sliceable.rs19
-rw-r--r--src/test/ui/autoref-autoderef/auto-ref.rs19
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-and-borrow-method-receiver.rs18
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-method-on-trait.rs15
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-method-priority.rs19
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs15
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-method-twice.rs15
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-method.rs15
-rw-r--r--src/test/ui/autoref-autoderef/autoderef-privacy.rs51
-rw-r--r--src/test/ui/autoref-autoderef/autoref-intermediate-types-issue-3585.rs22
-rw-r--r--src/test/ui/autoref-autoderef/deref-into-array.rs17
-rw-r--r--src/test/ui/autoref-autoderef/issue-38940.rs52
-rw-r--r--src/test/ui/autoref-autoderef/issue-38940.stderr23
14 files changed, 0 insertions, 329 deletions
diff --git a/src/test/ui/autoref-autoderef/auto-ref-bounded-ty-param.rs b/src/test/ui/autoref-autoderef/auto-ref-bounded-ty-param.rs
deleted file mode 100644
index 2482e1878..000000000
--- a/src/test/ui/autoref-autoderef/auto-ref-bounded-ty-param.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// run-pass
-trait Foo {
- fn f(&self);
-}
-
-struct Bar {
- x: isize
-}
-
-trait Baz {
- fn g(&self);
-}
-
-impl<T:Baz> Foo for T {
- fn f(&self) {
- self.g();
- }
-}
-
-impl Baz for Bar {
- fn g(&self) {
- println!("{}", self.x);
- }
-}
-
-pub fn main() {
- let y = Bar { x: 42 };
- y.f();
-}
diff --git a/src/test/ui/autoref-autoderef/auto-ref-sliceable.rs b/src/test/ui/autoref-autoderef/auto-ref-sliceable.rs
deleted file mode 100644
index e5f79d780..000000000
--- a/src/test/ui/autoref-autoderef/auto-ref-sliceable.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-
-
-trait Pushable<T> {
- fn push_val(&mut self, t: T);
-}
-
-impl<T> Pushable<T> for Vec<T> {
- fn push_val(&mut self, t: T) {
- self.push(t);
- }
-}
-
-pub fn main() {
- let mut v = vec![1];
- v.push_val(2);
- v.push_val(3);
- assert_eq!(v, [1, 2, 3]);
-}
diff --git a/src/test/ui/autoref-autoderef/auto-ref.rs b/src/test/ui/autoref-autoderef/auto-ref.rs
deleted file mode 100644
index b77f9c342..000000000
--- a/src/test/ui/autoref-autoderef/auto-ref.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-struct Foo {
- x: isize,
-}
-
-trait Stuff {
- fn printme(&self);
-}
-
-impl Stuff for Foo {
- fn printme(&self) {
- println!("{}", self.x);
- }
-}
-
-pub fn main() {
- let x = Foo { x: 3 };
- x.printme();
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-and-borrow-method-receiver.rs b/src/test/ui/autoref-autoderef/autoderef-and-borrow-method-receiver.rs
deleted file mode 100644
index 874f42282..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-and-borrow-method-receiver.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// pretty-expanded FIXME #23616
-
-struct Foo {
- x: isize,
-}
-
-impl Foo {
- pub fn f(&self) {}
-}
-
-fn g(x: &mut Foo) {
- x.f();
-}
-
-pub fn main() {
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-method-on-trait.rs b/src/test/ui/autoref-autoderef/autoderef-method-on-trait.rs
deleted file mode 100644
index af747cc76..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-method-on-trait.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-trait double {
- fn double(self: Box<Self>) -> usize;
-}
-
-impl double for usize {
- fn double(self: Box<usize>) -> usize { *self * 2 }
-}
-
-pub fn main() {
- let x: Box<_> = Box::new(Box::new(3usize) as Box<dyn double>);
- assert_eq!(x.double(), 6);
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-method-priority.rs b/src/test/ui/autoref-autoderef/autoderef-method-priority.rs
deleted file mode 100644
index 88a5140dc..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-method-priority.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-trait double {
- fn double(self) -> usize;
-}
-
-impl double for usize {
- fn double(self) -> usize { self }
-}
-
-impl double for Box<usize> {
- fn double(self) -> usize { *self * 2 }
-}
-
-pub fn main() {
- let x: Box<_> = Box::new(3);
- assert_eq!(x.double(), 6);
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs b/src/test/ui/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs
deleted file mode 100644
index 3657e61d4..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-trait double {
- fn double(self: Box<Self>) -> usize;
-}
-
-impl double for Box<usize> {
- fn double(self: Box<Box<usize>>) -> usize { **self * 2 }
-}
-
-pub fn main() {
- let x: Box<Box<Box<Box<Box<_>>>>> = Box::new(Box::new(Box::new(Box::new(Box::new(3)))));
- assert_eq!(x.double(), 6);
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-method-twice.rs b/src/test/ui/autoref-autoderef/autoderef-method-twice.rs
deleted file mode 100644
index ed86b31b8..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-method-twice.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-trait double {
- fn double(self: Box<Self>) -> usize;
-}
-
-impl double for usize {
- fn double(self: Box<usize>) -> usize { *self * 2 }
-}
-
-pub fn main() {
- let x: Box<Box<_>> = Box::new(Box::new(3));
- assert_eq!(x.double(), 6);
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-method.rs b/src/test/ui/autoref-autoderef/autoderef-method.rs
deleted file mode 100644
index 5b7965e95..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-method.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-trait double {
- fn double(self: Box<Self>) -> usize;
-}
-
-impl double for usize {
- fn double(self: Box<usize>) -> usize { *self * 2 }
-}
-
-pub fn main() {
- let x: Box<_> = Box::new(3);
- assert_eq!(x.double(), 6);
-}
diff --git a/src/test/ui/autoref-autoderef/autoderef-privacy.rs b/src/test/ui/autoref-autoderef/autoderef-privacy.rs
deleted file mode 100644
index 841be930b..000000000
--- a/src/test/ui/autoref-autoderef/autoderef-privacy.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// run-pass
-// Check we do not select a private method or field when computing autoderefs
-
-#![allow(unused)]
-
-#[derive(Default)]
-pub struct Bar2 { i: i32 }
-#[derive(Default)]
-pub struct Baz2(i32);
-
-impl Bar2 {
- fn f(&self) -> bool { true }
-}
-
-mod foo {
- #[derive(Default)]
- pub struct Bar { i: ::Bar2 }
- #[derive(Default)]
- pub struct Baz(::Baz2);
-
- impl Bar {
- fn f(&self) -> bool { false }
- }
-
- impl ::std::ops::Deref for Bar {
- type Target = ::Bar2;
- fn deref(&self) -> &::Bar2 { &self.i }
- }
-
- impl ::std::ops::Deref for Baz {
- type Target = ::Baz2;
- fn deref(&self) -> &::Baz2 { &self.0 }
- }
-
- pub fn f(bar: &Bar, baz: &Baz) {
- // Since the private fields and methods are visible here, there should be no autoderefs.
- let _: &::Bar2 = &bar.i;
- let _: &::Baz2 = &baz.0;
- assert!(!bar.f());
- }
-}
-
-fn main() {
- let bar = foo::Bar::default();
- let baz = foo::Baz::default();
- foo::f(&bar, &baz);
-
- let _: i32 = bar.i;
- let _: i32 = baz.0;
- assert!(bar.f());
-}
diff --git a/src/test/ui/autoref-autoderef/autoref-intermediate-types-issue-3585.rs b/src/test/ui/autoref-autoderef/autoref-intermediate-types-issue-3585.rs
deleted file mode 100644
index 3bdc248ff..000000000
--- a/src/test/ui/autoref-autoderef/autoref-intermediate-types-issue-3585.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// run-pass
-
-trait Foo {
- fn foo(&self) -> String;
-}
-
-impl<T:Foo> Foo for Box<T> {
- fn foo(&self) -> String {
- format!("box {}", (**self).foo())
- }
-}
-
-impl Foo for usize {
- fn foo(&self) -> String {
- format!("{}", *self)
- }
-}
-
-pub fn main() {
- let x: Box<_> = Box::new(3);
- assert_eq!(x.foo(), "box 3".to_string());
-}
diff --git a/src/test/ui/autoref-autoderef/deref-into-array.rs b/src/test/ui/autoref-autoderef/deref-into-array.rs
deleted file mode 100644
index 855a82d2f..000000000
--- a/src/test/ui/autoref-autoderef/deref-into-array.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// check-pass
-
-struct Test<T>([T; 1]);
-
-impl<T> std::ops::Deref for Test<T> {
- type Target = [T; 1];
-
- fn deref(&self) -> &[T; 1] {
- &self.0
- }
-}
-
-fn main() {
- let out = Test([(); 1]);
- let blah = out.len();
- println!("{}", blah);
-}
diff --git a/src/test/ui/autoref-autoderef/issue-38940.rs b/src/test/ui/autoref-autoderef/issue-38940.rs
deleted file mode 100644
index d2f1c6e32..000000000
--- a/src/test/ui/autoref-autoderef/issue-38940.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-// issue-38940: error printed twice for deref recursion limit exceeded
-// Test that the recursion limit can be changed. In this case, we have
-// deeply nested types that will fail the `Send` check by overflow
-// when the recursion limit is set very low.
-// compile-flags: -Zdeduplicate-diagnostics=yes
-
-#![allow(dead_code)]
-#![recursion_limit = "10"]
-macro_rules! link {
- ($outer:ident, $inner:ident) => {
- struct $outer($inner);
- impl $outer {
- fn new() -> $outer {
- $outer($inner::new())
- }
- }
- impl std::ops::Deref for $outer {
- type Target = $inner;
- fn deref(&self) -> &$inner {
- &self.0
- }
- }
- };
-}
-
-struct Bottom;
-
-impl Bottom {
- fn new() -> Bottom {
- Bottom
- }
-}
-
-link!(Top, A);
-link!(A, B);
-link!(B, C);
-link!(C, D);
-link!(D, E);
-link!(E, F);
-link!(F, G);
-link!(G, H);
-link!(H, I);
-link!(I, J);
-link!(J, K);
-link!(K, Bottom);
-
-fn main() {
- let t = Top::new();
- let x: &Bottom = &t;
- //~^ ERROR mismatched types
- //~| ERROR reached the recursion limit while auto-dereferencing `J`
-}
diff --git a/src/test/ui/autoref-autoderef/issue-38940.stderr b/src/test/ui/autoref-autoderef/issue-38940.stderr
deleted file mode 100644
index f0b840577..000000000
--- a/src/test/ui/autoref-autoderef/issue-38940.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0055]: reached the recursion limit while auto-dereferencing `J`
- --> $DIR/issue-38940.rs:49:22
- |
-LL | let x: &Bottom = &t;
- | ^^ deref recursion limit reached
- |
- = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`issue_38940`)
-
-error[E0308]: mismatched types
- --> $DIR/issue-38940.rs:49:22
- |
-LL | let x: &Bottom = &t;
- | ------- ^^ expected struct `Bottom`, found struct `Top`
- | |
- | expected due to this
- |
- = note: expected reference `&Bottom`
- found reference `&Top`
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0055, E0308.
-For more information about an error, try `rustc --explain E0055`.