From d13fe1c528d76ec313a94dac062e7f647b167e8c Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 28 Aug 2014 10:30:30 +1200 Subject: [PATCH] Fix an ICE with error types in a vec Closes #16783 --- src/librustc/middle/ty.rs | 5 +++++ src/test/compile-fail/issue-16783.rs | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/compile-fail/issue-16783.rs diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2d3096d13eae0..7b91ee7264283 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3266,6 +3266,11 @@ pub fn adjust_ty(cx: &ctxt, -> ty::t { /*! See `expr_ty_adjusted` */ + match get(unadjusted_ty).sty { + ty_err => return unadjusted_ty, + _ => {} + } + return match adjustment { Some(adjustment) => { match *adjustment { diff --git a/src/test/compile-fail/issue-16783.rs b/src/test/compile-fail/issue-16783.rs new file mode 100644 index 0000000000000..1b52bd9c3de9d --- /dev/null +++ b/src/test/compile-fail/issue-16783.rs @@ -0,0 +1,15 @@ +// Copyright 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let x = [1, 2, 3]; + //~^ ERROR cannot determine a type for this local variable: cannot determine the type of this + let y = x.as_slice(); +}