.emit();
}
CastError::CastToChar => {
- fcx.type_error_message(self.span,
- |actual| {
- format!("only `u8` can be cast as `char`, not `{}`",
- actual)
- },
- self.expr_ty);
+ struct_span_err!(fcx.tcx.sess, self.span, E0604,
+ "only `u8` can be cast as `char`, not `{}`", self.expr_ty).emit();
}
CastError::NonScalar => {
fcx.type_error_message(self.span,
```
"##,
+E0604: r##"
+A cast to `char` was attempted on another type than `u8`.
+
+Erroneous code example:
+
+```compile_fail,E0604
+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:
+
+```
+let c = 86u8 as char; // ok!
+assert!(c, 'V');
+```
+"##,
+
E0609: r##"
Attempted to access a non-existent field in a struct.
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ 1u32 as char; //~ ERROR E0604
+}
|
= help: compare with zero instead
-error: only `u8` can be cast as `char`, not `u32`
+error[E0604]: only `u8` can be cast as `char`, not `u32`
--> $DIR/cast-rfc0401.rs:51:13
|
51 | let _ = 0x61u32 as char;