Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakis
Implement the `!` type This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
This commit is contained in:
commit
e25542cb02
128 changed files with 898 additions and 704 deletions
|
@ -1332,11 +1332,7 @@ impl<'a> Parser<'a> {
|
|||
/// Parse optional return type [ -> TY ] in function decl
|
||||
pub fn parse_ret_ty(&mut self) -> PResult<'a, FunctionRetTy> {
|
||||
if self.eat(&token::RArrow) {
|
||||
if self.eat(&token::Not) {
|
||||
Ok(FunctionRetTy::None(self.last_span))
|
||||
} else {
|
||||
Ok(FunctionRetTy::Ty(self.parse_ty()?))
|
||||
}
|
||||
Ok(FunctionRetTy::Ty(self.parse_ty()?))
|
||||
} else {
|
||||
let pos = self.span.lo;
|
||||
Ok(FunctionRetTy::Default(mk_sp(pos, pos)))
|
||||
|
@ -1399,6 +1395,8 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
TyKind::Tup(ts)
|
||||
}
|
||||
} else if self.eat(&token::Not) {
|
||||
TyKind::Never
|
||||
} else if self.check(&token::BinOp(token::Star)) {
|
||||
// STAR POINTER (bare pointer?)
|
||||
self.bump();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue