Skip to content

Commit f036128

Browse files
committed
---
yaml --- r: 174722 b: refs/heads/snap-stage3 c: f68029e h: refs/heads/master v: v3
1 parent 176f5a5 commit f036128

File tree

8 files changed

+51
-27
lines changed

8 files changed

+51
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: a0f86de49748b472d4d189d9688b0d856c000914
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 0c5225c5bf31dcca141c36ce1b5850ff2df79b9c
4+
refs/heads/snap-stage3: f68029ec94415298e56ab20f73bcf2a1224ace4d
55
refs/heads/try: 08f6380a9f0b866796080094f44fe25ea5636547
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc/session/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ impl Session {
6969
pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
7070
self.diagnostic().span_fatal(sp, msg)
7171
}
72+
pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> ! {
73+
self.diagnostic().span_fatal_with_code(sp, msg, code)
74+
}
7275
pub fn fatal(&self, msg: &str) -> ! {
7376
self.diagnostic().handler().fatal(msg)
7477
}

branches/snap-stage3/src/librustc_typeck/astconv.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -339,22 +339,22 @@ fn create_substs_for_ast_path<'tcx>(
339339
} else {
340340
"expected"
341341
};
342-
this.tcx().sess.span_fatal(span,
343-
&format!("wrong number of type arguments: {} {}, found {}",
342+
span_fatal!(this.tcx().sess, span, E0243,
343+
"wrong number of type arguments: {} {}, found {}",
344344
expected,
345345
required_ty_param_count,
346-
supplied_ty_param_count)[]);
346+
supplied_ty_param_count);
347347
} else if supplied_ty_param_count > formal_ty_param_count {
348348
let expected = if required_ty_param_count < formal_ty_param_count {
349349
"expected at most"
350350
} else {
351351
"expected"
352352
};
353-
this.tcx().sess.span_fatal(span,
354-
&format!("wrong number of type arguments: {} {}, found {}",
353+
span_fatal!(this.tcx().sess, span, E0244,
354+
"wrong number of type arguments: {} {}, found {}",
355355
expected,
356356
formal_ty_param_count,
357-
supplied_ty_param_count)[]);
357+
supplied_ty_param_count);
358358
}
359359

360360
let mut substs = Substs::new_type(types, regions);
@@ -557,10 +557,9 @@ pub fn instantiate_trait_ref<'tcx>(
557557
trait_ref
558558
}
559559
_ => {
560-
this.tcx().sess.span_fatal(
561-
ast_trait_ref.path.span,
562-
&format!("`{}` is not a trait",
563-
ast_trait_ref.path.user_string(this.tcx()))[]);
560+
span_fatal!(this.tcx().sess, ast_trait_ref.path.span, E0245,
561+
"`{}` is not a trait",
562+
ast_trait_ref.path.user_string(this.tcx()));
564563
}
565564
}
566565
}
@@ -1036,7 +1035,7 @@ pub fn ast_ty_to_ty<'tcx>(
10361035
match ast_ty_to_ty_cache.get(&ast_ty.id) {
10371036
Some(&ty::atttce_resolved(ty)) => return ty,
10381037
Some(&ty::atttce_unresolved) => {
1039-
tcx.sess.span_fatal(ast_ty.span,
1038+
span_fatal!(tcx.sess, ast_ty.span, E0246,
10401039
"illegal recursive type; insert an enum \
10411040
or struct in the cycle, if this is \
10421041
desired");
@@ -1136,9 +1135,9 @@ pub fn ast_ty_to_ty<'tcx>(
11361135
ty::mk_self_type(tcx)
11371136
}
11381137
def::DefMod(id) => {
1139-
tcx.sess.span_fatal(ast_ty.span,
1140-
&format!("found module name used as a type: {}",
1141-
tcx.map.node_to_string(id.node))[]);
1138+
span_fatal!(tcx.sess, ast_ty.span, E0247,
1139+
"found module name used as a type: {}",
1140+
tcx.map.node_to_string(id.node));
11421141
}
11431142
def::DefPrimTy(_) => {
11441143
panic!("DefPrimTy arm missed in previous ast_ty_to_prim_ty call");
@@ -1164,10 +1163,10 @@ pub fn ast_ty_to_ty<'tcx>(
11641163
associated_path_def_to_ty(this, ast_ty, provenance, assoc_ident.name)
11651164
}
11661165
_ => {
1167-
tcx.sess.span_fatal(ast_ty.span,
1168-
&format!("found value name used \
1166+
span_fatal!(tcx.sess, ast_ty.span, E0248,
1167+
"found value name used \
11691168
as a type: {:?}",
1170-
a_def)[]);
1169+
a_def);
11711170
}
11721171
}
11731172
}
@@ -1185,17 +1184,16 @@ pub fn ast_ty_to_ty<'tcx>(
11851184
ty::mk_vec(tcx, ast_ty_to_ty(this, rscope, &**ty),
11861185
Some(i as uint)),
11871186
_ => {
1188-
tcx.sess.span_fatal(
1189-
ast_ty.span, "expected constant expr for array length");
1187+
span_fatal!(tcx.sess, ast_ty.span, E0249,
1188+
"expected constant expr for array length");
11901189
}
11911190
}
11921191
}
11931192
Err(ref r) => {
1194-
tcx.sess.span_fatal(
1195-
ast_ty.span,
1196-
&format!("expected constant expr for array \
1193+
span_fatal!(tcx.sess, ast_ty.span, E0250,
1194+
"expected constant expr for array \
11971195
length: {}",
1198-
*r)[]);
1196+
*r);
11991197
}
12001198
}
12011199
}

branches/snap-stage3/src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5224,7 +5224,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
52245224
"get_tydesc" => {
52255225
let tydesc_ty = match ty::get_tydesc_ty(ccx.tcx) {
52265226
Ok(t) => t,
5227-
Err(s) => { tcx.sess.span_fatal(it.span, &s[]); }
5227+
Err(s) => { span_fatal!(tcx.sess, it.span, E0240, "{}", &s[]); }
52285228
};
52295229
let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {
52305230
ty: tydesc_ty,

branches/snap-stage3/src/librustc_typeck/diagnostics.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,18 @@ register_diagnostics! {
160160
E0236, // no lang item for range syntax
161161
E0237, // no lang item for range syntax
162162
E0238, // parenthesized parameters may only be used with a trait
163-
E0239 // `next` method of `Iterator` trait has unexpected type
163+
E0239, // `next` method of `Iterator` trait has unexpected type
164+
E0240,
165+
E0241,
166+
E0242, // internal error looking up a definition
167+
E0243, // wrong number of type arguments
168+
E0244, // wrong number of type arguments
169+
E0245, // not a trait
170+
E0246, // illegal recursive type
171+
E0247, // found module name used as a type
172+
E0248, // found value name used as a type
173+
E0249, // expected constant expr for array length
174+
E0250 // expected constant expr for array length
164175
}
165176

166177
__build_diagnostic_array! { DIAGNOSTICS }

branches/snap-stage3/src/librustc_typeck/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> def::Def {
162162
match tcx.def_map.borrow().get(&id) {
163163
Some(x) => x.clone(),
164164
_ => {
165-
tcx.sess.span_fatal(sp, "internal error looking up a definition")
165+
span_fatal!(tcx.sess, sp, E0242, "internal error looking up a definition")
166166
}
167167
}
168168
}

branches/snap-stage3/src/libsyntax/diagnostic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ impl SpanHandler {
9292
self.handler.emit(Some((&self.cm, sp)), msg, Fatal);
9393
panic!(FatalError);
9494
}
95+
pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> ! {
96+
self.handler.emit_with_code(Some((&self.cm, sp)), msg, code, Fatal);
97+
panic!(FatalError);
98+
}
9599
pub fn span_err(&self, sp: Span, msg: &str) {
96100
self.handler.emit(Some((&self.cm, sp)), msg, Error);
97101
self.handler.bump_err_count();

branches/snap-stage3/src/libsyntax/diagnostics/macros.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ macro_rules! register_diagnostic {
1414
($code:tt) => (__register_diagnostic! { $code })
1515
}
1616

17+
#[macro_export]
18+
macro_rules! span_fatal {
19+
($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
20+
__diagnostic_used!($code);
21+
$session.span_fatal_with_code($span, format!($($message)*).as_slice(), stringify!($code))
22+
})
23+
}
24+
1725
#[macro_export]
1826
macro_rules! span_err {
1927
($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({

0 commit comments

Comments
 (0)