diff options
| author | Dan Robertson <danlrobertson89@gmail.com> | 2018-05-11 03:56:08 +0000 |
|---|---|---|
| committer | Dan Robertson <danlrobertson89@gmail.com> | 2018-05-12 02:47:58 +0000 |
| commit | f6a46cf4d16e5fa38ee983dd6e191ae7e46acaae (patch) | |
| tree | 3975f7c300121cb9ca3fe0ca6589af1bf6415d79 /src/test | |
| parent | 41707d8df9a441e19387a4a61415ee0af58a9e48 (diff) | |
| download | rust-f6a46cf4d16e5fa38ee983dd6e191ae7e46acaae.tar.gz rust-f6a46cf4d16e5fa38ee983dd6e191ae7e46acaae.zip | |
typeck: Fix ICE with struct update syntax
If check_expr_struct_fields fails, do not continue to record update. If we continue to record update, the struct may cause us to ICE later on indexing a field that may or may not exist.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/issue-50618.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/issue-50618.stderr | 11 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/ui/issue-50618.rs b/src/test/ui/issue-50618.rs new file mode 100644 index 00000000000..ed427c293df --- /dev/null +++ b/src/test/ui/issue-50618.rs @@ -0,0 +1,29 @@ +// 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. + +struct Point { + pub x: u64, + pub y: u64, +} + +const TEMPLATE: Point = Point { + x: 0, + y: 0 +}; + +fn main() { + let _ = || { + Point { + nonexistent: 0, + //~^ ERROR struct `Point` has no field named `nonexistent` + ..TEMPLATE + } + }; +} diff --git a/src/test/ui/issue-50618.stderr b/src/test/ui/issue-50618.stderr new file mode 100644 index 00000000000..07cc5a1318a --- /dev/null +++ b/src/test/ui/issue-50618.stderr @@ -0,0 +1,11 @@ +error[E0560]: struct `Point` has no field named `nonexistent` + --> $DIR/issue-50618.rs:24:13 + | +LL | nonexistent: 0, + | ^^^^^^^^^^^ `Point` does not have this field + | + = note: available fields are: `x`, `y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0560`. |
