Commit Graph

84 Commits

Author SHA1 Message Date
Huon Wilson
39713b8295 Remove unnecessary parentheses. 2014-01-21 22:00:18 +11:00
Niko Matsakis
419ac4a1b8 Issue #3511 - Rationalize temporary lifetimes.
Major changes:

- Define temporary scopes in a syntax-based way that basically defaults
  to the innermost statement or conditional block, except for in
  a `let` initializer, where we default to the innermost block. Rules
  are documented in the code, but not in the manual (yet).
  See new test run-pass/cleanup-value-scopes.rs for examples.
- Refactors Datum to better define cleanup roles.
- Refactor cleanup scopes to not be tied to basic blocks, permitting
  us to have a very large number of scopes (one per AST node).
- Introduce nascent documentation in trans/doc.rs covering datums and
  cleanup in a more comprehensive way.
2014-01-15 18:34:38 -05:00
Jed Davis
5487f15bbf Fix ICE on const of nullable enum with fields in null case.
That is, if you have an enum type that is subject to the nullable
pointer optimization, but the null variant has a nonzero number of
fields, and you declare a static whose value is of that variant, then
that used to be an ICE but this change fixes it.
2014-01-09 22:24:31 -08:00
Eduard Burtescu
6b221768cf libsyntax: Renamed types, traits and enum variants to CamelCase. 2014-01-09 22:25:28 +02:00
Patrick Walton
5e637a890c librustc: Move block contexts into per-function arenas, and
stack-allocate function contexts.
2014-01-07 17:00:47 -08:00
Patrick Walton
b941677ea3 librustc: De-@mut the crate context 2013-12-26 13:01:26 -08:00
Patrick Walton
a1747a6091 librustc: De-@mut CrateContext::adt_reprs 2013-12-26 13:01:24 -08:00
Patrick Walton
c9432327c4 librustc: Change @mut Block to @Block. 2013-12-26 13:01:21 -08:00
Alex Crichton
ab387a6838 Register new snapshots 2013-11-28 20:27:56 -08:00
Patrick Walton
8ceb374ab7 librustc: Remove non-procedure uses of do from librustc, librustdoc,
and librustpkg.
2013-11-26 08:25:00 -08:00
Jed Davis
8624d5b186 Represent C-like enums with a plain LLVM integer, not a struct.
This is needed so that the FFI works as expected on platforms that don't
flatten aggregates the way the AMD64 ABI does, especially for `#[repr(C)]`.

This moves more of `type_of` into `trans::adt`, because the type might
or might not be an LLVM struct.
2013-11-24 22:44:48 -08:00
Jed Davis
49f851c2c9 Fix type_of for enums to not lose data in some cases when immediate.
The previous implementation, when combined with small discriminants and
immediate types, caused problems for types like `Either<u8, i16>` which
are now small enough to be immediate and can have fields intersecting
the highest-alignment variant's alignment padding (which LLVM doesn't
preserve).  So let's not do that.
2013-10-29 09:09:20 -07:00
Jed Davis
92109b1202 Yet more neatening 2013-10-29 09:09:20 -07:00
Jed Davis
727731f89e Assorted cleanups suggested by reviewers. 2013-10-29 09:09:20 -07:00
Jed Davis
a027f164bc Check repr attribute consistency at check time, not translation.
Note that raising an error during trans doesn't stop the compile or cause
rustc to exit with a failure status, currently, so this is of more than
cosmetic importance.
2013-10-29 09:09:20 -07:00
Jed Davis
ac311ecaab Fix multiple mistakes in adt::is_ffi_safe 2013-10-29 09:09:20 -07:00
Jed Davis
25f953437d Lint non-FFI-safe enums. 2013-10-29 09:09:20 -07:00
Jed Davis
01740acd5a Initial implementation of enum discrimnant sizing.
Allows an enum with a discriminant to use any of the primitive integer
types to store it.  By default the smallest usable type is chosen, but
this can be overridden with an attribute: `#[repr(int)]` etc., or
`#[repr(C)]` to match the target's C ABI for the equivalent C enum.

This commit breaks a few things, due to transmutes that now no longer
match in size, or u8 enums being passed to C that expects int, or
reflection; later commits on this branch fix them.
2013-10-29 09:09:19 -07:00
Alex Crichton
daf5f5a4d1 Drop the '2' suffix from logging macros
Who doesn't like a massive renaming?
2013-10-22 08:09:56 -07:00
Luqman Aden
e88064d18f librustc: Combine C_struct and C_packed_struct. 2013-10-12 23:19:22 -04:00
Luqman Aden
4b4b2136e0 librustc: Don't ICE on packed structs in statics. 2013-10-12 21:42:24 -04:00
Alex Crichton
1b80558be3 rustc: Remove usage of fmt! 2013-09-30 23:21:19 -07:00
Jed Davis
5f536efa9f Don't truncate discriminants to host uint for C_uint's sake. 2013-08-24 20:16:40 -07:00
Jed Davis
8ef8dd9ceb Make enum discriminants u64 instead of the host uint. 2013-08-24 20:16:40 -07:00
Erick Tryzelaar
68f40d215e std: Rename Iterator.transform -> .map
cc #5898
2013-08-10 07:33:21 -07:00
Marvin Löbel
0ac7a219f0 Updated std::Option, std::Either and std::Result
- Made naming schemes consistent between Option, Result and Either
- Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None)
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-05 22:42:21 +02:00
Daniel Micay
1008945528 remove obsolete foreach keyword
this has been replaced by `for`
2013-08-03 22:48:02 -04:00
Daniel Micay
1fc4db2d08 migrate many for loops to foreach 2013-08-01 05:34:55 -04:00
Michael Woerister
8a329770b6 New naming convention for ast::{node_id, local_crate, crate_node_id, blk_check_mode, ty_field, ty_method} 2013-07-29 16:16:48 +02:00
Kevin Murphy
1c3dc294ce Allow uint discriminants and store them as such
Infers type of constants used as discriminants and ensures they are
integral, instead of forcing them to be a signed integer.

Also, stores discriminant values as uint instead of int interally and
deals with related fallout.

Fixes issue #7994
2013-07-24 23:54:40 -04:00
Michael Woerister
3315edfae7 Adapted trans::common::{block, fn_ctxt, scope_info} to new naming convention. 2013-07-23 15:38:55 +02:00
Michael Woerister
e0108a47ab debuginfo: DI generation for enums uses adt::represent_type() now. 2013-07-19 07:57:38 +02:00
Patrick Walton
99b33f7219 librustc: Remove all uses of "copy". 2013-07-17 14:57:51 -07:00
Alex Crichton
1ec06e0124 Remove the global 'vec::to_owned' function 2013-07-12 16:13:51 -04:00
Daniel Micay
641aec7407 remove some method resolve workarounds 2013-07-07 19:51:13 -04:00
Huon Wilson
f19fb2459f Remove standalone comparison functions in vec, make the trait impls better. 2013-07-04 00:46:50 +10:00
Huon Wilson
c0a20d2929 Remove vec::{map, mapi, zip_map} and the methods, except for .map, since this
is very common, and the replacement (.iter().transform().collect()) is very
ugly.
2013-06-30 21:59:44 +10:00
Corey Richardson
1662bd371c Great renaming: propagate throughout the rest of the codebase 2013-06-29 11:20:02 -04:00
James Miller
0cca08a21a Add support for #[no_drop_flag] attribute 2013-06-25 16:11:33 +12:00
Daniel Micay
d2e9912aea vec: remove BaseIter implementation
I removed the `static-method-test.rs` test because it was heavily based
on `BaseIter` and there are plenty of other more complex uses of static
methods anyway.
2013-06-23 02:05:20 -04:00
James Miller
81cf72c264 Finish up Type refactoring 2013-06-22 12:35:35 +12:00
James Miller
fd83b92b59 More Type refactorings 2013-06-22 12:26:33 +12:00
Daniel Micay
49c74524e2 vec: rm old_iter implementations, except BaseIter
The removed test for issue #2611 is well covered by the `std::iterator`
module itself.

This adds the `count` method to `IteratorUtil` to replace `EqIter`.
2013-06-21 03:20:22 -04:00
Graydon Hoare
d904c72af8 replace #[inline(always)] with #[inline]. r=burningtree. 2013-06-18 14:48:48 -07:00
bors
f74e1935aa auto merge of #7123 : huonw/rust/more-str, r=thestinger
Moves all the remaining functions that could reasonably be methods to be methods, except for some FFI ones (which I believe @erickt is working on, possibly) and `each_split_within`, since I'm not really sure the details of it (I believe @kimundi wrote the current implementation, so maybe he could convert it to an external iterator method on `StrSlice`, e.g. `word_wrap_iter(&self) -> WordWrapIterator<'self>`, where `WordWrapIterator` impls `Iterator<&'self str>`. It probably won't be too hard, since it's already a state machine.)

This also cleans up the comparison impls for the string types, except I'm not sure how the lang items `eq_str` and `eq_str_uniq` need to be handled, so they (`eq_slice` and `eq`) remain stand-alone functions.
2013-06-16 00:04:13 -07:00
Huon Wilson
bbcff95ac5 remove unused imports 2013-06-16 12:20:12 +10:00
Daniel Micay
e097d5eaba rm CopyableOrderedIter
replaced with OrdIterator
2013-06-15 22:16:21 -04:00
James Miller
cc908b772c Remove @-fields from CrateContext
Remove all the explicit @mut-fields from CrateContext, though many
fields are still @-ptrs.
This required changing every single function call that explicitly
took a @CrateContext, so I took advantage and changed as many as I
could get away with to &-ptrs or &mut ptrs.
2013-06-16 09:20:40 +12:00
Daniel Micay
585f5f7f79 add IteratorUtil to the prelude 2013-06-14 23:15:42 -04:00
Brian Anderson
7755018074 Revert "std: convert {vec,str}::to_owned to methods."
This fixes the strange random crashes in compile-fail tests.

This reverts commit 96cd61ad03.

Conflicts:
	src/librustc/driver/driver.rs
	src/libstd/str.rs
	src/libsyntax/ext/quote.rs
2013-06-13 19:06:47 -07:00