Skip to content

Commit 78d3860

Browse files
committed
---
yaml --- r: 273209 b: refs/heads/beta c: 7a2c50f h: refs/heads/master i: 273207: b1f29fe
1 parent 20ca021 commit 78d3860

36 files changed

+221
-218
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: 6e0f2f2f050443f2aec4e9c7d25618a6a6639b83
26+
refs/heads/beta: 7a2c50f9512ff5816aeb5e3341d0b3c217ba88f8
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/compiler-rt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 57315f7e07d09b6f0341ebbcd50dded6c20d782f
1+
Subproject commit b6087e82ba1384c4af3adf2dc68e92316f0d4caf

branches/beta/src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
671671
}
672672
hir::ExprBinary(op, ref a, ref b) => {
673673
let b_ty = match op.node {
674-
hir::BiShl | hir::BiShr => ty_hint.checked_or(tcx.types.usize),
674+
hir::BiShl | hir::BiShr => ty_hint.erase_hint(),
675675
_ => ty_hint
676676
};
677677
// technically, if we don't have type hints, but integral eval

branches/beta/src/librustc/middle/liveness.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ use self::VarKind::*;
112112
use dep_graph::DepNode;
113113
use middle::def::*;
114114
use middle::pat_util;
115-
use middle::ty::{self, TyCtxt, ParameterEnvironment};
116-
use middle::traits::{self, ProjectionMode};
117-
use middle::infer;
115+
use middle::ty::{self, TyCtxt};
118116
use lint;
119117
use util::nodemap::NodeMap;
120118

@@ -1492,19 +1490,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
14921490

14931491
match fn_ret {
14941492
ty::FnConverging(t_ret)
1495-
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() => {
1496-
1497-
let param_env = ParameterEnvironment::for_item(&self.ir.tcx, id);
1498-
let infcx = infer::new_infer_ctxt(&self.ir.tcx,
1499-
&self.ir.tcx.tables,
1500-
Some(param_env),
1501-
ProjectionMode::Any);
1502-
let cause = traits::ObligationCause::dummy();
1503-
let norm = traits::fully_normalize(&infcx,
1504-
cause,
1505-
&t_ret);
1506-
1507-
if norm.unwrap().is_nil() {
1493+
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() => {
1494+
1495+
if t_ret.is_nil() {
15081496
// for nil return types, it is ok to not return a value expl.
15091497
} else {
15101498
let ends_with_stmt = match body.expr {

branches/beta/src/librustc_resolve/build_reduced_graph.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,36 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
105105
/// otherwise, reports an error.
106106
fn define<T: ToNameBinding<'b>>(&self, parent: Module<'b>, name: Name, ns: Namespace, def: T) {
107107
let binding = def.to_name_binding();
108-
if let Err(old_binding) = parent.try_define_child(name, ns, binding.clone()) {
109-
self.report_conflict(parent, name, ns, old_binding, &binding);
108+
let old_binding = match parent.try_define_child(name, ns, binding.clone()) {
109+
Ok(()) => return,
110+
Err(old_binding) => old_binding,
111+
};
112+
113+
let span = binding.span.unwrap_or(DUMMY_SP);
114+
if !old_binding.is_extern_crate() && !binding.is_extern_crate() {
115+
// Record an error here by looking up the namespace that had the duplicate
116+
let ns_str = match ns { TypeNS => "type or module", ValueNS => "value" };
117+
let resolution_error = ResolutionError::DuplicateDefinition(ns_str, name);
118+
let mut err = resolve_struct_error(self, span, resolution_error);
119+
120+
if let Some(sp) = old_binding.span {
121+
let note = format!("first definition of {} `{}` here", ns_str, name);
122+
err.span_note(sp, &note);
123+
}
124+
err.emit();
125+
} else if old_binding.is_extern_crate() && binding.is_extern_crate() {
126+
span_err!(self.session,
127+
span,
128+
E0259,
129+
"an external crate named `{}` has already been imported into this module",
130+
name);
131+
} else {
132+
span_err!(self.session,
133+
span,
134+
E0260,
135+
"the name `{}` conflicts with an external crate \
136+
that has been imported into this module",
137+
name);
110138
}
111139
}
112140

branches/beta/src/librustc_resolve/lib.rs

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ pub enum ResolutionError<'a> {
183183
UndeclaredLabel(&'a str),
184184
/// error E0427: cannot use `ref` binding mode with ...
185185
CannotUseRefBindingModeWith(&'a str),
186+
/// error E0428: duplicate definition
187+
DuplicateDefinition(&'a str, Name),
186188
/// error E0429: `self` imports are only allowed within a { } list
187189
SelfImportsOnlyAllowedWithin,
188190
/// error E0430: `self` import can only appear once in the list
@@ -488,6 +490,14 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
488490
"cannot use `ref` binding mode with {}",
489491
descr)
490492
}
493+
ResolutionError::DuplicateDefinition(namespace, name) => {
494+
struct_span_err!(resolver.session,
495+
span,
496+
E0428,
497+
"duplicate definition of {} `{}`",
498+
namespace,
499+
name)
500+
}
491501
ResolutionError::SelfImportsOnlyAllowedWithin => {
492502
struct_span_err!(resolver.session,
493503
span,
@@ -3520,63 +3530,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35203530
}
35213531
}
35223532
}
3523-
3524-
fn report_conflict(&self,
3525-
parent: Module,
3526-
name: Name,
3527-
ns: Namespace,
3528-
binding: &NameBinding,
3529-
old_binding: &NameBinding) {
3530-
// Error on the second of two conflicting names
3531-
if old_binding.span.unwrap().lo > binding.span.unwrap().lo {
3532-
return self.report_conflict(parent, name, ns, old_binding, binding);
3533-
}
3534-
3535-
let container = match parent.def {
3536-
Some(Def::Mod(_)) => "module",
3537-
Some(Def::Trait(_)) => "trait",
3538-
None => "block",
3539-
_ => "enum",
3540-
};
3541-
3542-
let (participle, noun) = match old_binding.is_import() || old_binding.is_extern_crate() {
3543-
true => ("imported", "import"),
3544-
false => ("defined", "definition"),
3545-
};
3546-
3547-
let span = binding.span.unwrap();
3548-
let msg = {
3549-
let kind = match (ns, old_binding.module()) {
3550-
(ValueNS, _) => "a value",
3551-
(TypeNS, Some(module)) if module.extern_crate_id.is_some() => "an extern crate",
3552-
(TypeNS, Some(module)) if module.is_normal() => "a module",
3553-
(TypeNS, Some(module)) if module.is_trait() => "a trait",
3554-
(TypeNS, _) => "a type",
3555-
};
3556-
format!("{} named `{}` has already been {} in this {}",
3557-
kind, name, participle, container)
3558-
};
3559-
3560-
let mut err = match (old_binding.is_extern_crate(), binding.is_extern_crate()) {
3561-
(true, true) => struct_span_err!(self.session, span, E0259, "{}", msg),
3562-
(true, _) | (_, true) if binding.is_import() || old_binding.is_import() =>
3563-
struct_span_err!(self.session, span, E0254, "{}", msg),
3564-
(true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg),
3565-
_ => match (old_binding.is_import(), binding.is_import()) {
3566-
(false, false) => struct_span_err!(self.session, span, E0428, "{}", msg),
3567-
(true, true) => struct_span_err!(self.session, span, E0252, "{}", msg),
3568-
_ => struct_span_err!(self.session, span, E0255, "{}", msg),
3569-
},
3570-
};
3571-
3572-
let span = old_binding.span.unwrap();
3573-
if span != codemap::DUMMY_SP {
3574-
err.span_note(span, &format!("previous {} of `{}` here", noun, name));
3575-
}
3576-
err.emit();
3577-
}
35783533
}
35793534

3535+
35803536
fn names_to_string(names: &[Name]) -> String {
35813537
let mut first = true;
35823538
let mut result = String::new();

branches/beta/src/librustc_resolve/resolve_imports.rs

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
513513
let imported_binding = directive.import(binding, privacy_error);
514514
let conflict = module_.try_define_child(target, ns, imported_binding);
515515
if let Err(old_binding) = conflict {
516-
let binding = &directive.import(binding, None);
517-
self.resolver.report_conflict(module_, target, ns, binding, old_binding);
516+
self.report_conflict(target, ns, &directive.import(binding, None), old_binding);
518517
}
519518
}
520519

@@ -651,6 +650,67 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
651650
return Success(());
652651
}
653652

653+
fn report_conflict(&mut self,
654+
name: Name,
655+
ns: Namespace,
656+
binding: &NameBinding,
657+
old_binding: &NameBinding) {
658+
// Error on the second of two conflicting imports
659+
if old_binding.is_import() && binding.is_import() &&
660+
old_binding.span.unwrap().lo > binding.span.unwrap().lo {
661+
self.report_conflict(name, ns, old_binding, binding);
662+
return;
663+
}
664+
665+
if old_binding.is_extern_crate() {
666+
let msg = format!("import `{0}` conflicts with imported crate \
667+
in this module (maybe you meant `use {0}::*`?)",
668+
name);
669+
span_err!(self.resolver.session, binding.span.unwrap(), E0254, "{}", &msg);
670+
} else if old_binding.is_import() {
671+
let ns_word = match (ns, old_binding.module()) {
672+
(ValueNS, _) => "value",
673+
(TypeNS, Some(module)) if module.is_normal() => "module",
674+
(TypeNS, Some(module)) if module.is_trait() => "trait",
675+
(TypeNS, _) => "type",
676+
};
677+
let mut err = struct_span_err!(self.resolver.session,
678+
binding.span.unwrap(),
679+
E0252,
680+
"a {} named `{}` has already been imported \
681+
in this module",
682+
ns_word,
683+
name);
684+
err.span_note(old_binding.span.unwrap(),
685+
&format!("previous import of `{}` here", name));
686+
err.emit();
687+
} else if ns == ValueNS { // Check for item conflicts in the value namespace
688+
let mut err = struct_span_err!(self.resolver.session,
689+
binding.span.unwrap(),
690+
E0255,
691+
"import `{}` conflicts with value in this module",
692+
name);
693+
err.span_note(old_binding.span.unwrap(), "conflicting value here");
694+
err.emit();
695+
} else { // Check for item conflicts in the type namespace
696+
let (what, note) = match old_binding.module() {
697+
Some(ref module) if module.is_normal() =>
698+
("existing submodule", "note conflicting module here"),
699+
Some(ref module) if module.is_trait() =>
700+
("trait in this module", "note conflicting trait here"),
701+
_ => ("type in this module", "note conflicting type here"),
702+
};
703+
let mut err = struct_span_err!(self.resolver.session,
704+
binding.span.unwrap(),
705+
E0256,
706+
"import `{}` conflicts with {}",
707+
name,
708+
what);
709+
err.span_note(old_binding.span.unwrap(), note);
710+
err.emit();
711+
}
712+
}
713+
654714
// Miscellaneous post-processing, including recording reexports, recording shadowed traits,
655715
// reporting conflicts, reporting the PRIVATE_IN_PUBLIC lint, and reporting unresolved imports.
656716
fn finalize_resolutions(&mut self, module: Module<'b>, report_unresolved_imports: bool) {
@@ -660,10 +720,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
660720

661721
let mut reexports = Vec::new();
662722
for (&(name, ns), resolution) in module.resolutions.borrow().iter() {
663-
resolution.report_conflicts(|b1, b2| {
664-
self.resolver.report_conflict(module, name, ns, b1, b2)
665-
});
666-
723+
resolution.report_conflicts(|b1, b2| self.report_conflict(name, ns, b1, b2));
667724
let binding = match resolution.binding {
668725
Some(binding) => binding,
669726
None => continue,

branches/beta/src/libstd/sys/unix/time.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ mod inner {
8888
-> Result<Duration, Duration> {
8989
if self >= other {
9090
Ok(if self.t.tv_usec >= other.t.tv_usec {
91-
Duration::new((self.t.tv_sec - other.t.tv_sec) as u64,
92-
((self.t.tv_usec -
93-
other.t.tv_usec) as u32) * 1000)
91+
Duration::new(self.t.tv_sec as u64 - other.t.tv_sec as u64,
92+
(self.t.tv_usec as u32 -
93+
other.t.tv_usec as u32) * 1000)
9494
} else {
95-
Duration::new((self.t.tv_sec - 1 - other.t.tv_sec) as u64,
95+
Duration::new(self.t.tv_sec as u64 - 1 - other.t.tv_sec as u64,
9696
(self.t.tv_usec as u32 + (USEC_PER_SEC as u32) -
9797
other.t.tv_usec as u32) * 1000)
9898
})

branches/beta/src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,7 @@ pub trait PrintState<'a> {
752752
}
753753
try!(self.maybe_print_comment(attr.span.lo));
754754
if attr.node.is_sugared_doc {
755-
try!(word(self.writer(), &attr.value_str().unwrap()));
756-
hardbreak(self.writer())
755+
word(self.writer(), &attr.value_str().unwrap())
757756
} else {
758757
match attr.node.style {
759758
ast::AttrStyle::Inner => try!(word(self.writer(), "#![")),

branches/beta/src/llvm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 63f3a1bfcd78355398a460712db25922247756b6
1+
Subproject commit be89e4b532fba8544f629c257460b63fe26c680d
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2016-03-15
4+
2016-03-13

branches/beta/src/test/compile-fail/blind-item-block-item-shadow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
{
1515
struct Bar;
1616
use foo::Bar;
17-
//~^ ERROR a type named `Bar` has already been defined in this block
18-
//~^^ ERROR a value named `Bar` has already been defined in this block
17+
//~^ ERROR import `Bar` conflicts with type in this module
18+
//~^^ ERROR import `Bar` conflicts with value in this module
1919
}
2020
}

branches/beta/src/test/compile-fail/blind-item-item-shadow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
mod foo { pub mod foo { } } //~ NOTE previous definition of `foo` here
11+
mod foo { pub mod foo { } }
1212

13-
use foo::foo; //~ ERROR a module named `foo` has already been defined in this module
13+
use foo::foo; //~ ERROR import `foo` conflicts with existing submodule
1414

1515
fn main() {}

branches/beta/src/test/compile-fail/enum-and-module-in-same-scope.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
enum Foo { //~ NOTE previous definition
11+
enum Foo {
1212
X
1313
}
1414

15-
mod Foo { //~ ERROR a type named `Foo` has already been defined
15+
mod Foo { //~ ERROR duplicate definition of type or module `Foo`
1616
pub static X: isize = 42;
1717
fn f() { f() } // Check that this does not result in a resolution error
1818
}

branches/beta/src/test/compile-fail/issue-19498.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use self::A; //~ NOTE previous import of `A` here
12-
use self::B; //~ NOTE previous import of `B` here
13-
mod A {} //~ ERROR a module named `A` has already been imported in this module
14-
pub mod B {} //~ ERROR a module named `B` has already been imported in this module
11+
use self::A; //~ ERROR import `A` conflicts with existing submodule
12+
use self::B; //~ ERROR import `B` conflicts with existing submodule
13+
mod A {}
14+
pub mod B {}
1515

1616
mod C {
17-
use C::D; //~ NOTE previous import of `D` here
18-
mod D {} //~ ERROR a module named `D` has already been imported in this module
17+
use C::D; //~ ERROR import `D` conflicts with existing submodule
18+
mod D {}
1919
}
2020

2121
fn main() {}

0 commit comments

Comments
 (0)