]> git.lizzy.rs Git - rust.git/commitdiff
wording improvement
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 9 Jun 2017 20:04:29 +0000 (22:04 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 24 Jun 2017 19:28:08 +0000 (21:28 +0200)
17 files changed:
src/librustc_typeck/check/cast.rs
src/librustc_typeck/diagnostics.rs
src/test/compile-fail/cast-from-nil.rs
src/test/compile-fail/cast-to-bare-fn.rs
src/test/compile-fail/cast-to-nil.rs
src/test/compile-fail/closure-no-fn-3.rs
src/test/compile-fail/coerce-to-bang-cast.rs
src/test/compile-fail/fat-ptr-cast.rs
src/test/compile-fail/issue-10991.rs
src/test/compile-fail/issue-22289.rs
src/test/compile-fail/issue-22312.rs
src/test/compile-fail/issue-2995.rs
src/test/compile-fail/nonscalar-cast.rs
src/test/compile-fail/tag-variant-cast-non-nullary.rs
src/test/compile-fail/uninhabited-enum-cast.rs
src/test/ui/mismatched_types/cast-rfc0401.stderr
src/test/ui/mismatched_types/issue-26480.stderr

index 52962e1e478c07adfd0c11e4e7ea68f55f620927..aec9d6f16d24f802e7ef3cc1c5fcac3192684a53 100644 (file)
@@ -217,7 +217,7 @@ fn report_cast_error(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, e: CastError) {
             }
             CastError::NonScalar => {
                 struct_span_err!(fcx.tcx.sess, self.span, E0605,
-                                 "non-scalar cast: `{}` as `{}`",
+                                 "non-primitive cast: `{}` as `{}`",
                                  self.expr_ty,
                                  fcx.ty_to_string(self.cast_ty))
                                 .note("an `as` expression can only be used to convert between \
index ae13e236743dd525f5f6ee86668100c893e98be0..f9b44f0395fc423a548c14a0948d3576a8a66f7a 100644 (file)
@@ -4209,7 +4209,7 @@ trait was performed.
 "##,
 
 E0604: r##"
-A cast to `char` was attempted on another type than `u8`.
+A cast to `char` was attempted on a type other than `u8`.
 
 Erroneous code example:
 
@@ -4217,11 +4217,11 @@ trait was performed.
 0u32 as char; // error: only `u8` can be cast as `char`, not `u32`
 ```
 
-As the error message indicates, only `u8` can be casted into `char`. Example:
+As the error message indicates, only `u8` can be cast into `char`. Example:
 
 ```
 let c = 86u8 as char; // ok!
-assert!(c, 'V');
+assert_eq!(c, 'V');
 ```
 "##,
 
@@ -4232,15 +4232,15 @@ trait was performed.
 
 ```compile_fail,E0605
 let x = 0u8;
-x as Vec<u8>; // error: non-scalar cast: `u8` as `std::vec::Vec<u8>`
+x as Vec<u8>; // error: non-primitive cast: `u8` as `std::vec::Vec<u8>`
 
 // Another example
 
 let v = 0 as *const u8; // So here, `v` is a `*const u8`.
-v as &u8; // error: non-scalar cast: `*const u8` as `&u8`
+v as &u8; // error: non-primitive cast: `*const u8` as `&u8`
 ```
 
-Only primitive types cast be casted into each others. Examples:
+Only primitive types can be cast into each other. Examples:
 
 ```
 let x = 0u8;
@@ -4261,8 +4261,8 @@ trait was performed.
 let y: u32 = x as u32; // error: casting `&u8` as `u32` is invalid
 ```
 
-When casting, keep in mind that only primitive types cast be casted into each
-others. Example:
+When casting, keep in mind that only primitive types can be cast into each
+other. Example:
 
 ```
 let x = &0u8;
@@ -4282,15 +4282,16 @@ trait was performed.
 
 First: what are thin and fat pointers?
 
-Thin pointers are "simple" pointers that simply reference a memory address.
+Thin pointers are "simple" pointers: they are purely a reference to a memory
+address.
 
 Fat pointers are pointers referencing Dynamically Sized Types (also called DST).
-They don't have a statically known size, therefore they can only exist behind
+DST don't have a statically known size, therefore they can only exist behind
 some kind of pointers that contain additional information. Slices and trait
-objects are DSTs.
+objects are DSTs. In the case of slices, the additional information the fat
+pointer holds is their size.
 
-So in order to fix this error, don't try to cast directly between thin and fat
-pointers.
+To fix this error, don't try to cast directly between thin and fat pointers.
 "##,
 
 E0609: r##"
index 4c6dcaccc9aed5347cb85f94cd456c982f56e724..ab22d352480739d3fe27520993523b4df654acf5 100644 (file)
@@ -8,5 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: non-scalar cast: `()` as `u32`
+// error-pattern: non-primitive cast: `()` as `u32`
 fn main() { let u = (assert!(true) as u32); }
index 7cc5c727bc7df786e045124167adf0757df82167..d5a998c6e4b6b944884c6135beac62f29cf74742 100644 (file)
@@ -13,8 +13,8 @@ fn foo(_x: isize) { }
 fn main() {
     let v: u64 = 5;
     let x = foo as extern "C" fn() -> isize;
-    //~^ ERROR non-scalar cast
+    //~^ ERROR non-primitive cast
     let y = v as extern "Rust" fn(isize) -> (isize, isize);
-    //~^ ERROR non-scalar cast
+    //~^ ERROR non-primitive cast
     y(x());
 }
index e5fd5bb33eb908978d6f77f82b7354fabc6fdc17..27d9e8a42b188c58759ff50ac7410f893d33cf65 100644 (file)
@@ -8,5 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: non-scalar cast: `u32` as `()`
+// error-pattern: non-primitive cast: `u32` as `()`
 fn main() { let u = 0u32 as (); }
index 85dbc899208f6f95e7b3c8096a4122d0982355f8..6584c16c9dec67cfdbb3d6966dcb56d6ada51b10 100644 (file)
@@ -14,5 +14,5 @@
 fn main() {
     let b = 0u8;
     let baz: fn() -> u8 = (|| { b }) as fn() -> u8;
-    //~^ ERROR non-scalar cast
+    //~^ ERROR non-primitive cast
 }
index 57d2192e6356b854d3e53db7ad85ed526874f649..0479f5cce65379ed73bd43b46f1356bde316f564 100644 (file)
@@ -17,7 +17,7 @@ fn cast_a() {
 }
 
 fn cast_b() {
-    let y = 22 as !; //~ ERROR non-scalar cast
+    let y = 22 as !; //~ ERROR non-primitive cast
 }
 
 fn main() { }
index c62987a5b900e60c637858a63374061934adcc53..bc2dc1cc5d4c83923f349f8062462af9bc79f020 100644 (file)
@@ -22,7 +22,7 @@ fn main() {
     a as isize; //~ ERROR casting
     a as i16; //~ ERROR casting `&[i32]` as `i16` is invalid
     a as u32; //~ ERROR casting `&[i32]` as `u32` is invalid
-    b as usize; //~ ERROR non-scalar cast
+    b as usize; //~ ERROR non-primitive cast
     p as usize;
     //~^ ERROR casting
     //~^^ HELP cast through a thin pointer
index 25060b94dcf37bec0354f1fd1c6e4bbaa714d7d4..2d00f339f33a066607fbf6eee018501ce5557422 100644 (file)
@@ -10,5 +10,5 @@
 
 fn main() {
     let nil = ();
-    let _t = nil as usize; //~ ERROR: non-scalar cast: `()` as `usize`
+    let _t = nil as usize; //~ ERROR: non-primitive cast: `()` as `usize`
 }
index bcbc414d3534bb3245dbd086701a0a2d7c68305e..c23fc4f334472bee36f321981f2e44078bc71d83 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn main() {
-    0 as &std::any::Any; //~ ERROR non-scalar cast
+    0 as &std::any::Any; //~ ERROR non-primitive cast
 }
index 4d6e6eded211847a415538c4a0b28fc900e30d52..2128c4206301b3848968c48eb9db804b5a75a17e 100644 (file)
@@ -19,7 +19,7 @@ fn get<'a>(&'a self, y: usize, x: usize) -> Option<&'a <Self as Index<usize>>::O
         }
         let i = y * self.columns() + x;
         let indexer = &(*self as &Index<usize, Output = <Self as Index<usize>>::Output>);
-        //~^ERROR non-scalar cast
+        //~^ERROR non-primitive cast
         Some(indexer.index(i))
     }
 }
index 8fbf97411cc7d0aaaf1c72fe4a3d060ff0f3310e..d735e184d5cd568f3c0461d11e9bebb8e9b483b4 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn bad (p: *const isize) {
-    let _q: &isize = p as &isize; //~ ERROR non-scalar cast
+    let _q: &isize = p as &isize; //~ ERROR non-primitive cast
 }
 
 fn main() { }
index d6f274da967d11e4d227794bb7fb3929123e6bfe..0abbc05eef05dd7b84bcd578b3ef6413001c2ed1 100644 (file)
@@ -8,13 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:non-scalar cast
-
 #[derive(Debug)]
 struct foo {
     x: isize
 }
 
 fn main() {
-    println!("{}", foo{ x: 1 } as isize);
+    println!("{}", foo{ x: 1 } as isize); //~ non-primitive cast: `foo` as `isize` [E0605]
 }
index b01063291266c37a55749e4a1d9a1f120308ff47..220537633eaf12291d6f99b18df7af814b5e90b3 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//error-pattern: non-scalar cast
-
 enum non_nullary {
     nullary,
     other(isize),
@@ -17,5 +15,5 @@ enum non_nullary {
 
 fn main() {
     let v = non_nullary::nullary;
-    let val = v as isize;
+    let val = v as isize; //~ ERROR non-primitive cast: `non_nullary` as `isize` [E0605]
 }
index b4df5fb1e2accd5a9c2884585876a03c257e278e..2a5d25e6b98dd0497286a83883c518c64a5ceef0 100644 (file)
@@ -11,7 +11,7 @@
 enum E {}
 
 fn f(e: E) {
-    println!("{}", (e as isize).to_string());   //~ ERROR non-scalar cast
+    println!("{}", (e as isize).to_string());   //~ ERROR non-primitive cast
 }
 
 fn main() {}
index 50e1815057928537328387b9eb9da1309e8038a1..879acbcf9d9d1cd198a603df218e067a894c0dab 100644 (file)
@@ -20,7 +20,7 @@ error[E0609]: no field `f` on type `fn() {main}`
 75 |     let _ = main.f as *const u32;
    |                  ^
 
-error[E0605]: non-scalar cast: `*const u8` as `&u8`
+error[E0605]: non-primitive cast: `*const u8` as `&u8`
   --> $DIR/cast-rfc0401.rs:39:13
    |
 39 |     let _ = v as &u8;
@@ -28,7 +28,7 @@ error[E0605]: non-scalar cast: `*const u8` as `&u8`
    |
    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
 
-error[E0605]: non-scalar cast: `*const u8` as `E`
+error[E0605]: non-primitive cast: `*const u8` as `E`
   --> $DIR/cast-rfc0401.rs:40:13
    |
 40 |     let _ = v as E;
@@ -36,7 +36,7 @@ error[E0605]: non-scalar cast: `*const u8` as `E`
    |
    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
 
-error[E0605]: non-scalar cast: `*const u8` as `fn()`
+error[E0605]: non-primitive cast: `*const u8` as `fn()`
   --> $DIR/cast-rfc0401.rs:41:13
    |
 41 |     let _ = v as fn();
@@ -44,7 +44,7 @@ error[E0605]: non-scalar cast: `*const u8` as `fn()`
    |
    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
 
-error[E0605]: non-scalar cast: `*const u8` as `(u32,)`
+error[E0605]: non-primitive cast: `*const u8` as `(u32,)`
   --> $DIR/cast-rfc0401.rs:42:13
    |
 42 |     let _ = v as (u32,);
@@ -52,7 +52,7 @@ error[E0605]: non-scalar cast: `*const u8` as `(u32,)`
    |
    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
 
-error[E0605]: non-scalar cast: `std::option::Option<&*const u8>` as `*const u8`
+error[E0605]: non-primitive cast: `std::option::Option<&*const u8>` as `*const u8`
   --> $DIR/cast-rfc0401.rs:43:13
    |
 43 |     let _ = Some(&v) as *const u8;
index 06b88069002909f977aa5224b7b5641d3f6e793d..9da9042e78ed13b891e2899e6e9bccd36b368a0f 100644 (file)
@@ -7,7 +7,7 @@ error[E0308]: mismatched types
 37 |     write!(hello);
    |     -------------- in this macro invocation
 
-error[E0605]: non-scalar cast: `{integer}` as `()`
+error[E0605]: non-primitive cast: `{integer}` as `()`
   --> $DIR/issue-26480.rs:32:19
    |
 32 |     ($x:expr) => ($x as ())