Skip to content

Commit 775c7a5

Browse files
committed
---
yaml --- r: 60086 b: refs/heads/master c: 86500fb h: refs/heads/master v: v3
1 parent a785583 commit 775c7a5

File tree

6 files changed

+210
-164
lines changed

6 files changed

+210
-164
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 80061ecb1d11afd7c450673676e7708f85b73f12
2+
refs/heads/master: 86500fbb134032ed28129272ef9fb3873934dd1b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/libcore/rt/mod.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,22 @@ mod local_heap;
3838
pub mod test;
3939

4040
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
41-
4241
use self::sched::{Scheduler, Task};
4342
use self::uvio::UvEventLoop;
44-
use sys::Closure;
45-
use ptr;
46-
use cast;
4743

4844
let loop_ = ~UvEventLoop::new();
4945
let mut sched = ~Scheduler::new(loop_);
50-
5146
let main_task = ~do Task::new(&mut sched.stack_pool) {
52-
53-
unsafe {
54-
// `main` is an `fn() -> ()` that doesn't take an environment
55-
// XXX: Could also call this as an `extern "Rust" fn` once they work
56-
let main = Closure {
57-
code: main as *(),
58-
env: ptr::null(),
59-
};
60-
let mainfn: &fn() = cast::transmute(main);
61-
62-
mainfn();
63-
}
47+
// XXX: Can't call a C function pointer from Rust yet
48+
unsafe { rust_call_nullary_fn(main) };
6449
};
65-
6650
sched.task_queue.push_back(main_task);
6751
sched.run();
68-
6952
return 0;
53+
54+
extern {
55+
fn rust_call_nullary_fn(f: *u8);
56+
}
7057
}
7158

7259
/// Possible contexts in which Rust code may be executing.

trunk/src/librustc/middle/lint.rs

Lines changed: 145 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -90,156 +90,157 @@ struct LintSpec {
9090

9191
pub type LintDict = @HashMap<~str, LintSpec>;
9292

93+
static lint_table: &'static [(&'static str, LintSpec)] = &[
94+
("ctypes",
95+
LintSpec {
96+
lint: ctypes,
97+
desc: "proper use of core::libc types in foreign modules",
98+
default: warn
99+
}),
100+
101+
("unused_imports",
102+
LintSpec {
103+
lint: unused_imports,
104+
desc: "imports that are never used",
105+
default: warn
106+
}),
107+
108+
("while_true",
109+
LintSpec {
110+
lint: while_true,
111+
desc: "suggest using loop { } instead of while(true) { }",
112+
default: warn
113+
}),
114+
115+
("path_statement",
116+
LintSpec {
117+
lint: path_statement,
118+
desc: "path statements with no effect",
119+
default: warn
120+
}),
121+
122+
("unrecognized_lint",
123+
LintSpec {
124+
lint: unrecognized_lint,
125+
desc: "unrecognized lint attribute",
126+
default: warn
127+
}),
128+
129+
("non_implicitly_copyable_typarams",
130+
LintSpec {
131+
lint: non_implicitly_copyable_typarams,
132+
desc: "passing non implicitly copyable types as copy type params",
133+
default: warn
134+
}),
135+
136+
("vecs_implicitly_copyable",
137+
LintSpec {
138+
lint: vecs_implicitly_copyable,
139+
desc: "make vecs and strs not implicitly copyable \
140+
(only checked at top level)",
141+
default: warn
142+
}),
143+
144+
("implicit_copies",
145+
LintSpec {
146+
lint: implicit_copies,
147+
desc: "implicit copies of non implicitly copyable data",
148+
default: warn
149+
}),
150+
151+
("deprecated_pattern",
152+
LintSpec {
153+
lint: deprecated_pattern,
154+
desc: "warn about deprecated uses of pattern bindings",
155+
default: allow
156+
}),
157+
158+
("non_camel_case_types",
159+
LintSpec {
160+
lint: non_camel_case_types,
161+
desc: "types, variants and traits should have camel case names",
162+
default: allow
163+
}),
164+
165+
("managed_heap_memory",
166+
LintSpec {
167+
lint: managed_heap_memory,
168+
desc: "use of managed (@ type) heap memory",
169+
default: allow
170+
}),
171+
172+
("owned_heap_memory",
173+
LintSpec {
174+
lint: owned_heap_memory,
175+
desc: "use of owned (~ type) heap memory",
176+
default: allow
177+
}),
178+
179+
("heap_memory",
180+
LintSpec {
181+
lint: heap_memory,
182+
desc: "use of any (~ type or @ type) heap memory",
183+
default: allow
184+
}),
185+
186+
("type_limits",
187+
LintSpec {
188+
lint: type_limits,
189+
desc: "comparisons made useless by limits of the types involved",
190+
default: warn
191+
}),
192+
193+
("default_methods",
194+
LintSpec {
195+
lint: default_methods,
196+
desc: "allow default methods",
197+
default: deny
198+
}),
199+
200+
("deprecated_mutable_fields",
201+
LintSpec {
202+
lint: deprecated_mutable_fields,
203+
desc: "deprecated mutable fields in structures",
204+
default: deny
205+
}),
206+
207+
("unused_unsafe",
208+
LintSpec {
209+
lint: unused_unsafe,
210+
desc: "unnecessary use of an `unsafe` block",
211+
default: warn
212+
}),
213+
214+
("unused_variable",
215+
LintSpec {
216+
lint: unused_variable,
217+
desc: "detect variables which are not used in any way",
218+
default: warn
219+
}),
220+
221+
("dead_assignment",
222+
LintSpec {
223+
lint: dead_assignment,
224+
desc: "detect assignments that will never be read",
225+
default: warn
226+
}),
227+
228+
("unused_mut",
229+
LintSpec {
230+
lint: unused_mut,
231+
desc: "detect mut variables which don't need to be mutable",
232+
default: warn
233+
}),
234+
];
235+
93236
/*
94237
Pass names should not contain a '-', as the compiler normalizes
95238
'-' to '_' in command-line flags
96239
*/
97240
pub fn get_lint_dict() -> LintDict {
98-
let v = ~[
99-
(~"ctypes",
100-
LintSpec {
101-
lint: ctypes,
102-
desc: "proper use of core::libc types in foreign modules",
103-
default: warn
104-
}),
105-
106-
(~"unused_imports",
107-
LintSpec {
108-
lint: unused_imports,
109-
desc: "imports that are never used",
110-
default: warn
111-
}),
112-
113-
(~"while_true",
114-
LintSpec {
115-
lint: while_true,
116-
desc: "suggest using loop { } instead of while(true) { }",
117-
default: warn
118-
}),
119-
120-
(~"path_statement",
121-
LintSpec {
122-
lint: path_statement,
123-
desc: "path statements with no effect",
124-
default: warn
125-
}),
126-
127-
(~"unrecognized_lint",
128-
LintSpec {
129-
lint: unrecognized_lint,
130-
desc: "unrecognized lint attribute",
131-
default: warn
132-
}),
133-
134-
(~"non_implicitly_copyable_typarams",
135-
LintSpec {
136-
lint: non_implicitly_copyable_typarams,
137-
desc: "passing non implicitly copyable types as copy type params",
138-
default: warn
139-
}),
140-
141-
(~"vecs_implicitly_copyable",
142-
LintSpec {
143-
lint: vecs_implicitly_copyable,
144-
desc: "make vecs and strs not implicitly copyable \
145-
(only checked at top level)",
146-
default: warn
147-
}),
148-
149-
(~"implicit_copies",
150-
LintSpec {
151-
lint: implicit_copies,
152-
desc: "implicit copies of non implicitly copyable data",
153-
default: warn
154-
}),
155-
156-
(~"deprecated_pattern",
157-
LintSpec {
158-
lint: deprecated_pattern,
159-
desc: "warn about deprecated uses of pattern bindings",
160-
default: allow
161-
}),
162-
163-
(~"non_camel_case_types",
164-
LintSpec {
165-
lint: non_camel_case_types,
166-
desc: "types, variants and traits should have camel case names",
167-
default: allow
168-
}),
169-
170-
(~"managed_heap_memory",
171-
LintSpec {
172-
lint: managed_heap_memory,
173-
desc: "use of managed (@ type) heap memory",
174-
default: allow
175-
}),
176-
177-
(~"owned_heap_memory",
178-
LintSpec {
179-
lint: owned_heap_memory,
180-
desc: "use of owned (~ type) heap memory",
181-
default: allow
182-
}),
183-
184-
(~"heap_memory",
185-
LintSpec {
186-
lint: heap_memory,
187-
desc: "use of any (~ type or @ type) heap memory",
188-
default: allow
189-
}),
190-
191-
(~"type_limits",
192-
LintSpec {
193-
lint: type_limits,
194-
desc: "comparisons made useless by limits of the types involved",
195-
default: warn
196-
}),
197-
198-
(~"default_methods",
199-
LintSpec {
200-
lint: default_methods,
201-
desc: "allow default methods",
202-
default: deny
203-
}),
204-
205-
(~"deprecated_mutable_fields",
206-
LintSpec {
207-
lint: deprecated_mutable_fields,
208-
desc: "deprecated mutable fields in structures",
209-
default: deny
210-
}),
211-
212-
(~"unused_unsafe",
213-
LintSpec {
214-
lint: unused_unsafe,
215-
desc: "unnecessary use of an `unsafe` block",
216-
default: warn
217-
}),
218-
219-
(~"unused_variable",
220-
LintSpec {
221-
lint: unused_variable,
222-
desc: "detect variables which are not used in any way",
223-
default: warn
224-
}),
225-
226-
(~"dead_assignment",
227-
LintSpec {
228-
lint: dead_assignment,
229-
desc: "detect assignments that will never be read",
230-
default: warn
231-
}),
232-
233-
(~"unused_mut",
234-
LintSpec {
235-
lint: unused_mut,
236-
desc: "detect mut variables which don't need to be mutable",
237-
default: warn
238-
}),
239-
];
240241
let mut map = HashMap::new();
241-
do vec::consume(v) |_, (k, v)| {
242-
map.insert(k, v);
242+
for lint_table.each|&(k, v)| {
243+
map.insert(k.to_str(), v);
243244
}
244245
return @map;
245246
}

trunk/src/rt/rust_builtin.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,13 @@ rust_get_rt_env() {
830830
return task->kernel->env;
831831
}
832832

833+
typedef void *(*nullary_fn)();
834+
835+
extern "C" CDECL void
836+
rust_call_nullary_fn(nullary_fn f) {
837+
f();
838+
}
839+
833840
#ifndef _WIN32
834841
pthread_key_t sched_key;
835842
#else

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ rust_uv_ip4_addrp
222222
rust_uv_ip6_addrp
223223
rust_uv_free_ip4_addr
224224
rust_uv_free_ip6_addr
225+
rust_call_nullary_fn
225226
rust_initialize_global_state
226227
rust_dbg_next_port
227228
rust_new_memory_region

0 commit comments

Comments
 (0)