Skip to content

Commit

Permalink
Add E0614
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 15, 2017
1 parent e8cbb53 commit a80db25
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/librustc_typeck/diagnostics.rs
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions src/test/compile-fail/E0614.rs
@@ -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
}

0 comments on commit a80db25

Please sign in to comment.