Commit Graph

23209 Commits

Author SHA1 Message Date
Benjamin Herr
e007f94747 pp: print spaces around '=' in 'extern mod blah = "blah"' 2013-10-08 01:44:05 +02:00
Daniel Micay
f56cf16b80 stop zeroing the drop flag in drop glue
this is only going to cover up real bugs, as it's not part of the model
used to prevent multiple destructor calls
2013-10-07 18:41:20 -04:00
Daniel Micay
a9fb88d4f8 rm special case for ty_struct from take glue
This is incorrect, as take glue isn't used for moves.
2013-10-07 17:18:10 -04:00
Alex Crichton
2c76cdae3e Document visibility in the manual/tutorial
This removes the warning "Note" about visibility not being fully defined, as it
should now be considered fully defined with further bugs being considered just
bugs in the implementation.
2013-10-07 13:00:52 -07:00
Alex Crichton
de7d143176 Fix existing privacy/visibility violations
This commit fixes all of the fallout of the previous commit which is an attempt
to refine privacy. There were a few unfortunate leaks which now must be plugged,
and the most horrible one is the current `shouldnt_be_public` module now inside
`std::rt`. I think that this either needs a slight reorganization of the
runtime, or otherwise it needs to just wait for the external users of these
modules to get replaced with their `rt` implementations.

Other fixes involve making things pub which should be pub, and otherwise
updating error messages that now reference privacy instead of referencing an
"unresolved name" (yay!).
2013-10-07 13:00:52 -07:00
Alex Crichton
439e2770be Extract privacy checking from name resolution
This commit is the culmination of my recent effort to refine Rust's notion of
privacy and visibility among crates. The major goals of this commit were to
remove privacy checking from resolve for the sake of sane error messages, and to
attempt a much more rigid and well-tested implementation of visibility
throughout rust. The implemented rules for name visibility are:

1. Everything pub from the root namespace is visible to anyone
2. You may access any private item of your ancestors.

"Accessing a private item" depends on what the item is, so for a function this
means that you can call it, but for a module it means that you can look inside
of it. Once you look inside a private module, any accessed item must be "pub
from the root" where the new root is the private module that you looked into.
These rules required some more analysis results to get propagated from trans to
privacy in the form of a few hash tables.

I added a new test in which my goal was to showcase all of the privacy nuances
of the language, and I hope to place any new bugs into this file to prevent
regressions.

Overall, I was unable to completely remove the notion of privacy from resolve.
One use of privacy is for dealing with glob imports. Essentially a glob import
can only import *public* items from the destination, and because this must be
done at namespace resolution time, resolve must maintain the notion of "what
items are public in a module". There are some sad approximations of privacy, but
I unfortunately can't see clear methods to extract them outside.

The other use case of privacy in resolve now is one that must stick around
regardless of glob imports. When dealing with privacy, checking a private path
needs to know "what the last private thing was" when looking at a path. Resolve
is the only compiler pass which knows the answer to this question, so it
maintains the answer on a per-path resolution basis (works similarly to the
def_map generated).

Closes #8215
2013-10-07 13:00:52 -07:00
Dmitry Ermolov
da7f41104d Fix bug in match checking
When `specialize`ing struct-like enum patterns, compare struct fields to
pattern fields, not pattern fields to pattern fields.

Closes #8351.
2013-10-07 22:28:18 +04:00
Dmitry Ermolov
822699e57e Add tests for issue 8351 2013-10-07 22:28:18 +04:00
Dmitry Ermolov
fdb49aa917 Hide internal stuff in check_match.rs 2013-10-07 13:33:50 +04:00
bors
8eb28bb7dc auto merge of #9703 : alexcrichton/rust/compiler-features, r=cmr
This implements the necessary logic for gating particular features off by default in the compiler. There are a number of issues which have been wanting this form of mechanism, and this initially gates features which we have open issues for.

Additionally, this should unblock #9255
2013-10-06 14:41:28 -07:00
Alex Crichton
3396365cab Add appropriate #[feature] directives to tests 2013-10-06 14:39:25 -07:00
bors
4db6eba3a2 auto merge of #9741 : catamorphism/rust/rustpkg-remotes, r=cmr
r? @cmr Closes #9193
2013-10-06 09:16:30 -07:00
bors
c05fbc5a2c auto merge of #9593 : fhahn/rust/logging-unsafe-removal, r=alexcrichton
This pull request changes to memory layout of the `CrateMap` struct to use static slices instead of raw pointers. Most of the discussion took place [here](63b5975efa (L1R92)) .

The memory layout of CrateMap changed, without bumping the version number in the struct. Another, more backward compatible, solution would be to keep the old code and increase the version number in the new struct. On the other hand, the `annihilate_fn` pointer was removed without bumping the version number recently.

At the moment, the stage0 compiler does not use the new memory layout, which would lead the segfaults during stage0 compilation, so I've added a dummy `iter_crate_map` function for stage0, which does nothing. Again, this could be avoided if we'd bump the version number in the struct and keep the old code.

I'd like to use a normal `for` loop [here](https://github.com/fhahn/rust/compare/logging-unsafe-removal?expand=1#L1R109), 

        for child in children.iter() {
            do_iter_crate_map(child, |x| f(x), visited);
        }


but for some reason this only yields `error: unresolved enum variant, struct or const 'Some'` and I have no idea why.
2013-10-06 03:21:32 -07:00
Florian Hahn
23176fc567 get_crate_map returns an Option 2013-10-06 11:40:26 +02:00
bors
a623fd339b auto merge of #9682 : skade/rust/clearer-error-message-for-external-type-and-trait, r=alexcrichton
The old error message implied that external traits could never
be implemented locally.
2013-10-06 02:06:32 -07:00
Florian Gilcher
8154d23e44 Clearer error message for external trait and type
The old error message implied that external traits could never
be implemented locally.
2013-10-06 09:56:46 +02:00
Huon Wilson
c5c980ac2a Fix a typo in std::ops documentation 2013-10-06 18:51:58 +11:00
bors
d5e5d22bdb auto merge of #9738 : catamorphism/rust/rustpkg-test-docs-need-to-submit, r=alexcrichton
r? anybody Talk about `rustpkg test` in the tutorial, and update its usage message.

@steveklabnik, it would be great if you could look this over :-)
2013-10-05 22:46:34 -07:00
Tim Chevalier
d7b2c70a13 rustpkg: Fix fetching remote packages
Closes #9193
2013-10-06 00:49:11 -04:00
Alex Crichton
dd98f7089f Implement feature-gating for the compiler
A few features are now hidden behind various #[feature(...)] directives. These
include struct-like enum variants, glob imports, and macro_rules! invocations.

Closes #9304
Closes #9305
Closes #9306
Closes #9331
2013-10-05 20:19:33 -07:00
Tim Chevalier
8ba148b295 docs / rustpkg: Document rustpkg test more
Talk about `rustpkg test` in the tutorial, and update its usage message.
2013-10-05 23:17:23 -04:00
bors
0114ab631d auto merge of #9729 : dwrensha/rust/regionmanip-cleanup, r=catamorphism 2013-10-05 19:56:32 -07:00
bors
acf9783879 auto merge of #9733 : catamorphism/rust/issues-7246-and-7573, r=alexcrichton
r? anybody Closes #7246
Closes #7573
2013-10-05 18:41:34 -07:00
Tim Chevalier
310c0e3d4b testsuite: Two tests for fixed bugs
Closes #7246
Closes #7573
2013-10-05 20:36:14 -04:00
David Renshaw
3b26bb9022 remove duplicate statement 2013-10-05 20:28:09 -04:00
bors
549f70989e auto merge of #9734 : luisbg/rust/master, r=alexcrichton
These formats are already covered with 'T' | 'X' in line 571 and 'D' | 'x' in
line 446.
2013-10-05 17:26:35 -07:00
bors
bf416e7daf auto merge of #9713 : sfackler/rust/dynamic_lib, r=alexcrichton
The root issue is that dlerror isn't reentrant or even thread safe.

The solution implemented here is to make a yielding spin lock over an
AtomicFlag. This is pretty hacky, but the best we can do at this point.
As far as I can tell, it isn't possible to create a global mutex without
having to initialize it in a single threaded context.

The Windows code isn't affected since errno is thread-local on Windows
and it's running in an atomically block to ensure there isn't a green
thread context switch.

Closes #8156
2013-10-05 15:41:35 -07:00
Luis de Bethencourt
72490c9d48 extra: remove commented out 'X' and 'x' formats
These formats are already covered with 'T' | 'X' in line 571 and 'D' | 'x' in
line 446.
2013-10-05 17:30:26 -04:00
bors
2733b189ac auto merge of #9250 : erickt/rust/num, r=erickt
This PR solves one of the pain points with c-style enums. Simplifies writing a fn to convert from an int/uint to an enum. It does this through a `#[deriving(FromPrimitive)]` syntax extension.

Before this is committed though, we need to discuss if `ToPrimitive`/`FromPrimitive` has the right design (cc #4819). I've changed all the `.to_int()` and `from_int()` style functions to return `Option<int>` so we can handle partial functions. For this PR though only enums and `extra::num::bigint::*` take advantage of returning None for unrepresentable values. In the long run it'd be better if `i64.to_i8()` returned `None` if the value was too large, but I'll save this for a future PR.

Closes #3868.
2013-10-05 14:26:44 -07:00
Erick Tryzelaar
0e8ad4d8a2 extra: fix BigInt on 32bit machines 2013-10-05 13:59:06 -07:00
Erick Tryzelaar
efae73d95a test: fix the tests for windows 2013-10-05 13:59:06 -07:00
Erick Tryzelaar
41f9deb2ee std: add Primitive.is_signed 2013-10-05 13:59:06 -07:00
Erick Tryzelaar
50fde8c024 std: ToPrimitive's default impls should use .to_*()
This allows the default methods to be properly range checked.
2013-10-05 13:59:06 -07:00
Erick Tryzelaar
da145b2372 std: fix some warnings 2013-10-05 13:59:05 -07:00
Erick Tryzelaar
e323749397 extra: Don't truncate {u64,i64} when converting to BigInts 2013-10-05 13:59:05 -07:00
Erick Tryzelaar
cb24019744 std: check bounds for ints/uints in {To,From}Primitive 2013-10-05 13:59:05 -07:00
bors
0c388be8d1 auto merge of #9731 : Kimundi/rust/SendStrTaskName, r=alexcrichton
This resolves a FIXME in `std::rt::task`.
2013-10-05 13:11:54 -07:00
Marvin Löbel
517298de48 Implemented IntoSendStr on SendStr to allow naming a
task with a `SendStr` directly
2013-10-05 21:28:04 +02:00
Marvin Löbel
49ac6baa72 Make a task name use a SendStr, allowing for either
static or owned strings
2013-10-05 21:01:58 +02:00
Steven Fackler
1d19ad9787 Fix thread safety issues in dynamic_lib
The root issue is that dlerror isn't reentrant or even thread safe.

The Windows code isn't affected since errno is thread-local on Windows
and it's running in an atomically block to ensure there isn't a green
thread context switch.

Closes #8156
2013-10-05 10:37:11 -07:00
Florian Hahn
b7b4f7a5e2 Add code for older crate map versions, bumped crate map version number 2013-10-05 12:09:30 +02:00
Florian Hahn
5dd1145c9b Use &'self str instead of raw char pointer in ModEntry 2013-10-05 12:09:30 +02:00
Florian Hahn
9ef4463b2a Use slice representation for module entries in CrateMap
Relaxe lifetime of CrateMap as well.
2013-10-05 12:09:30 +02:00
Florian Hahn
787f20a255 Use slice representation for child crate maps 2013-10-05 12:09:30 +02:00
bors
1506dac10f auto merge of #9727 : Valloric/rust/doc-fixes, r=catamorphism 2013-10-04 23:51:32 -07:00
bors
bae0ce2a69 auto merge of #9726 : Valloric/rust/typo_fix, r=alexcrichton 2013-10-04 22:36:33 -07:00
Strahinja Val Markovic
03099e5678 Fixed another minor typo in std::str docs 2013-10-04 22:07:57 -07:00
Strahinja Val Markovic
d629aca81a Fix minor typo in std::str module docs 2013-10-04 21:24:29 -07:00
bors
5a1073fbab auto merge of #9722 : alexcrichton/rust/less-mem, r=sanxiyn
According to http://huonw.github.io/isrustfastyet/mem/#012f909, the "const
marking" pass generates about 400MB of extra memory during compilation. It
appears that this is due to two different factors:

    1. There is a `ccache` map in the ty::ctxt which is only ever used in this
       pass, so this commit moves the map out of the ty::ctxt struct and into
       just this pass's visitor. This turned out to not benefit that much in
       memory (as indicated by http://i.imgur.com/Eo4iOzK.png), but it's helpful
       to do nonetheless.

    2. During const_eval, there are a lot of lookups into decoding inlined items
       from external crates. There is no caching involved here, so the same
       static or variant could be re-translated many times. After adding
       separate caches for variants and statics, the memory peak of compiling
       rustc decreased by 200MB (as evident by http://i.imgur.com/ULAUMtq.png)

The culmination of this is basically a slight reorganization of a caching map
for the const_eval pass along with a 200MB decrease in peak memory usage when
compiling librustc.
2013-10-04 21:21:31 -07:00
Alex Crichton
19e9766c29 Don't fail when unpacking the windows snapshot
Newly having a third-party directory was throwing off the unpack script
2013-10-04 21:16:54 -07:00