Skip to content

Commit 8566e12

Browse files
committed
---
yaml --- r: 227195 b: refs/heads/auto c: d46e840 h: refs/heads/master i: 227193: 06b0008 227191: 9c3da3e v: v3
1 parent 3a0adb4 commit 8566e12

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: c115c513632b45d1a4d1b3fb648755a7023269e7
11+
refs/heads/auto: d46e84081f88f22198fbfcd5221faaf922e0500d
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc/middle/traits/error_reporting.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use middle::ty::{self, ToPredicate, HasTypeFlags, ToPolyTraitRef, TraitRef};
2929
use middle::ty_fold::TypeFoldable;
3030
use std::collections::HashMap;
3131
use std::fmt;
32-
use syntax::codemap::{DUMMY_SP, Span};
32+
use syntax::codemap::Span;
3333
use syntax::attr::{AttributeMethods, AttrMetaMethods};
3434

3535
pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
@@ -81,11 +81,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
8181
let mut report = None;
8282
for item in infcx.tcx.get_attrs(def_id).iter() {
8383
if item.check_name("rustc_on_unimplemented") {
84-
let err_sp = if item.meta().span == DUMMY_SP {
85-
span
86-
} else {
87-
item.meta().span
88-
};
84+
let err_sp = item.meta().span.substitute_dummy(span);
8985
let def = infcx.tcx.lookup_trait_def(def_id);
9086
let trait_str = def.trait_ref.to_string();
9187
if let Some(ref istring) = item.value_str() {

branches/auto/src/libsyntax/codemap.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ pub const COMMAND_LINE_SP: Span = Span { lo: BytePos(0),
135135
hi: BytePos(0),
136136
expn_id: COMMAND_LINE_EXPN };
137137

138+
impl Span {
139+
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
140+
pub fn substitute_dummy(self, other: Span) -> Span {
141+
if self == DUMMY_SP { other } else { self }
142+
}
143+
}
144+
138145
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
139146
pub struct Spanned<T> {
140147
pub node: T,

branches/auto/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,16 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
211211
best_fail_spot = sp;
212212
best_fail_msg = (*msg).clone();
213213
},
214-
Error(mut spp, ref msg) => {
215-
if spp == DUMMY_SP {
216-
spp = sp;
217-
}
218-
219-
panic!(cx.span_fatal(spp, &msg[..]))
214+
Error(err_sp, ref msg) => {
215+
panic!(cx.span_fatal(err_sp.substitute_dummy(sp), &msg[..]))
220216
}
221217
}
222218
}
223219
_ => cx.bug("non-matcher found in parsed lhses")
224220
}
225221
}
226222

227-
if best_fail_spot == DUMMY_SP {
228-
best_fail_spot = sp;
229-
}
230-
231-
panic!(cx.span_fatal(best_fail_spot, &best_fail_msg[..]));
223+
panic!(cx.span_fatal(best_fail_spot.substitute_dummy(sp), &best_fail_msg[..]));
232224
}
233225

234226
// Note that macro-by-example's input is also matched against a token tree:
@@ -283,12 +275,9 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
283275
arg_reader,
284276
&argument_gram) {
285277
Success(m) => m,
286-
Failure(mut sp, str) | Error(mut sp, str) => {
287-
if sp == DUMMY_SP {
288-
sp = def.span;
289-
}
290-
291-
panic!(cx.parse_sess().span_diagnostic.span_fatal(sp, &str[..]));
278+
Failure(sp, str) | Error(sp, str) => {
279+
panic!(cx.parse_sess().span_diagnostic
280+
.span_fatal(sp.substitute_dummy(def.span), &str[..]));
292281
}
293282
};
294283

0 commit comments

Comments
 (0)