about summary refs log tree commit diff
path: root/src/test/ui/mut
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /src/test/ui/mut
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
Move /src/test to /tests
Diffstat (limited to 'src/test/ui/mut')
-rw-r--r--src/test/ui/mut/mut-cant-alias.rs14
-rw-r--r--src/test/ui/mut/mut-cant-alias.stderr13
-rw-r--r--src/test/ui/mut/mut-cross-borrowing.rs8
-rw-r--r--src/test/ui/mut/mut-cross-borrowing.stderr21
-rw-r--r--src/test/ui/mut/mut-pattern-internal-mutability.rs15
-rw-r--r--src/test/ui/mut/mut-pattern-internal-mutability.stderr25
-rw-r--r--src/test/ui/mut/mut-pattern-mismatched.rs20
-rw-r--r--src/test/ui/mut/mut-pattern-mismatched.stderr27
-rw-r--r--src/test/ui/mut/mut-ref.rs4
-rw-r--r--src/test/ui/mut/mut-ref.stderr8
-rw-r--r--src/test/ui/mut/mut-suggestion.rs22
-rw-r--r--src/test/ui/mut/mut-suggestion.stderr25
-rw-r--r--src/test/ui/mut/mutable-class-fields-2.rs24
-rw-r--r--src/test/ui/mut/mutable-class-fields-2.stderr14
-rw-r--r--src/test/ui/mut/mutable-class-fields.rs16
-rw-r--r--src/test/ui/mut/mutable-class-fields.stderr14
-rw-r--r--src/test/ui/mut/mutable-enum-indirect.rs19
-rw-r--r--src/test/ui/mut/mutable-enum-indirect.stderr24
-rw-r--r--src/test/ui/mut/no-mut-lint-for-desugared-mut.rs8
19 files changed, 0 insertions, 321 deletions
diff --git a/src/test/ui/mut/mut-cant-alias.rs b/src/test/ui/mut/mut-cant-alias.rs
deleted file mode 100644
index 9146b931a19..00000000000
--- a/src/test/ui/mut/mut-cant-alias.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use std::cell::RefCell;
-
-
-
-fn main() {
-    let m = RefCell::new(0);
-    let mut b = m.borrow_mut();
-    let b1 = &mut *b;
-    let b2 = &mut *b; //~ ERROR cannot borrow
-    b1.use_mut();
-}
-
-trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { }  }
-impl<T> Fake for T { }
diff --git a/src/test/ui/mut/mut-cant-alias.stderr b/src/test/ui/mut/mut-cant-alias.stderr
deleted file mode 100644
index 6046c076f2e..00000000000
--- a/src/test/ui/mut/mut-cant-alias.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0499]: cannot borrow `b` as mutable more than once at a time
-  --> $DIR/mut-cant-alias.rs:9:20
-   |
-LL |     let b1 = &mut *b;
-   |                    - first mutable borrow occurs here
-LL |     let b2 = &mut *b;
-   |                    ^ second mutable borrow occurs here
-LL |     b1.use_mut();
-   |     ------------ first borrow later used here
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0499`.
diff --git a/src/test/ui/mut/mut-cross-borrowing.rs b/src/test/ui/mut/mut-cross-borrowing.rs
deleted file mode 100644
index 080faab7326..00000000000
--- a/src/test/ui/mut/mut-cross-borrowing.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-fn f(_: &mut isize) {}
-
-fn main() {
-
-    let mut x: Box<_> = Box::new(3);
-
-    f(x)    //~ ERROR mismatched types
-}
diff --git a/src/test/ui/mut/mut-cross-borrowing.stderr b/src/test/ui/mut/mut-cross-borrowing.stderr
deleted file mode 100644
index ee739d6286a..00000000000
--- a/src/test/ui/mut/mut-cross-borrowing.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/mut-cross-borrowing.rs:7:7
-   |
-LL |     f(x)
-   |     - ^
-   |     | |
-   |     | expected `&mut isize`, found struct `Box`
-   |     | help: consider mutably borrowing here: `&mut x`
-   |     arguments to this function are incorrect
-   |
-   = note: expected mutable reference `&mut isize`
-                         found struct `Box<{integer}>`
-note: function defined here
-  --> $DIR/mut-cross-borrowing.rs:1:4
-   |
-LL | fn f(_: &mut isize) {}
-   |    ^ -------------
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.rs b/src/test/ui/mut/mut-pattern-internal-mutability.rs
deleted file mode 100644
index bcee878e389..00000000000
--- a/src/test/ui/mut/mut-pattern-internal-mutability.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-fn main() {
-    let foo = &mut 1;
-
-    let &mut x = foo;
-    x += 1; //~ ERROR cannot assign twice to immutable variable `x`
-
-    // explicitly mut-ify internals
-    let &mut mut x = foo;
-    x += 1;
-
-    // check borrowing is detected successfully
-    let &mut ref x = foo;
-    *foo += 1; //~ ERROR cannot assign to `*foo` because it is borrowed
-    drop(x);
-}
diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.stderr
deleted file mode 100644
index 6583546aa5c..00000000000
--- a/src/test/ui/mut/mut-pattern-internal-mutability.stderr
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0384]: cannot assign twice to immutable variable `x`
-  --> $DIR/mut-pattern-internal-mutability.rs:5:5
-   |
-LL |     let &mut x = foo;
-   |              -
-   |              |
-   |              first assignment to `x`
-   |              help: consider making this binding mutable: `mut x`
-LL |     x += 1;
-   |     ^^^^^^ cannot assign twice to immutable variable
-
-error[E0506]: cannot assign to `*foo` because it is borrowed
-  --> $DIR/mut-pattern-internal-mutability.rs:13:5
-   |
-LL |     let &mut ref x = foo;
-   |              ----- borrow of `*foo` occurs here
-LL |     *foo += 1;
-   |     ^^^^^^^^^ assignment to borrowed `*foo` occurs here
-LL |     drop(x);
-   |          - borrow later used here
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0384, E0506.
-For more information about an error, try `rustc --explain E0384`.
diff --git a/src/test/ui/mut/mut-pattern-mismatched.rs b/src/test/ui/mut/mut-pattern-mismatched.rs
deleted file mode 100644
index 700261fe40b..00000000000
--- a/src/test/ui/mut/mut-pattern-mismatched.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-fn main() {
-    let foo = &mut 1;
-
-    // (separate lines to ensure the spans are accurate)
-
-     let &_ //~  ERROR mismatched types
-            //~| expected mutable reference `&mut {integer}`
-            //~| found reference `&_`
-            //~| types differ in mutability
-        = foo;
-    let &mut _ = foo;
-
-    let bar = &1;
-    let &_ = bar;
-    let &mut _ //~  ERROR mismatched types
-               //~| expected reference `&{integer}`
-               //~| found mutable reference `&mut _`
-               //~| types differ in mutability
-         = bar;
-}
diff --git a/src/test/ui/mut/mut-pattern-mismatched.stderr b/src/test/ui/mut/mut-pattern-mismatched.stderr
deleted file mode 100644
index cad1cef5155..00000000000
--- a/src/test/ui/mut/mut-pattern-mismatched.stderr
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/mut-pattern-mismatched.rs:6:10
-   |
-LL |      let &_
-   |          ^^ types differ in mutability
-...
-LL |         = foo;
-   |           --- this expression has type `&mut {integer}`
-   |
-   = note: expected mutable reference `&mut {integer}`
-                      found reference `&_`
-
-error[E0308]: mismatched types
-  --> $DIR/mut-pattern-mismatched.rs:15:9
-   |
-LL |     let &mut _
-   |         ^^^^^^ types differ in mutability
-...
-LL |          = bar;
-   |            --- this expression has type `&{integer}`
-   |
-   = note:      expected reference `&{integer}`
-           found mutable reference `&mut _`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/mut/mut-ref.rs b/src/test/ui/mut/mut-ref.rs
deleted file mode 100644
index 80990b2bfde..00000000000
--- a/src/test/ui/mut/mut-ref.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-fn main() {
-    let mut ref x = 10; //~ ERROR the order of `mut` and `ref` is incorrect
-    let ref mut y = 11;
-}
diff --git a/src/test/ui/mut/mut-ref.stderr b/src/test/ui/mut/mut-ref.stderr
deleted file mode 100644
index e6d4901aafb..00000000000
--- a/src/test/ui/mut/mut-ref.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: the order of `mut` and `ref` is incorrect
-  --> $DIR/mut-ref.rs:2:9
-   |
-LL |     let mut ref x = 10;
-   |         ^^^^^^^ help: try switching the order: `ref mut`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/mut/mut-suggestion.rs b/src/test/ui/mut/mut-suggestion.rs
deleted file mode 100644
index 8c269d1e727..00000000000
--- a/src/test/ui/mut/mut-suggestion.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#[derive(Copy, Clone)]
-struct S;
-
-impl S {
-    fn mutate(&mut self) {
-    }
-}
-
-fn func(arg: S) {
-    //~^ HELP consider changing this to be mutable
-    //~| SUGGESTION mut
-    arg.mutate();
-    //~^ ERROR cannot borrow `arg` as mutable, as it is not declared as mutable
-}
-
-fn main() {
-    let local = S;
-    //~^ HELP consider changing this to be mutable
-    //~| SUGGESTION mut
-    local.mutate();
-    //~^ ERROR cannot borrow `local` as mutable, as it is not declared as mutable
-}
diff --git a/src/test/ui/mut/mut-suggestion.stderr b/src/test/ui/mut/mut-suggestion.stderr
deleted file mode 100644
index d89c8b41304..00000000000
--- a/src/test/ui/mut/mut-suggestion.stderr
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
-  --> $DIR/mut-suggestion.rs:12:5
-   |
-LL |     arg.mutate();
-   |     ^^^^^^^^^^^^ cannot borrow as mutable
-   |
-help: consider changing this to be mutable
-   |
-LL | fn func(mut arg: S) {
-   |         +++
-
-error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable
-  --> $DIR/mut-suggestion.rs:20:5
-   |
-LL |     local.mutate();
-   |     ^^^^^^^^^^^^^^ cannot borrow as mutable
-   |
-help: consider changing this to be mutable
-   |
-LL |     let mut local = S;
-   |         +++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0596`.
diff --git a/src/test/ui/mut/mutable-class-fields-2.rs b/src/test/ui/mut/mutable-class-fields-2.rs
deleted file mode 100644
index 30e54dfc9cd..00000000000
--- a/src/test/ui/mut/mutable-class-fields-2.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-struct Cat {
-  meows : usize,
-
-  how_hungry : isize,
-}
-
-impl Cat {
-  pub fn eat(&self) {
-    self.how_hungry -= 5; //~ ERROR cannot assign
-  }
-
-}
-
-fn cat(in_x : usize, in_y : isize) -> Cat {
-    Cat {
-        meows: in_x,
-        how_hungry: in_y
-    }
-}
-
-fn main() {
-  let nyan : Cat = cat(52, 99);
-  nyan.eat();
-}
diff --git a/src/test/ui/mut/mutable-class-fields-2.stderr b/src/test/ui/mut/mutable-class-fields-2.stderr
deleted file mode 100644
index c53c6ea302c..00000000000
--- a/src/test/ui/mut/mutable-class-fields-2.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0594]: cannot assign to `self.how_hungry`, which is behind a `&` reference
-  --> $DIR/mutable-class-fields-2.rs:9:5
-   |
-LL |     self.how_hungry -= 5;
-   |     ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
-   |
-help: consider changing this to be a mutable reference
-   |
-LL |   pub fn eat(&mut self) {
-   |              ~~~~~~~~~
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/mut/mutable-class-fields.rs b/src/test/ui/mut/mutable-class-fields.rs
deleted file mode 100644
index 30768a1ec9b..00000000000
--- a/src/test/ui/mut/mutable-class-fields.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-struct Cat {
-  meows : usize,
-  how_hungry : isize,
-}
-
-fn cat(in_x : usize, in_y : isize) -> Cat {
-    Cat {
-        meows: in_x,
-        how_hungry: in_y
-    }
-}
-
-fn main() {
-  let nyan : Cat = cat(52, 99);
-  nyan.how_hungry = 0; //~ ERROR cannot assign
-}
diff --git a/src/test/ui/mut/mutable-class-fields.stderr b/src/test/ui/mut/mutable-class-fields.stderr
deleted file mode 100644
index 1d731be8a85..00000000000
--- a/src/test/ui/mut/mutable-class-fields.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0594]: cannot assign to `nyan.how_hungry`, as `nyan` is not declared as mutable
-  --> $DIR/mutable-class-fields.rs:15:3
-   |
-LL |   nyan.how_hungry = 0;
-   |   ^^^^^^^^^^^^^^^^^^^ cannot assign
-   |
-help: consider changing this to be mutable
-   |
-LL |   let mut nyan : Cat = cat(52, 99);
-   |       +++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/mut/mutable-enum-indirect.rs b/src/test/ui/mut/mutable-enum-indirect.rs
deleted file mode 100644
index 502859c0413..00000000000
--- a/src/test/ui/mut/mutable-enum-indirect.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Tests that an `&` pointer to something inherently mutable is itself
-// to be considered mutable.
-
-#![feature(negative_impls)]
-
-use std::marker::Sync;
-
-struct NoSync;
-impl !Sync for NoSync {}
-
-enum Foo { A(NoSync) }
-
-fn bar<T: Sync>(_: T) {}
-
-fn main() {
-    let x = Foo::A(NoSync);
-    bar(&x);
-    //~^ ERROR `NoSync` cannot be shared between threads safely [E0277]
-}
diff --git a/src/test/ui/mut/mutable-enum-indirect.stderr b/src/test/ui/mut/mutable-enum-indirect.stderr
deleted file mode 100644
index 9e1f4e1fe4e..00000000000
--- a/src/test/ui/mut/mutable-enum-indirect.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-error[E0277]: `NoSync` cannot be shared between threads safely
-  --> $DIR/mutable-enum-indirect.rs:17:9
-   |
-LL |     bar(&x);
-   |     --- ^^ `NoSync` cannot be shared between threads safely
-   |     |
-   |     required by a bound introduced by this call
-   |
-   = help: within `&Foo`, the trait `Sync` is not implemented for `NoSync`
-note: required because it appears within the type `Foo`
-  --> $DIR/mutable-enum-indirect.rs:11:6
-   |
-LL | enum Foo { A(NoSync) }
-   |      ^^^
-   = note: required because it appears within the type `&Foo`
-note: required by a bound in `bar`
-  --> $DIR/mutable-enum-indirect.rs:13:11
-   |
-LL | fn bar<T: Sync>(_: T) {}
-   |           ^^^^ required by this bound in `bar`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs b/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs
deleted file mode 100644
index 419d580419f..00000000000
--- a/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-// run-pass
-
-#![deny(unused_mut)]
-#![allow(unreachable_code)]
-
-fn main() {
-    for _ in { return (); 0..3 } {} // ok
-}