about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-04 19:51:52 +0000
committerbors <bors@rust-lang.org>2022-04-04 19:51:52 +0000
commit60e50fc1cfe0bb693a5f4f93eb83ef70854531e3 (patch)
tree12ff676ece8a495b1c327d875d999f96ac738e94 /src/test
parent6a9080b25e73d26aae94c3f6a13b31de58e66b5a (diff)
parent0c5f8792037e860351ddb7c5cd9e6761d2bba704 (diff)
Auto merge of #95653 - Dylan-DPC:rollup-2p9hzi3, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #92942 (stabilize windows_process_extensions_raw_arg)
 - #94817 (Release notes for 1.60.0)
 - #95343 (Reduce unnecessary escaping in proc_macro::Literal::character/string)
 - #95431 (Stabilize total_cmp)
 - #95438 (Add SyncUnsafeCell.)
 - #95467 (Windows: Synchronize asynchronous pipe reads and writes)
 - #95609 (Suggest borrowing when trying to coerce unsized type into `dyn Trait`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/issues/issue-14366.stderr4
-rw-r--r--src/test/ui/mismatched_types/cast-rfc0401.stderr8
-rw-r--r--src/test/ui/proc-macro/auxiliary/api/parse.rs11
-rw-r--r--src/test/ui/proc-macro/quote-debug.stdout4
-rw-r--r--src/test/ui/unsized/unsized-fn-param.stderr16
5 files changed, 41 insertions, 2 deletions
diff --git a/src/test/ui/issues/issue-14366.stderr b/src/test/ui/issues/issue-14366.stderr
index d5dab561dde..b96b07c91a1 100644
--- a/src/test/ui/issues/issue-14366.stderr
+++ b/src/test/ui/issues/issue-14366.stderr
@@ -6,6 +6,10 @@ LL |     let _x = "test" as &dyn (::std::any::Any);
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: required for the cast to the object type `dyn Any`
+help: consider borrowing the value, since `&str` can be coerced into `dyn Any`
+   |
+LL |     let _x = &"test" as &dyn (::std::any::Any);
+   |              +
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr
index 5f11e4ded80..84220ea172a 100644
--- a/src/test/ui/mismatched_types/cast-rfc0401.stderr
+++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr
@@ -224,6 +224,10 @@ LL |     let _ = fat_v as *const dyn Foo;
    |
    = help: the trait `Sized` is not implemented for `[u8]`
    = note: required for the cast to the object type `dyn Foo`
+help: consider borrowing the value, since `&[u8]` can be coerced into `dyn Foo`
+   |
+LL |     let _ = &fat_v as *const dyn Foo;
+   |             +
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/cast-rfc0401.rs:62:13
@@ -233,6 +237,10 @@ LL |     let _ = a as *const dyn Foo;
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: required for the cast to the object type `dyn Foo`
+help: consider borrowing the value, since `&str` can be coerced into `dyn Foo`
+   |
+LL |     let _ = &a as *const dyn Foo;
+   |             +
 
 error[E0606]: casting `&{float}` as `f32` is invalid
   --> $DIR/cast-rfc0401.rs:71:30
diff --git a/src/test/ui/proc-macro/auxiliary/api/parse.rs b/src/test/ui/proc-macro/auxiliary/api/parse.rs
index 6186b941ef6..27391f83111 100644
--- a/src/test/ui/proc-macro/auxiliary/api/parse.rs
+++ b/src/test/ui/proc-macro/auxiliary/api/parse.rs
@@ -18,6 +18,17 @@ fn test_display_literal() {
         Literal::f64_unsuffixed(1e100).to_string(),
         "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0",
     );
+
+    assert_eq!(
+        Literal::string("a \t ❤ ' \" \u{1}").to_string(),
+        "\"a \\t ❤ ' \\\" \\u{1}\"",
+    );
+    assert_eq!(Literal::character('a').to_string(), "'a'");
+    assert_eq!(Literal::character('\t').to_string(), "'\\t'");
+    assert_eq!(Literal::character('❤').to_string(), "'❤'");
+    assert_eq!(Literal::character('\'').to_string(), "'\\''");
+    assert_eq!(Literal::character('"').to_string(), "'\"'");
+    assert_eq!(Literal::character('\u{1}').to_string(), "'\\u{1}'");
 }
 
 fn test_parse_literal() {
diff --git a/src/test/ui/proc-macro/quote-debug.stdout b/src/test/ui/proc-macro/quote-debug.stdout
index ec54851fcf9..d2cc5c6e2a3 100644
--- a/src/test/ui/proc-macro/quote-debug.stdout
+++ b/src/test/ui/proc-macro/quote-debug.stdout
@@ -22,7 +22,7 @@ fn main() {
                                     crate::Span::recover_proc_macro_span(0)))),
                         crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("hello",
                                     crate::Span::recover_proc_macro_span(1)))),
-                        crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3d}',
+                        crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('=',
                                     crate::Spacing::Alone))),
                         crate::TokenStream::from(crate::TokenTree::Literal({
                                     let mut iter =
@@ -35,7 +35,7 @@ fn main() {
                                            ::core::panicking::panic("internal error: entered unreachable code")
                                        }
                                 })),
-                        crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3b}',
+                        crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new(';',
                                     crate::Spacing::Alone)))].iter().cloned().collect::<crate::TokenStream>()
 }
 const _: () =
diff --git a/src/test/ui/unsized/unsized-fn-param.stderr b/src/test/ui/unsized/unsized-fn-param.stderr
index b498259efe7..3eecca0fa09 100644
--- a/src/test/ui/unsized/unsized-fn-param.stderr
+++ b/src/test/ui/unsized/unsized-fn-param.stderr
@@ -6,6 +6,10 @@ LL |     foo11("bar", &"baz");
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: required for the cast to the object type `dyn AsRef<Path>`
+help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<Path>`
+   |
+LL |     foo11(&"bar", &"baz");
+   |           +
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/unsized-fn-param.rs:13:19
@@ -15,6 +19,10 @@ LL |     foo12(&"bar", "baz");
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: required for the cast to the object type `dyn AsRef<Path>`
+help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<Path>`
+   |
+LL |     foo12(&"bar", &"baz");
+   |                   +
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/unsized-fn-param.rs:16:11
@@ -24,6 +32,10 @@ LL |     foo21("bar", &"baz");
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: required for the cast to the object type `dyn AsRef<str>`
+help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<str>`
+   |
+LL |     foo21(&"bar", &"baz");
+   |           +
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/unsized-fn-param.rs:18:19
@@ -33,6 +45,10 @@ LL |     foo22(&"bar", "baz");
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: required for the cast to the object type `dyn AsRef<str>`
+help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<str>`
+   |
+LL |     foo22(&"bar", &"baz");
+   |                   +
 
 error: aborting due to 4 previous errors