Skip to content

Commit bcff5a7

Browse files
committed
Permit ! as T with test
1 parent 06747c6 commit bcff5a7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/librustc_typeck/check/coercion.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
642642
apply(&mut coerce, &|| Some(expr), source, target)?;
643643
if !adjustment.is_identity() {
644644
debug!("Success, coerced with {:?}", adjustment);
645-
assert!(!self.tables.borrow().adjustments.contains_key(&expr.id));
645+
match self.tables.borrow().adjustments.get(&expr.id) {
646+
None | Some(&AdjustNeverToAny(..)) => (),
647+
_ => bug!("expr already has an adjustment on it!"),
648+
};
646649
self.write_adjustment(expr.id, adjustment);
647650
}
648651
Ok(ty)

src/test/run-fail/cast-never.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(never_type)]
12+
13+
// error-pattern:explicit
14+
fn main() {
15+
let x: ! = panic!();
16+
let y: u32 = x as u32;
17+
}
18+

0 commit comments

Comments
 (0)