Skip to content

Commit 78b48e1

Browse files
committed
---
yaml --- r: 63192 b: refs/heads/snap-stage3 c: febba9f h: refs/heads/master v: v3
1 parent 02e04f3 commit 78b48e1

File tree

4 files changed

+44
-45
lines changed

4 files changed

+44
-45
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: df5b0c040c744879705b4c37be3bb1cbe7282ab2
4+
refs/heads/snap-stage3: febba9f41803e5a782c912131a9e26193ef0ced8
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/resolve.rs

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@ pub enum DuplicateCheckingMode {
294294
OverwriteDuplicates
295295
}
296296

297+
// Returns the namespace associated with the given duplicate checking mode,
298+
// or fails for OverwriteDuplicates. This is used for error messages.
299+
pub fn namespace_for_duplicate_checking_mode(mode: DuplicateCheckingMode)
300+
-> Namespace {
301+
match mode {
302+
ForbidDuplicateModules | ForbidDuplicateTypes |
303+
ForbidDuplicateTypesAndValues => TypeNS,
304+
ForbidDuplicateValues => ValueNS,
305+
OverwriteDuplicates => fail!("OverwriteDuplicates has no namespace")
306+
}
307+
}
308+
297309
/// One local scope.
298310
pub struct Rib {
299311
bindings: @mut HashMap<ident,def_like>,
@@ -995,43 +1007,37 @@ impl Resolver {
9951007
// nothing.
9961008

9971009
let mut is_duplicate = false;
998-
let ns = match duplicate_checking_mode {
1010+
match duplicate_checking_mode {
9991011
ForbidDuplicateModules => {
1000-
is_duplicate = child.get_module_if_available().is_some();
1001-
Some(TypeNS)
1012+
is_duplicate =
1013+
child.get_module_if_available().is_some();
10021014
}
10031015
ForbidDuplicateTypes => {
10041016
match child.def_for_namespace(TypeNS) {
10051017
Some(def_mod(_)) | None => {}
10061018
Some(_) => is_duplicate = true
10071019
}
1008-
Some(TypeNS)
10091020
}
10101021
ForbidDuplicateValues => {
10111022
is_duplicate = child.defined_in_namespace(ValueNS);
1012-
Some(ValueNS)
10131023
}
10141024
ForbidDuplicateTypesAndValues => {
1015-
let mut n = None;
10161025
match child.def_for_namespace(TypeNS) {
10171026
Some(def_mod(_)) | None => {}
1018-
Some(_) => {
1019-
n = Some(TypeNS);
1020-
is_duplicate = true;
1021-
}
1027+
Some(_) => is_duplicate = true
10221028
};
10231029
if child.defined_in_namespace(ValueNS) {
10241030
is_duplicate = true;
1025-
n = Some(ValueNS);
10261031
}
1027-
n
10281032
}
1029-
OverwriteDuplicates => None
1030-
};
1031-
if is_duplicate {
1033+
OverwriteDuplicates => {}
1034+
}
1035+
if duplicate_checking_mode != OverwriteDuplicates &&
1036+
is_duplicate {
10321037
// Return an error here by looking up the namespace that
10331038
// had the duplicate.
1034-
let ns = ns.unwrap();
1039+
let ns = namespace_for_duplicate_checking_mode(
1040+
duplicate_checking_mode);
10351041
self.session.span_err(sp,
10361042
fmt!("duplicate definition of %s `%s`",
10371043
namespace_to_str(ns),
@@ -1189,22 +1195,22 @@ impl Resolver {
11891195

11901196
// These items live in both the type and value namespaces.
11911197
item_struct(struct_def, _) => {
1192-
// Adding to both Type and Value namespaces or just Type?
1193-
let (forbid, ctor_id) = match struct_def.ctor_id {
1194-
Some(ctor_id) => (ForbidDuplicateTypesAndValues, Some(ctor_id)),
1195-
None => (ForbidDuplicateTypes, None)
1196-
};
1197-
1198-
let (name_bindings, new_parent) = self.add_child(ident, parent, forbid, sp);
1198+
let (name_bindings, new_parent) =
1199+
self.add_child(ident, parent, ForbidDuplicateTypes, sp);
11991200

1200-
// Define a name in the type namespace.
1201-
name_bindings.define_type(privacy, def_ty(local_def(item.id)), sp);
1201+
name_bindings.define_type(
1202+
privacy, def_ty(local_def(item.id)), sp);
12021203

1203-
// If this is a newtype or unit-like struct, define a name
1204-
// in the value namespace as well
1205-
do ctor_id.while_some |cid| {
1206-
name_bindings.define_value(privacy, def_struct(local_def(cid)), sp);
1207-
None
1204+
// If this struct is tuple-like or enum-like, define a name
1205+
// in the value namespace.
1206+
match struct_def.ctor_id {
1207+
None => {}
1208+
Some(ctor_id) => {
1209+
name_bindings.define_value(
1210+
privacy,
1211+
def_struct(local_def(ctor_id)),
1212+
sp);
1213+
}
12081214
}
12091215

12101216
// Record the def ID of this struct.

branches/snap-stage3/src/rt/rust_android_dummy.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,11 @@ extern "C" void globfree(glob_t *pglob)
7676
{
7777
}
7878

79+
extern "C" int pthread_atfork(void (*prefork)(void),
80+
void (*postfork_parent)(void),
81+
void (*postfork_child)(void))
82+
{
83+
return 0;
84+
}
85+
7986
#endif

branches/snap-stage3/src/test/compile-fail/issue-7044.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)