about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-03-30 14:20:20 +0000
committerbors <bors@rust-lang.org>2017-03-30 14:20:20 +0000
commit7ae95e548929f4924905b2e8f87f2dd57d8bc887 (patch)
treeaceb2641992bb0d995e317bb38e119a6ad13710d /src/libsyntax/parse
parentfe151194e9a919ab23c2bb356767a5cbfa3811e7 (diff)
parent2414222b17f45e33d68582dd5ebe0083ed27b8cc (diff)
downloadrust-7ae95e548929f4924905b2e8f87f2dd57d8bc887.tar.gz
rust-7ae95e548929f4924905b2e8f87f2dd57d8bc887.zip
Auto merge of #40224 - nikomatsakis:issue-39808, r=eddyb
change the strategy for diverging types

The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes #39808.
Fixes #39984.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/obsolete.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index a46a788ca08..d5baec675e4 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -36,6 +36,7 @@ pub trait ParserObsoleteMethods {
 impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
     /// Reports an obsolete syntax non-fatal error.
     #[allow(unused_variables)]
+    #[allow(unreachable_code)]
     fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
         let (kind_str, desc, error) = match kind {
             // Nothing here at the moment