diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index fb78d3a37ca23..3074a62fddf92 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -302,7 +302,11 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { debug!(" -> {:?}", k); fcx.tcx.cast_kinds.borrow_mut().insert(self.expr.id, k); } - Err(e) => self.report_cast_error(fcx, e) + Err(e) => { + if !fcx.inh.infcx.is_tainted_by_errors() { + self.report_cast_error(fcx, e) + } + } };} } diff --git a/src/test/compile-fail/issue-35772.rs b/src/test/compile-fail/issue-35772.rs new file mode 100644 index 0000000000000..d6af7af0c69b6 --- /dev/null +++ b/src/test/compile-fail/issue-35772.rs @@ -0,0 +1,14 @@ +// Copyright 2016 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. + +fn main() { + error; //~ ERROR unresolved name `error` + 1 as f32; +}