Permit ! as T with test

This commit is contained in:
Andrew Cann 2016-08-11 19:28:52 +08:00
parent 06747c669f
commit bcff5a78b3
2 changed files with 22 additions and 1 deletions

View file

@ -642,7 +642,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
apply(&mut coerce, &|| Some(expr), source, target)?;
if !adjustment.is_identity() {
debug!("Success, coerced with {:?}", adjustment);
assert!(!self.tables.borrow().adjustments.contains_key(&expr.id));
match self.tables.borrow().adjustments.get(&expr.id) {
None | Some(&AdjustNeverToAny(..)) => (),
_ => bug!("expr already has an adjustment on it!"),
};
self.write_adjustment(expr.id, adjustment);
}
Ok(ty)

View file

@ -0,0 +1,18 @@
// Copyright 2012 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.
#![feature(never_type)]
// error-pattern:explicit
fn main() {
let x: ! = panic!();
let y: u32 = x as u32;
}