summaryrefslogtreecommitdiffstats
path: root/src/test/ui/mut
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/mut
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/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.stderr21
-rw-r--r--src/test/ui/mut/mutable-class-fields-2.rs24
-rw-r--r--src/test/ui/mut/mutable-class-fields-2.stderr11
-rw-r--r--src/test/ui/mut/mutable-class-fields.rs16
-rw-r--r--src/test/ui/mut/mutable-class-fields.stderr11
-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, 311 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 9146b931a..000000000
--- 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 6046c076f..000000000
--- 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 080faab73..000000000
--- 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 ee739d628..000000000
--- 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 bcee878e3..000000000
--- 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 6583546aa..000000000
--- 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 700261fe4..000000000
--- 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 cad1cef51..000000000
--- 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 80990b2bf..000000000
--- 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 e6d4901aa..000000000
--- 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 3104b20ac..000000000
--- 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
- 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
- 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 cba284550..000000000
--- a/src/test/ui/mut/mut-suggestion.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
- --> $DIR/mut-suggestion.rs:12:5
- |
-LL | fn func(arg: S) {
- | --- help: consider changing this to be mutable: `mut arg`
-...
-LL | arg.mutate();
- | ^^^^^^^^^^^^ cannot borrow as mutable
-
-error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable
- --> $DIR/mut-suggestion.rs:20:5
- |
-LL | let local = S;
- | ----- help: consider changing this to be mutable: `mut local`
-...
-LL | local.mutate();
- | ^^^^^^^^^^^^^^ cannot borrow as mutable
-
-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 30e54dfc9..000000000
--- 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 5a4e31947..000000000
--- a/src/test/ui/mut/mutable-class-fields-2.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0594]: cannot assign to `self.how_hungry`, which is behind a `&` reference
- --> $DIR/mutable-class-fields-2.rs:9:5
- |
-LL | pub fn eat(&self) {
- | ----- help: consider changing this to be a mutable reference: `&mut self`
-LL | self.how_hungry -= 5;
- | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
-
-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 30768a1ec..000000000
--- 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 40a0dc9b2..000000000
--- a/src/test/ui/mut/mutable-class-fields.stderr
+++ /dev/null
@@ -1,11 +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 | let nyan : Cat = cat(52, 99);
- | ---- help: consider changing this to be mutable: `mut nyan`
-LL | nyan.how_hungry = 0;
- | ^^^^^^^^^^^^^^^^^^^ cannot assign
-
-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 502859c04..000000000
--- 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 9e1f4e1fe..000000000
--- 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 419d58041..000000000
--- 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
-}