Skip to content

Assert #5499

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 2 commits into from
Closed

Assert #5499

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
2 changes: 1 addition & 1 deletion src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn test() {
}
}

fail_unless!(seq_range(10, 15) == @[10, 11, 12, 13, 14]);
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
fail_unless!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
fail_unless!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/rt/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl Task {
};
}

static priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
// XXX: The old code didn't have this extra allocation
let wrapper: ~fn() = || {
start();
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/rustpkg.rc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct PackageScript {
}

impl PackageScript {
static fn parse(parent: &Path) -> Result<PackageScript, ~str> {
fn parse(parent: &Path) -> Result<PackageScript, ~str> {
let script = parent.push(~"pkg.rs");

if !os::path_exists(&script) {
Expand Down
13 changes: 13 additions & 0 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,19 @@ pub fn core_macros() -> ~str {
}
)

macro_rules! assert(
($cond:expr) => {
if !$cond {
::core::sys::fail_assert(stringify!($cond), file!(), line!())
}
};
($cond:expr, $msg:expr) => {
if !$cond {
::core::sys::fail_assert($msg, file!(), line!())
}
}
)

macro_rules! assert_eq (
($given:expr , $expected:expr) =>
({let given_val = $given;
Expand Down
15 changes: 10 additions & 5 deletions src/libsyntax/parse/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ pub enum ObsoleteSyntax {
ObsoleteTraitImplVisibility,
ObsoleteRecordType,
ObsoleteRecordPattern,
ObsoleteAssertion,
ObsoletePostFnTySigil,
ObsoleteBareFnType,
ObsoleteNewtypeEnum,
ObsoleteMode,
ObsoleteImplicitSelf,
ObsoleteLifetimeNotation,
ObsoleteConstManagedPointer,
ObsoletePurity,
ObsoleteStaticMethod,
}

impl to_bytes::IterBytes for ObsoleteSyntax {
Expand Down Expand Up @@ -163,10 +164,6 @@ pub impl Parser {
"structural record pattern",
"use a structure instead"
),
ObsoleteAssertion => (
"assertion",
"use `fail_unless!()` instead"
),
ObsoletePostFnTySigil => (
"fn sigil in postfix position",
"Rather than `fn@`, `fn~`, or `fn&`, \
Expand Down Expand Up @@ -198,6 +195,14 @@ pub impl Parser {
"const `@` pointer",
"instead of `@const Foo`, write `@Foo`"
),
ObsoletePurity => (
"pure function",
"remove `pure`"
),
ObsoleteStaticMethod => (
"`static` notation",
"`static` is superfluous; remove it"
),
};

self.report(sp, kind, kind_str, desc);
Expand Down
22 changes: 13 additions & 9 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
use parse::obsolete::{ObsoletePostFnTySigil};
use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum};
use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf};
use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer};
use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
use parse::prec::{as_prec, token_to_binop};
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
Expand Down Expand Up @@ -413,7 +414,7 @@ pub impl Parser {

fn parse_purity(&self) -> purity {
if self.eat_keyword(&~"pure") {
// NB: We parse this as impure for bootstrapping purposes.
self.obsolete(*self.last_span, ObsoletePurity);
return impure_fn;
} else if self.eat_keyword(&~"unsafe") {
return unsafe_fn;
Expand Down Expand Up @@ -1216,10 +1217,6 @@ pub impl Parser {
ex = expr_log(ast::log_other, lvl, e);
hi = self.span.hi;
self.expect(&token::RPAREN);
} else if self.eat_keyword(&~"assert") {
let e = self.parse_expr();
ex = expr_copy(e); // whatever
self.obsolete(*self.last_span, ObsoleteAssertion);
} else if self.eat_keyword(&~"return") {
if can_begin_expr(&*self.token) {
let e = self.parse_expr();
Expand Down Expand Up @@ -2684,7 +2681,7 @@ pub impl Parser {

fn parse_optional_purity(&self) -> ast::purity {
if self.eat_keyword(&~"pure") {
// NB: We parse this as impure for bootstrapping purposes.
self.obsolete(*self.last_span, ObsoletePurity);
ast::impure_fn
} else if self.eat_keyword(&~"unsafe") {
ast::unsafe_fn
Expand Down Expand Up @@ -3338,8 +3335,14 @@ pub impl Parser {
else if self.eat_keyword(&~"priv") { private }
else { inherited }
}

fn parse_staticness(&self) -> bool {
self.eat_keyword(&~"static")
if self.eat_keyword(&~"static") {
self.obsolete(*self.last_span, ObsoleteStaticMethod);
true
} else {
false
}
}

// given a termination token and a vector of already-parsed
Expand Down Expand Up @@ -3577,6 +3580,7 @@ pub impl Parser {
fn parse_fn_purity(&self) -> purity {
if self.eat_keyword(&~"fn") { impure_fn }
else if self.eat_keyword(&~"pure") {
self.obsolete(*self.last_span, ObsoletePurity);
self.expect_keyword(&~"fn");
// NB: We parse this as impure for bootstrapping purposes.
impure_fn
Expand Down Expand Up @@ -3976,7 +3980,7 @@ pub impl Parser {
}
if items_allowed && self.eat_keyword(&~"pure") {
// PURE FUNCTION ITEM
// NB: We parse this as impure for bootstrapping purposes.
self.obsolete(*self.last_span, ObsoletePurity);
self.expect_keyword(&~"fn");
let (ident, item_, extra_attrs) = self.parse_item_fn(impure_fn);
return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ pub fn temporary_keyword_table() -> HashMap<~str, ()> {
pub fn strict_keyword_table() -> HashMap<~str, ()> {
let words = HashMap();
let keys = ~[
~"as", ~"assert",
~"as",
~"break",
~"const", ~"copy",
~"do", ~"drop",
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/static_fn_inline_xc_aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

pub mod num {
pub trait Num2 {
static fn from_int2(n: int) -> Self;
fn from_int2(n: int) -> Self;
}
}

pub mod float {
impl ::num::Num2 for float {
#[inline]
static fn from_int2(n: int) -> float { return n as float; }
fn from_int2(n: int) -> float { return n as float; }
}
}