Skip to content

Commit

Permalink
librustc: Don't ICE with struct exprs where the name is not a valid s…
Browse files Browse the repository at this point in the history
…truct.
  • Loading branch information
luqmana authored and alexcrichton committed Jul 31, 2014
1 parent bd15854 commit bc24819
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/librustc/middle/typeck/check/mod.rs
Expand Up @@ -3547,6 +3547,17 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
span_err!(tcx.sess, path.span, E0071,
"`{}` does not name a structure",
pprust::path_to_string(path));

// Make sure to still write the types
// otherwise we might ICE
fcx.write_error(id);
for field in fields.iter() {
check_expr(fcx, &*field.expr);
}
match base_expr {
Some(ref base) => check_expr(fcx, &**base),
None => {}
}
}
}

Expand Down
26 changes: 26 additions & 0 deletions src/test/compile-fail/issue-16058.rs
@@ -0,0 +1,26 @@
// Copyright 2012-2014 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.


pub struct GslResult {
pub val: f64,
pub err: f64
}

impl GslResult {
pub fn new() -> GslResult {
Result { //~ ERROR: `Result` does not name a structure
val: 0f64,
err: 0f64
}
}
}

fn main() {}

0 comments on commit bc24819

Please sign in to comment.