Skip to content

Remove typestate from the language #2588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
372 changes: 15 additions & 357 deletions doc/rust.md

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ ifeq ($(CFG_C_COMPILER),clang)
endif
CFG_GCCISH_CFLAGS += -Wall -Werror -fno-rtti -g
CFG_GCCISH_LINK_FLAGS += -g
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
-MM $(2)
# These flags will cause the compiler to produce a .d file
# next to the .o file that lists header deps.
CFG_DEPEND_FLAGS = -MMD -MP -MT $(1) -MF $(1:%.o=%.d)

define CFG_MAKE_CC
CFG_COMPILE_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_CFLAGS) $$(CFG_CLANG_CFLAGS) \
$$(CFG_GCCISH_CFLAGS_$$(HOST_$(1))) \
$$(CFG_CLANG_CFLAGS_$$(HOST_$(1))) \
$$(CFG_DEPEND_FLAGS) \
-c -o $$(1) $$(2)
CFG_LINK_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
Expand All @@ -245,15 +247,17 @@ ifeq ($(CFG_C_COMPILER),gcc)
endif
CFG_GCCISH_CFLAGS += -Wall -Werror -fno-rtti -g
CFG_GCCISH_LINK_FLAGS += -g
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
-MM $(2)
# These flags will cause the compiler to produce a .d file
# next to the .o file that lists header deps.
CFG_DEPEND_FLAGS = -MMD -MP -MT $(1) -MF $(1:%.o=%.d)

define CFG_MAKE_CC
CFG_COMPILE_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_CFLAGS) \
$$(CFG_GCCISH_CFLAGS_$$(HOST_$(1))) \
$$(CFG_GCC_CFLAGS) \
$$(CFG_GCC_CFLAGS_$$(HOST_$(1))) \
$$(CFG_DEPEND_FLAGS) \
-c -o $$(1) $$(2)
CFG_LINK_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
Expand All @@ -272,7 +276,7 @@ endif
# We're using llvm-mc as our assembler because it supports
# .cfi pseudo-ops on mac
define CFG_MAKE_ASSEMBLER
CFG_ASSEMBLE_$(1)=$$(CPP) $$(2) | \
CFG_ASSEMBLE_$(1)=$$(CPP) $$(CFG_DEPEND_FLAGS) $$(2) | \
$$(LLVM_MC_$$(CFG_HOST_TRIPLE)) \
-assemble \
-filetype=obj \
Expand Down
26 changes: 9 additions & 17 deletions mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ RUNTIME_S_$(1) := rt/arch/$$(HOST_$(1))/_context.S \
rt/arch/$$(HOST_$(1))/ccall.S \
rt/arch/$$(HOST_$(1))/record_sp.S

RUNTIME_HDR_$(1) := $$(wildcard \
rt/*.h \
rt/bigint/*.h \
rt/isaac/*.h \
rt/msvc/*.h \
rt/sync/*.h \
rt/uthash/*.h \
rt/util/*.h \
rt/vg/*.h \
rt/arch/$$(HOST_$(1))/*.h)

ifeq ($$(HOST_$(1)), i386)
LIBUV_ARCH_$(1) := ia32
else
Expand All @@ -116,14 +105,17 @@ RUNTIME_INCS_$(1) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
-I $$(S)src/libuv/include
RUNTIME_OBJS_$(1) := $$(RUNTIME_CS_$(1):rt/%.cpp=rt/$(1)/%.o) \
$$(RUNTIME_S_$(1):rt/%.S=rt/$(1)/%.o)
RUNTIME_DEP_FILES_$(1) := $$(RUNTIME_OBJS_$(1):%.o=%.d)
-include $$(RUNTIME_DEP_FILES_$(1))

RUNTIME_LIBS_$(1) := $$(LIBUV_LIB_$(1))

rt/$(1)/%.o: rt/%.cpp $$(RUNTIME_HDR_$(1)) $$(MKFILE_DEPS)
rt/$(1)/%.o: rt/%.cpp $$(MKFILE_DEPS)
@$$(call E, compile: $$@)
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(RUNTIME_INCS_$(1)) \
$$(SNAP_DEFINES)) $$<

rt/$(1)/%.o: rt/%.S $$(RUNTIME_HDR_$(1)) $$(MKFILE_DEPS) \
rt/$(1)/%.o: rt/%.S $$(MKFILE_DEPS) \
$$(LLVM_CONFIG_$$(CFG_HOST_TRIPLE))
@$$(call E, compile: $$@)
$$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<)
Expand All @@ -134,17 +126,17 @@ rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a: \
$$(Q)ar rcs $$@ $$<

rt/$(1)/$(CFG_RUNTIME): $$(RUNTIME_OBJS_$(1)) $$(MKFILE_DEPS) \
$$(RUNTIME_HDR_$(1)) \
$$(RUNTIME_DEF_$(1)) \
$$(RUNTIME_LIBS_$(1))
@$$(call E, link: $$@)
$$(Q)$$(call CFG_LINK_C_$(1),$$@, $$(RUNTIME_OBJS_$(1)) \
$$(CFG_GCCISH_POST_LIB_FLAGS) $$(RUNTIME_LIBS_$(1)) \
$$(CFG_LIBUV_LINK_FLAGS),$$(RUNTIME_DEF_$(1)),$$(CFG_RUNTIME))

# FIXME: For some reason libuv's makefiles can't figure out the correct definition
# of CC on the mingw I'm using, so we are explicitly using gcc. Also, we
# have to list environment variables first on windows... mysterious
# FIXME: For some reason libuv's makefiles can't figure out the
# correct definition of CC on the mingw I'm using, so we are
# explicitly using gcc. Also, we have to list environment variables
# first on windows... mysterious

ifdef CFG_ENABLE_FAST_MAKE
LIBUV_DEPS := $$(S)/.gitmodules
Expand Down
7 changes: 2 additions & 5 deletions mk/rustllvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ endif

RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, RustWrapper.cpp)

# Behind an ifdef for now since this requires a patched LLVM.
ifdef CFG_STACK_GROWTH
RUSTLLVM_OBJS_CS_$(1) += rustllvm/RustPrologHook.cpp
endif

RUSTLLVM_DEF_$(1) := rustllvm/rustllvm$$(CFG_DEF_SUFFIX)

RUSTLLVM_INCS_$(1) = $$(LLVM_EXTRA_INCDIRS_$(1)) \
-iquote $$(LLVM_INCDIR_$(1)) \
-iquote $$(S)src/rustllvm/include
RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=rustllvm/$(1)/%.o)
RUSTLLVM_DEP_FILES_$(1) := $$(RUSTLLVM_OBJS_OBJS_$(1):%.o=%.d)
-include $$(RUSTLLVM_DEP_FILES_$(1))

rustllvm/$(1)/$(CFG_RUSTLLVM): $$(RUSTLLVM_OBJS_OBJS_$(1)) \
$$(MKFILE_DEPS) $$(RUSTLLVM_DEF_$(1))
Expand Down
33 changes: 16 additions & 17 deletions src/cargo/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ fn load_link(mis: [@ast::meta_item]) -> (option<str>,
for mis.each {|a|
alt a.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v {
"name" { name = some(s); }
"vers" { vers = some(s); }
"uuid" { uuid = some(s); }
alt *v {
"name" { name = some(*s); }
"vers" { vers = some(*s); }
"uuid" { uuid = some(*s); }
_ { }
}
}
Expand Down Expand Up @@ -259,15 +259,15 @@ fn load_crate(filename: str) -> option<crate> {
for c.node.attrs.each {|a|
alt a.node.value.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v {
"desc" { desc = some(v); }
"sigs" { sigs = some(v); }
"crate_type" { crate_type = some(v); }
alt *v {
"desc" { desc = some(*v); }
"sigs" { sigs = some(*v); }
"crate_type" { crate_type = some(*v); }
_ { }
}
}
ast::meta_list(v, mis) {
if v == "link" {
if *v == "link" {
let (n, v, u) = load_link(mis);
name = n;
vers = v;
Expand All @@ -290,7 +290,7 @@ fn load_crate(filename: str) -> option<crate> {
ast::view_item_use(ident, metas, id) {
let name_items = attr::find_meta_items_by_name(metas, "name");
let m = if name_items.is_empty() {
metas + [attr::mk_name_value_item_str("name", ident)]
metas + [attr::mk_name_value_item_str(@"name", *ident)]
} else {
metas
};
Expand All @@ -303,9 +303,9 @@ fn load_crate(filename: str) -> option<crate> {
some(value) {
let name = attr::get_meta_item_name(item);

alt name {
"vers" { attr_vers = value; }
"from" { attr_from = value; }
alt *name {
"vers" { attr_vers = *value; }
"from" { attr_from = *value; }
_ {}
}
}
Expand All @@ -317,11 +317,11 @@ fn load_crate(filename: str) -> option<crate> {
attr_from
} else {
if !str::is_empty(attr_vers) {
attr_name + "@" + attr_vers
} else { attr_name }
*attr_name + "@" + attr_vers
} else { *attr_name }
};

alt attr_name {
alt *attr_name {
"std" | "core" { }
_ { e.deps += [query]; }
}
Expand Down Expand Up @@ -766,7 +766,6 @@ fn rustc_sysroot() -> str {
alt os::self_exe_path() {
some(path) {
let path = [path, "..", "bin", "rustc"];
check vec::is_not_empty(path);
let rustc = path::normalize(path::connect_many(path));
#debug(" rustc: %s", rustc);
rustc
Expand Down
1 change: 0 additions & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ fn parse_config(args: [str]) -> config {
getopts::optflag("verbose"),
getopts::optopt("logfile")];

check (vec::is_not_empty(args));
let args_ = vec::tail(args);
let match =
alt getopts::getopts(args_, opts) {
Expand Down
1 change: 0 additions & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) {
if option::is_some(props.pp_exact) {
// Now we have to care about line endings
let cr = "\r";
check (str::is_not_empty(cr));
actual = str::replace(actual, cr, "");
expected = str::replace(expected, cr, "");
}
Expand Down
5 changes: 1 addition & 4 deletions src/fuzzer/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn common_exprs() -> [ast::expr] {
dse(ast::expr_cont),
dse(ast::expr_fail(option::none)),
dse(ast::expr_fail(option::some(
@dse(ast::expr_lit(@dsl(ast::lit_str("boo"))))))),
@dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))),
dse(ast::expr_ret(option::none)),
dse(ast::expr_lit(@dsl(ast::lit_nil))),
dse(ast::expr_lit(@dsl(ast::lit_bool(false)))),
Expand All @@ -69,7 +69,6 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
// position, the pretty-printer can't preserve this even by
// parenthesizing!! See email to marijn.
ast::expr_if(_, _, _) { false }
ast::expr_if_check(_, _, _) { false }
ast::expr_block(_) { false }
ast::expr_alt(_, _, _) { false }
ast::expr_while(_, _) { false }
Expand All @@ -89,7 +88,6 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {

// https://github.com/mozilla/rust/issues/927
//ast::expr_assert(_) { false }
ast::expr_check(_, _) { false }

// https://github.com/mozilla/rust/issues/928
//ast::expr_cast(_, _) { false }
Expand All @@ -107,7 +105,6 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
fn safe_to_steal_ty(t: @ast::ty, tm: test_mode) -> bool {
alt t.node {
// https://github.com/mozilla/rust/issues/971
ast::ty_constr(_, _) { false }

// Other restrictions happen to be the same.
_ { safe_to_replace_ty(t.node, tm) }
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn normalize(p: path) -> path {
let s = strip_dots(s);
let s = rollup_doubledots(s);

let s = if check vec::is_not_empty(s) {
let s = if vec::is_not_empty(s) {
connect_many(s)
} else {
""
Expand Down
7 changes: 5 additions & 2 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ library, a precondition is used here because result::t is generally
used in 'careful' code contexts where it is both appropriate and easy
to accommodate an error like the vectors being of different lengths."]
fn map_vec2<S,T,U:copy,V:copy>(ss: [S], ts: [T], op: fn(S,T) -> result<V,U>)
: vec::same_length(ss, ts) -> result<[V],U> {
-> result<[V],U> {

assert vec::same_length(ss, ts);

let n = vec::len(ts);
let mut vs = [];
Expand All @@ -302,9 +304,10 @@ on its own as no result vector is built.
"]
fn iter_vec2<S,T,U:copy>(ss: [S], ts: [T],
op: fn(S,T) -> result<(),U>)
: vec::same_length(ss, ts)
-> result<(),U> {

assert vec::same_length(ss, ts);

let n = vec::len(ts);
let mut i = 0u;
while i < n {
Expand Down
6 changes: 6 additions & 0 deletions src/libstd/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import chained::hashmap;
export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash;
export box_str_hash;
export bytes_hash, int_hash, uint_hash, set_add;
export hash_from_vec, hash_from_strs, hash_from_bytes;
export hash_from_ints, hash_from_uints;
Expand Down Expand Up @@ -292,6 +293,11 @@ fn str_hash<V: copy>() -> hashmap<str, V> {
ret hashmap(str::hash, str::eq);
}

#[doc = "Construct a hashmap for boxed string keys"]
fn box_str_hash<V: copy>() -> hashmap<@str, V> {
ret hashmap({|x: @str|str::hash(*x)}, {|x,y|str::eq(*x,*y)});
}

#[doc = "Construct a hashmap for byte string keys"]
fn bytes_hash<V: copy>() -> hashmap<[u8], V> {
ret hashmap(vec::u8::hash, vec::u8::eq);
Expand Down
Loading