Add E0614
This commit is contained in:
parent
e8cbb53309
commit
a80db25802
3 changed files with 47 additions and 13 deletions
|
|
@ -3217,15 +3217,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
.join(", ");
|
||||
|
||||
struct_span_err!(tcx.sess, span, E0063,
|
||||
"missing field{} {}{} in initializer of `{}`",
|
||||
if remaining_fields.len() == 1 {""} else {"s"},
|
||||
remaining_fields_names,
|
||||
truncated_fields_error,
|
||||
adt_ty)
|
||||
.span_label(span, format!("missing {}{}",
|
||||
remaining_fields_names,
|
||||
truncated_fields_error))
|
||||
.emit();
|
||||
"missing field{} {}{} in initializer of `{}`",
|
||||
if remaining_fields.len() == 1 { "" } else { "s" },
|
||||
remaining_fields_names,
|
||||
truncated_fields_error,
|
||||
adt_ty)
|
||||
.span_label(span, format!("missing {}{}",
|
||||
remaining_fields_names,
|
||||
truncated_fields_error))
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3458,10 +3458,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
oprnd_t = self.make_overloaded_lvalue_return_type(method).ty;
|
||||
self.write_method_call(expr.id, method);
|
||||
} else {
|
||||
self.type_error_message(expr.span, |actual| {
|
||||
format!("type `{}` cannot be \
|
||||
dereferenced", actual)
|
||||
}, oprnd_t);
|
||||
type_error_struct!(tcx.sess, expr.span, oprnd_t, E0614,
|
||||
"type `{}` cannot be dereferenced",
|
||||
oprnd_t).emit();
|
||||
oprnd_t = tcx.types.err;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4286,6 +4286,27 @@ println!("x: {} y: {}", s.x, s.y);
|
|||
```
|
||||
"##,
|
||||
|
||||
E0614: r##"
|
||||
Attempted to dereference a variable which cannot be dereferenced.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0614
|
||||
let y = 0u32;
|
||||
*y; // error: type `u32` cannot be dereferenced
|
||||
```
|
||||
|
||||
Only types implementing `std::ops::Deref` can be dereferenced (such as `&T`).
|
||||
Example:
|
||||
|
||||
```
|
||||
let y = 0u32;
|
||||
let x = &y;
|
||||
// So here, `x` is a `&u32`, so we can dereference it:
|
||||
*x; // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0617: r##"
|
||||
Attempted to pass an invalid type of variable into a variadic function.
|
||||
|
||||
|
|
|
|||
14
src/test/compile-fail/E0614.rs
Normal file
14
src/test/compile-fail/E0614.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// 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() {
|
||||
let y = 0u32;
|
||||
*y; //~ ERROR E0614
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue