Skip to content

Commit 73d5ca3

Browse files
committed
---
yaml --- r: 273717 b: refs/heads/beta c: 9799cac h: refs/heads/master i: 273715: 31853d7
1 parent 3f80455 commit 73d5ca3

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: cd80c1bb5540fa2610a8f3d8a25560d1f0981400
26+
refs/heads/beta: 9799cacba3042420cc7b49d555289241cf0456e1
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc/session/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ impl NodeIdAssigner for Session {
336336
fn peek_node_id(&self) -> NodeId {
337337
self.next_node_id.get().checked_add(1).unwrap()
338338
}
339+
340+
fn diagnostic(&self) -> &errors::Handler {
341+
self.diagnostic()
342+
}
339343
}
340344

341345
fn split_msg_into_multilines(msg: &str) -> Option<String> {

branches/beta/src/librustc_front/lowering.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use std::collections::HashMap;
6868
use std::iter;
6969
use syntax::ast::*;
7070
use syntax::attr::{ThinAttributes, ThinAttributesExt};
71+
use syntax::errors::Handler;
7172
use syntax::ext::mtwt;
7273
use syntax::ptr::P;
7374
use syntax::codemap::{respan, Spanned, Span};
@@ -140,6 +141,11 @@ impl<'a, 'hir> LoweringContext<'a> {
140141
result
141142
}
142143
}
144+
145+
// panics if this LoweringContext's NodeIdAssigner is not a Session
146+
fn diagnostic(&self) -> &Handler {
147+
self.id_assigner.diagnostic()
148+
}
143149
}
144150

145151
// Utility fn for setting and unsetting the cached id.
@@ -1289,7 +1295,8 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
12891295
make_struct(lctx, e, &["RangeInclusive", "NonEmpty"],
12901296
&[("start", e1), ("end", e2)]),
12911297

1292-
_ => panic!("impossible range in AST"),
1298+
_ => panic!(lctx.diagnostic().span_fatal(e.span,
1299+
"inclusive range with no end"))
12931300
}
12941301
});
12951302
}

branches/beta/src/libsyntax/ast.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub use self::PathParameters::*;
1919
use attr::ThinAttributes;
2020
use codemap::{Span, Spanned, DUMMY_SP, ExpnId};
2121
use abi::Abi;
22+
use errors;
2223
use ext::base;
2324
use ext::tt::macro_parser;
2425
use parse::token::InternedString;
@@ -344,6 +345,10 @@ pub const DUMMY_NODE_ID: NodeId = !0;
344345
pub trait NodeIdAssigner {
345346
fn next_node_id(&self) -> NodeId;
346347
fn peek_node_id(&self) -> NodeId;
348+
349+
fn diagnostic(&self) -> &errors::Handler {
350+
panic!("this ID assigner cannot emit diagnostics")
351+
}
347352
}
348353

349354
/// The AST represents all type param bounds as types.

branches/beta/src/test/parse-fail/range_inclusive.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(inclusive_range_syntax, inclusive_range)]
1414

1515
pub fn main() {
16-
for _ in 1... {}
17-
} //~ ERROR expected one of
16+
for _ in 1... {} //~ERROR inclusive range with no end
17+
//~^HELP 28237
18+
}
1819

0 commit comments

Comments
 (0)