rustc: Add error about obsolete struct deref
This commit is contained in:
parent
3b1862a82f
commit
2d8fbba57d
|
@ -2765,6 +2765,16 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
}
|
||||
None => {
|
||||
match *sty {
|
||||
ty::ty_struct(did, ref substs) if {
|
||||
let fields = ty::struct_fields(fcx.tcx(), did, substs);
|
||||
fields.len() == 1
|
||||
&& fields[0].ident == token::special_idents::unnamed_field
|
||||
} => {
|
||||
// This is an obsolete struct deref
|
||||
tcx.sess.span_err(
|
||||
expr.span,
|
||||
"single-field tuple-structs can no longer be dereferenced");
|
||||
}
|
||||
_ => {
|
||||
fcx.type_error_message(expr.span,
|
||||
|actual| {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2013 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() {
|
||||
struct S(int);
|
||||
let s = S(0);
|
||||
let x = *s; //~ ERROR single-field tuple-structs can no longer be dereferenced
|
||||
}
|
Loading…
Reference in New Issue