summaryrefslogtreecommitdiffstats
path: root/src/test/ui/str
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/str
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/str')
-rw-r--r--src/test/ui/str/str-array-assignment.rs11
-rw-r--r--src/test/ui/str/str-array-assignment.stderr45
-rw-r--r--src/test/ui/str/str-as-char.fixed5
-rw-r--r--src/test/ui/str/str-as-char.rs5
-rw-r--r--src/test/ui/str/str-as-char.stderr13
-rw-r--r--src/test/ui/str/str-concat-on-double-ref.rs7
-rw-r--r--src/test/ui/str/str-concat-on-double-ref.stderr18
-rw-r--r--src/test/ui/str/str-escape.rs11
-rw-r--r--src/test/ui/str/str-escape.stderr21
-rw-r--r--src/test/ui/str/str-idx.rs7
-rw-r--r--src/test/ui/str/str-idx.stderr60
-rw-r--r--src/test/ui/str/str-lit-type-mismatch.rs5
-rw-r--r--src/test/ui/str/str-lit-type-mismatch.stderr49
-rw-r--r--src/test/ui/str/str-mut-idx.rs17
-rw-r--r--src/test/ui/str/str-mut-idx.stderr84
-rw-r--r--src/test/ui/str/str-overrun.rs10
16 files changed, 0 insertions, 368 deletions
diff --git a/src/test/ui/str/str-array-assignment.rs b/src/test/ui/str/str-array-assignment.rs
deleted file mode 100644
index 323eefb38..000000000
--- a/src/test/ui/str/str-array-assignment.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-fn main() {
- let s = "abc";
- let t = if true { s[..2] } else { s };
- //~^ ERROR `if` and `else` have incompatible types
- let u: &str = if true { s[..2] } else { s };
- //~^ ERROR mismatched types
- let v = s[..2];
- //~^ ERROR the size for values of type
- let w: &str = s[..2];
- //~^ ERROR mismatched types
-}
diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr
deleted file mode 100644
index c23400a1d..000000000
--- a/src/test/ui/str/str-array-assignment.stderr
+++ /dev/null
@@ -1,45 +0,0 @@
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/str-array-assignment.rs:3:37
- |
-LL | let t = if true { s[..2] } else { s };
- | ------ ^ expected `str`, found `&str`
- | |
- | expected because of this
-
-error[E0308]: mismatched types
- --> $DIR/str-array-assignment.rs:5:27
- |
-LL | let u: &str = if true { s[..2] } else { s };
- | ^^^^^^
- | |
- | expected `&str`, found `str`
- | help: consider borrowing here: `&s[..2]`
-
-error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/str-array-assignment.rs:7:7
- |
-LL | let v = s[..2];
- | ^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `str`
- = note: all local variables must have a statically known size
- = help: unsized locals are gated as an unstable feature
-help: consider borrowing here
- |
-LL | let v = &s[..2];
- | +
-
-error[E0308]: mismatched types
- --> $DIR/str-array-assignment.rs:9:17
- |
-LL | let w: &str = s[..2];
- | ---- ^^^^^^
- | | |
- | | expected `&str`, found `str`
- | | help: consider borrowing here: `&s[..2]`
- | expected due to this
-
-error: aborting due to 4 previous errors
-
-Some errors have detailed explanations: E0277, E0308.
-For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/str/str-as-char.fixed b/src/test/ui/str/str-as-char.fixed
deleted file mode 100644
index 42bbef839..000000000
--- a/src/test/ui/str/str-as-char.fixed
+++ /dev/null
@@ -1,5 +0,0 @@
-// run-rustfix
-
-fn main() {
- println!("●●"); //~ ERROR character literal may only contain one codepoint
-}
diff --git a/src/test/ui/str/str-as-char.rs b/src/test/ui/str/str-as-char.rs
deleted file mode 100644
index 09b9dfc59..000000000
--- a/src/test/ui/str/str-as-char.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-// run-rustfix
-
-fn main() {
- println!('●●'); //~ ERROR character literal may only contain one codepoint
-}
diff --git a/src/test/ui/str/str-as-char.stderr b/src/test/ui/str/str-as-char.stderr
deleted file mode 100644
index c3cb488e3..000000000
--- a/src/test/ui/str/str-as-char.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error: character literal may only contain one codepoint
- --> $DIR/str-as-char.rs:4:14
- |
-LL | println!('●●');
- | ^^^^
- |
-help: if you meant to write a `str` literal, use double quotes
- |
-LL | println!("●●");
- | ~~~~
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/str/str-concat-on-double-ref.rs b/src/test/ui/str/str-concat-on-double-ref.rs
deleted file mode 100644
index e68210d53..000000000
--- a/src/test/ui/str/str-concat-on-double-ref.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-fn main() {
- let a: &String = &"1".to_owned();
- let b: &str = &"2";
- let c = a + b;
- //~^ ERROR cannot add `&str` to `&String`
- println!("{:?}", c);
-}
diff --git a/src/test/ui/str/str-concat-on-double-ref.stderr b/src/test/ui/str/str-concat-on-double-ref.stderr
deleted file mode 100644
index bd354679f..000000000
--- a/src/test/ui/str/str-concat-on-double-ref.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error[E0369]: cannot add `&str` to `&String`
- --> $DIR/str-concat-on-double-ref.rs:4:15
- |
-LL | let c = a + b;
- | - ^ - &str
- | | |
- | | `+` cannot be used to concatenate two `&str` strings
- | &String
- |
- = note: string concatenation requires an owned `String` on the left
-help: create an owned `String` from a string reference
- |
-LL | let c = a.to_owned() + b;
- | +++++++++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0369`.
diff --git a/src/test/ui/str/str-escape.rs b/src/test/ui/str/str-escape.rs
deleted file mode 100644
index 0264632fd..000000000
--- a/src/test/ui/str/str-escape.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// check-pass
-fn main() {
- let s = "\
-
- ";
- //~^^^ WARNING multiple lines skipped by escaped newline
- let s = "foo\
-   bar
- ";
- //~^^^ WARNING non-ASCII whitespace symbol '\u{a0}' is not skipped
-}
diff --git a/src/test/ui/str/str-escape.stderr b/src/test/ui/str/str-escape.stderr
deleted file mode 100644
index b2501f1a2..000000000
--- a/src/test/ui/str/str-escape.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-warning: multiple lines skipped by escaped newline
- --> $DIR/str-escape.rs:3:14
- |
-LL | let s = "\
- | ______________^
-LL | |
-LL | | ";
- | |_____________^ skipping everything up to and including this point
-
-warning: non-ASCII whitespace symbol '\u{a0}' is not skipped
- --> $DIR/str-escape.rs:7:17
- |
-LL | let s = "foo\
- | _________________^
-LL | |   bar
- | | ^ non-ASCII whitespace symbol '\u{a0}' is not skipped
- | |___|
- |
-
-warning: 2 warnings emitted
-
diff --git a/src/test/ui/str/str-idx.rs b/src/test/ui/str/str-idx.rs
deleted file mode 100644
index 1b32ed553..000000000
--- a/src/test/ui/str/str-idx.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-pub fn main() {
- let s: &str = "hello";
- let _: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}`
- let _ = s.get(4); //~ ERROR the type `str` cannot be indexed by `{integer}`
- let _ = s.get_unchecked(4); //~ ERROR the type `str` cannot be indexed by `{integer}`
- let _: u8 = s['c']; //~ ERROR the type `str` cannot be indexed by `char`
-}
diff --git a/src/test/ui/str/str-idx.stderr b/src/test/ui/str/str-idx.stderr
deleted file mode 100644
index 019305def..000000000
--- a/src/test/ui/str/str-idx.stderr
+++ /dev/null
@@ -1,60 +0,0 @@
-error[E0277]: the type `str` cannot be indexed by `{integer}`
- --> $DIR/str-idx.rs:3:19
- |
-LL | let _: u8 = s[4];
- | ^ string indices are ranges of `usize`
- |
- = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
- = note: you can use `.chars().nth()` or `.bytes().nth()`
- for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
- = note: required for `str` to implement `Index<{integer}>`
-
-error[E0277]: the type `str` cannot be indexed by `{integer}`
- --> $DIR/str-idx.rs:4:19
- |
-LL | let _ = s.get(4);
- | --- ^ string indices are ranges of `usize`
- | |
- | required by a bound introduced by this call
- |
- = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
- = note: you can use `.chars().nth()` or `.bytes().nth()`
- for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
-note: required by a bound in `core::str::<impl str>::get`
- --> $SRC_DIR/core/src/str/mod.rs:LL:COL
- |
-LL | pub const fn get<I: ~const SliceIndex<str>>(&self, i: I) -> Option<&I::Output> {
- | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get`
-
-error[E0277]: the type `str` cannot be indexed by `{integer}`
- --> $DIR/str-idx.rs:5:29
- |
-LL | let _ = s.get_unchecked(4);
- | ------------- ^ string indices are ranges of `usize`
- | |
- | required by a bound introduced by this call
- |
- = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
- = note: you can use `.chars().nth()` or `.bytes().nth()`
- for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
-note: required by a bound in `core::str::<impl str>::get_unchecked`
- --> $SRC_DIR/core/src/str/mod.rs:LL:COL
- |
-LL | pub const unsafe fn get_unchecked<I: ~const SliceIndex<str>>(&self, i: I) -> &I::Output {
- | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get_unchecked`
-
-error[E0277]: the type `str` cannot be indexed by `char`
- --> $DIR/str-idx.rs:6:19
- |
-LL | let _: u8 = s['c'];
- | ^^^ string indices are ranges of `usize`
- |
- = help: the trait `SliceIndex<str>` is not implemented for `char`
- = note: required for `str` to implement `Index<char>`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/str/str-lit-type-mismatch.rs b/src/test/ui/str/str-lit-type-mismatch.rs
deleted file mode 100644
index 12637c7b9..000000000
--- a/src/test/ui/str/str-lit-type-mismatch.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
- let x: &[u8] = "foo"; //~ ERROR mismatched types
- let y: &[u8; 4] = "baaa"; //~ ERROR mismatched types
- let z: &str = b"foo"; //~ ERROR mismatched types
-}
diff --git a/src/test/ui/str/str-lit-type-mismatch.stderr b/src/test/ui/str/str-lit-type-mismatch.stderr
deleted file mode 100644
index 6b56cd6f3..000000000
--- a/src/test/ui/str/str-lit-type-mismatch.stderr
+++ /dev/null
@@ -1,49 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/str-lit-type-mismatch.rs:2:20
- |
-LL | let x: &[u8] = "foo";
- | ----- ^^^^^ expected slice `[u8]`, found `str`
- | |
- | expected due to this
- |
- = note: expected reference `&[u8]`
- found reference `&'static str`
-help: consider adding a leading `b`
- |
-LL | let x: &[u8] = b"foo";
- | +
-
-error[E0308]: mismatched types
- --> $DIR/str-lit-type-mismatch.rs:3:23
- |
-LL | let y: &[u8; 4] = "baaa";
- | -------- ^^^^^^ expected array `[u8; 4]`, found `str`
- | |
- | expected due to this
- |
- = note: expected reference `&[u8; 4]`
- found reference `&'static str`
-help: consider adding a leading `b`
- |
-LL | let y: &[u8; 4] = b"baaa";
- | +
-
-error[E0308]: mismatched types
- --> $DIR/str-lit-type-mismatch.rs:4:19
- |
-LL | let z: &str = b"foo";
- | ---- ^^^^^^ expected `str`, found array `[u8; 3]`
- | |
- | expected due to this
- |
- = note: expected reference `&str`
- found reference `&'static [u8; 3]`
-help: consider removing the leading `b`
- |
-LL - let z: &str = b"foo";
-LL + let z: &str = "foo";
- |
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/str/str-mut-idx.rs b/src/test/ui/str/str-mut-idx.rs
deleted file mode 100644
index 575a9eae8..000000000
--- a/src/test/ui/str/str-mut-idx.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-fn bot<T>() -> T { loop {} }
-
-fn mutate(s: &mut str) {
- s[1..2] = bot();
- //~^ ERROR the size for values of type
- //~| ERROR the size for values of type
- s[1usize] = bot();
- //~^ ERROR the type `str` cannot be indexed by `usize`
- s.get_mut(1);
- //~^ ERROR the type `str` cannot be indexed by `{integer}`
- s.get_unchecked_mut(1);
- //~^ ERROR the type `str` cannot be indexed by `{integer}`
- s['c'];
- //~^ ERROR the type `str` cannot be indexed by `char`
-}
-
-pub fn main() {}
diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr
deleted file mode 100644
index b165c4825..000000000
--- a/src/test/ui/str/str-mut-idx.stderr
+++ /dev/null
@@ -1,84 +0,0 @@
-error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/str-mut-idx.rs:4:15
- |
-LL | s[1..2] = bot();
- | ^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `str`
-note: required by a bound in `bot`
- --> $DIR/str-mut-idx.rs:1:8
- |
-LL | fn bot<T>() -> T { loop {} }
- | ^ required by this bound in `bot`
-help: consider relaxing the implicit `Sized` restriction
- |
-LL | fn bot<T: ?Sized>() -> T { loop {} }
- | ++++++++
-
-error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/str-mut-idx.rs:4:5
- |
-LL | s[1..2] = bot();
- | ^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `str`
- = note: the left-hand-side of an assignment must have a statically known size
-
-error[E0277]: the type `str` cannot be indexed by `usize`
- --> $DIR/str-mut-idx.rs:7:7
- |
-LL | s[1usize] = bot();
- | ^^^^^^ string indices are ranges of `usize`
- |
- = help: the trait `SliceIndex<str>` is not implemented for `usize`
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
- = note: required for `str` to implement `Index<usize>`
-
-error[E0277]: the type `str` cannot be indexed by `{integer}`
- --> $DIR/str-mut-idx.rs:9:15
- |
-LL | s.get_mut(1);
- | ------- ^ string indices are ranges of `usize`
- | |
- | required by a bound introduced by this call
- |
- = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
- = note: you can use `.chars().nth()` or `.bytes().nth()`
- for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
-note: required by a bound in `core::str::<impl str>::get_mut`
- --> $SRC_DIR/core/src/str/mod.rs:LL:COL
- |
-LL | pub const fn get_mut<I: ~const SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> {
- | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get_mut`
-
-error[E0277]: the type `str` cannot be indexed by `{integer}`
- --> $DIR/str-mut-idx.rs:11:25
- |
-LL | s.get_unchecked_mut(1);
- | ----------------- ^ string indices are ranges of `usize`
- | |
- | required by a bound introduced by this call
- |
- = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
- = note: you can use `.chars().nth()` or `.bytes().nth()`
- for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
-note: required by a bound in `core::str::<impl str>::get_unchecked_mut`
- --> $SRC_DIR/core/src/str/mod.rs:LL:COL
- |
-LL | pub const unsafe fn get_unchecked_mut<I: ~const SliceIndex<str>>(
- | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get_unchecked_mut`
-
-error[E0277]: the type `str` cannot be indexed by `char`
- --> $DIR/str-mut-idx.rs:13:7
- |
-LL | s['c'];
- | ^^^ string indices are ranges of `usize`
- |
- = help: the trait `SliceIndex<str>` is not implemented for `char`
- = note: required for `str` to implement `Index<char>`
-
-error: aborting due to 6 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/str/str-overrun.rs b/src/test/ui/str/str-overrun.rs
deleted file mode 100644
index a3ec89413..000000000
--- a/src/test/ui/str/str-overrun.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// run-fail
-// error-pattern:index out of bounds: the len is 5 but the index is 5
-// ignore-emscripten no processes
-
-fn main() {
- let s: String = "hello".to_string();
-
- // Bounds-check panic.
- assert_eq!(s.as_bytes()[5], 0x0 as u8);
-}