Skip to content

Commit 45391ee

Browse files
committed
---
yaml --- r: 277508 b: refs/heads/try c: 5a4e0b1 h: refs/heads/master
1 parent e9738b7 commit 45391ee

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
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: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 60c8f7dbf5788f1c9f3a27be2e7be28ecf7817ff
4+
refs/heads/try: 5a4e0b14e39989f327f9f8103cf38ec43cd22131
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_resolve/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ enum ResolutionError<'a> {
141141
/// error E0413: declaration shadows an enum variant or unit-like struct in scope
142142
DeclarationShadowsEnumVariantOrUnitLikeStruct(Name),
143143
/// error E0414: only irrefutable patterns allowed here
144-
OnlyIrrefutablePatternsAllowedHere(DefId, Name),
144+
OnlyIrrefutablePatternsAllowedHere(Name),
145145
/// error E0415: identifier is bound more than once in this parameter list
146146
IdentifierBoundMoreThanOnceInParameterList(&'a str),
147147
/// error E0416: identifier is bound more than once in the same pattern
@@ -323,22 +323,18 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
323323
or unit-like struct in scope",
324324
name)
325325
}
326-
ResolutionError::OnlyIrrefutablePatternsAllowedHere(did, name) => {
326+
ResolutionError::OnlyIrrefutablePatternsAllowedHere(name) => {
327327
let mut err = struct_span_err!(resolver.session,
328328
span,
329329
E0414,
330330
"only irrefutable patterns allowed here");
331331
err.span_note(span,
332332
"there already is a constant in scope sharing the same \
333333
name as this pattern");
334-
if let Some(sp) = resolver.ast_map.span_if_local(did) {
335-
err.span_note(sp, "constant defined here");
336-
}
337334
if let Some(binding) = resolver.current_module
338335
.resolve_name_in_lexical_scope(name, ValueNS) {
339-
if binding.is_import() {
340-
err.span_note(binding.span, "constant imported here");
341-
}
336+
let participle = if binding.is_import() { "imported" } else { "defined" };
337+
err.span_note(binding.span, &format!("constant {} here", participle));
342338
}
343339
err
344340
}
@@ -2248,12 +2244,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22482244
depth: 0,
22492245
});
22502246
}
2251-
FoundConst(def, name) => {
2247+
FoundConst(_, name) => {
22522248
resolve_error(
22532249
self,
22542250
pattern.span,
2255-
ResolutionError::OnlyIrrefutablePatternsAllowedHere(def.def_id(),
2256-
name)
2251+
ResolutionError::OnlyIrrefutablePatternsAllowedHere(name)
22572252
);
22582253
self.record_def(pattern.id, err_path_resolution());
22592254
}

branches/try/src/test/compile-fail/const-pattern-irrefutable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
mod foo {
12-
pub const b: u8 = 2; //~ NOTE constant defined here
13-
pub const d: u8 = 2; //~ NOTE constant defined here
12+
pub const b: u8 = 2;
13+
pub const d: u8 = 2;
1414
}
1515

1616
use foo::b as c; //~ NOTE constant imported here

0 commit comments

Comments
 (0)