Commit Graph

48 Commits

Author SHA1 Message Date
Marijn Haverbeke
3d0610b072 Check for literals that are out of range for their type 2011-12-07 21:53:05 +01:00
Marijn Haverbeke
e3eca9174b Change literal representation to not truncate
Also shuffles around the organization of numeric literals and types,
separating by int/uint/float instead of machine-vs-non-machine types.
This simplifies some code.

Closes #974
Closes #1252
2011-12-07 21:08:28 +01:00
Niko Matsakis
6c95e400d8 repair more hash functions 2011-12-07 07:35:25 -08:00
Niko Matsakis
8b608125ac fix hash function: + binds tighter than << 2011-12-06 21:34:50 -08:00
Stefan Plantikow
4ba3158e4f parse: typeck: enabling trivial casts of tail-call return values
introduces ctypes::m_* machine type aliases for int, uint, float
depending on cfg(target_arch) that are used in tests
2011-12-02 11:38:24 -08:00
Stefan Plantikow
29f7cdffa4 ty: trans: added support for dropping trivial casts 2011-12-02 11:38:24 -08:00
Marijn Haverbeke
64ce092c27 Allow literal patterns to contain arbitrary literal expressions
This removes the need for the unary minus hacks, and allows some other
neat things like matching on 1 >> 4.

Issue #954
2011-12-02 13:42:51 +01:00
Marijn Haverbeke
b40c6773c2 Box ast::path values
It seems inefficient to copy them around. Let's measure whether that's actually
> the case
2011-11-30 13:38:38 +01:00
Marijn Haverbeke
e98286b594 Allow import directives in any block
Closes #49
2011-11-23 20:57:34 +01:00
Marijn Haverbeke
9fb3719ded Rollback return-by-reference
It's proving too inflexible, so I'm ripping out the extra complexity
in the hope that regions will, at some point, provide something
similar.

Closes #918
2011-11-23 11:02:27 +01:00
Marijn Haverbeke
5d6a74f020 Only warn about unreachable range patterns when appropriate
Also simplifies the literal-munging, and moves it into ast_util

Closes #1170
2011-11-22 11:49:29 +01:00
Marijn Haverbeke
f6491bb426 Update stdlib, compiler, and tests to new kind system
This involved adding 'copy' to more generics than I hoped, but an
experiment with making it implicit showed that that way lies madness --
unless enforced, you will not remember to mark functions that don't
copy as not requiring copyable kind.

Issue #1177
2011-11-18 12:49:01 +01:00
Marijn Haverbeke
9cf48d3753 Preparation for kind system overhaul
This goes before a snapshot, so that subsequenct patches can make the
transition without breaking the build. Disables kind checking pass, makes
parser accept both new and old-style kind annotation.

Issue #1177
2011-11-18 10:52:28 +01:00
Niko Matsakis
adc79e2f44 remove compile-command from local variable blocks 2011-11-17 11:46:13 -08:00
Marijn Haverbeke
7dacccde94 Make shared kind the default only for generic functions
You almost never want a function with pinned type params. For
types, objects, resources, and tags, pinned types are actually often
more sane. For most of these, shared rarely makes sense. Only tricky
case is objs -- you'll have to think about the kinds you want there.

Issue #1076
2011-10-28 17:00:14 +02:00
Marijn Haverbeke
cfdf193c46 Update our code to new type parameter kind syntax
Closes #1067
2011-10-25 15:56:55 +02:00
Marijn Haverbeke
7114702496 Change the way block calls are parsed, mark them as block-calls.
This makes it possible to omit the semicolon after the block, and will
cause the pretty-printer to properly print such calls (if
pretty-printing of blocks wasn't so broken). Block calls (with the
block outside of the parentheses) can now only occur at statement
level, and their value can not be used. When calling a block-style
function that returns a useful value, the block must be put insde the
parentheses.

Issue #1054
2011-10-21 14:24:14 +02:00
Marijn Haverbeke
fd5a08384d Move ast_util::pat_bindings over to new iter system.
Issue #1056
2011-10-21 12:41:42 +02:00
Brian Anderson
0714bb5f7d Fix the problem with check-fast randomly failing
Trans has been assuming that tag node id's are unique across crates and they
are not so, depending on which way the wind is blowing, it would choose to use
a crate-local tag variant instead of the correct one from std.

No test case since I can't come up with a reliable one that compiles in a
reasonable amount of time.
2011-10-20 15:38:51 -07:00
Niko Matsakis
212707ce84 make native functions markable as unsafe and incorporate that
into the type check
2011-10-12 14:39:34 -07:00
Niko Matsakis
cbe8da0655 make treatment of unchecked/unsafe blocks more uniform
also repair various errors in the parser related to such blocks.
rename checked_blk to default_blk to reflect the fact that it
inherits its purity from the surrounding context.
2011-10-12 14:39:24 -07:00
Niko Matsakis
29584cc5ac Extend the unchecked block stuff to allow unsafe blocks as well. 2011-10-12 14:26:47 -07:00
Marijn Haverbeke
f9fbd86f52 Parse and typecheck by-value and by-ref arg specs
Add sprinkle && throughout the compiler to make it typecheck again.

Issue #1008
2011-10-07 09:09:50 +02:00
Brian Anderson
381205b747 Revert "Revert "Implement pattern ranges for all numeric types.""
This reverts commit a034f87146.

Conflicts:

	src/comp/middle/check_alt.rs
	src/comp/middle/trans_alt.rs
	src/comp/syntax/ast.rs
	src/comp/syntax/ast_util.rs
	src/comp/syntax/fold.rs
	src/comp/syntax/print/pprust.rs

Conflicts:

	src/comp/middle/trans_alt.rs
2011-09-28 12:46:29 -07:00
Brian Anderson
2082f67765 Begin to support pattern matching on unique boxes
Issue #409
2011-09-23 15:15:30 -07:00
Marijn Haverbeke
a034f87146 Revert "Implement pattern ranges for all numeric types."
This reverts commit ce0f054f9d.
2011-09-21 18:42:09 +02:00
Josh Matthews
ce0f054f9d Implement pattern ranges for all numeric types. 2011-09-21 09:36:12 +02:00
Brian Anderson
f809e22697 Represent unique creation as a unop in the AST instead of its own expr
Like the box unop.

Issue #409
2011-09-20 18:06:47 -07:00
Marijn Haverbeke
3abe3671bd Require the parameter that will be referenced to be noted
Issue #918
2011-09-15 16:15:17 +02:00
Marijn Haverbeke
25787bd2b8 Forbid assignment to by-reference bindings
Issue #918
2011-09-15 14:08:54 +02:00
Marijn Haverbeke
93de2f0b74 Add syntax and representation for return-by-mutably-rooted-ref
This will be used in the near future to decide what can safely
be done with the returned reference.

Issue #918
2011-09-14 17:30:38 +02:00
Graydon Hoare
a4815b6742 Factor imports mindlessly. 2011-09-12 16:13:28 -07:00
Marijn Haverbeke
fc6b7c8b38 Reformat for new mode syntax, step 1
Long lines were fixed in a very crude way, as I'll be following up
with another reformat in a bit.
2011-09-12 12:04:14 +02:00
Brian Anderson
5c49e4f4e9 Reformat. Issue #855 2011-09-02 22:11:42 -07:00
Brian Anderson
ab6bb035e5 Rename std::istr to std::str. Issue #855 2011-09-01 17:27:58 -07:00
Brian Anderson
e824775d53 Remove std::str. Issue #855 2011-09-01 16:09:15 -07:00
Marijn Haverbeke
6ba4eacddf Make resolve recognize upvars
Upvars are now marked with def_upvar throughout, not just when going
through freevars::lookup_def. This makes things less error-prone. One
thing to watch out for is that def_upvar is used in `for each` bodies
too, when they refer to a local outside the body.
2011-09-01 16:32:44 +02:00
Marijn Haverbeke
2d1dec78e7 Move mutability checking into its own pass.
Having it in the alias pass was slightly more efficient (finding
expression roots has to be done in both passes), but further muddled
up the already complex alias checker.

Also factors out some duplication in the mutability-checking code.
2011-09-01 16:32:38 +02:00
Marijn Haverbeke
34ae491ca9 Store arg mode and objfield mutability in their def 2011-09-01 16:32:38 +02:00
Brian Anderson
9fb085560d Convert rustc::syntax::ast_util to istrs. Issue #855 2011-08-27 15:54:46 -07:00
Brian Anderson
03119fe269 Convert ast::ident to istr. Issue #855 2011-08-27 15:54:44 -07:00
Brian Anderson
652332f9d4 Convert std::map::new_str_hash to istrs. Issue #855 2011-08-27 15:54:44 -07:00
Tim Chevalier
c02f346e2c Revert "Revert "Use typestate constraints for trans_be""
This reverts commit b0db13956f.

(Should work now that we have a new snapshot)
2011-08-26 10:14:58 -07:00
Tim Chevalier
f841e89443 Support unchecked blocks
This patch supports the syntax

    unchecked {
      ...
    }

    to disable purity checking within a block. Presumably it will only be
    used within a declared "pure fn". However, there is no checking that it
    doesn't occur elsewhere, and it would be harmless for it to do so.

    I went with Lindsey's suggestion for the syntax, but it's subject to
    change.

    This allows you to write code that uses predicates that call arbitrary
    Rust functions, but you must declare your intentions by wrapping it in
    an unchecked { ... } block. The test case run-pass/unchecked-predicates.rs
    demonstrates how to do that.
2011-08-25 18:28:23 -07:00
Tim Chevalier
1cb85015c3 Change "pred" to "pure fn" within the compiler. 2011-08-25 18:24:40 -07:00
Brian Anderson
608f7ccded Move ast::pat_id_map to ast::util 2011-08-25 14:15:54 -07:00
Graydon Hoare
c011f13144 Add kind-checking for assign-op, copy, ret, be, fail exprs. Fix caught kinding-violations in rustc and libstd. 2011-08-23 15:58:53 -07:00
Brian Anderson
152cbaade7 Move functions from syntax::ast to syntax::ast_util
This leaves syntax::ast just defining the AST, which strikes me as somewhat
nicer
2011-08-22 10:44:04 -07:00