diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 051ddd57241..557b7b70947 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3305,6 +3305,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 00000000000..1b52bd9c3de --- /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(); +}