Commit Graph

4146 Commits

Author SHA1 Message Date
Edward Wang
daa1f5099f Combine lifetime parameters when instantiating default methods
When instantiating trait default methods for certain implementation,
`typeck` correctly combined type parameters from trait bound with those
from method bound, but didn't do so for lifetime parameters. Applies
the same logic to lifetime parameters.

Closes #13204
2014-04-17 00:38:54 +08:00
bors
72869b6579 auto merge of #13547 : alexcrichton/rust/remove-priv, r=huonw
See [RFC 6](e0c741f1c6/active/0006-remove-priv.md)
2014-04-16 08:16:35 -07:00
Alex Crichton
5cfbc0e7ae rustc: Remove private enum variants
This removes the `priv` keyword from the language and removes private enum
variants as a result. The remaining use cases of private enum variants were all
updated to be a struct with one private field that is a private enum.

RFC: 0006-remove-priv

Closes #13535
2014-04-16 08:12:43 -07:00
bors
349d66af94 auto merge of #13532 : alexcrichton/rust/rollup, r=alexcrichton 2014-04-15 23:36:58 -07:00
bors
74bd2338eb auto merge of #13390 : alexcrichton/rust/run-some-destructors, r=brson
Previously, if statements of the form "Foo;" or "let _ = Foo;" were encountered
where Foo had a destructor, the destructors were not run. This changes
the relevant locations in trans to check for ty::type_needs_drop and invokes
trans_to_lvalue instead of trans_into.

Closes #4734
Closes #6892
2014-04-15 21:17:00 -07:00
Huon Wilson
54ec04f1c1 Use the unsigned integer types for bitwise intrinsics.
Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just
exposing the internal LLVM names pointlessly (LLVM doesn't have "signed
integers" or "unsigned integers", it just has sized integer types
with (un)signed *operations*).

These operations are semantically working with raw bytes, which the
unsigned types model better.
2014-04-15 19:45:00 -07:00
Alex Crichton
83351fa02e Remove usage of private enum variants
This replaces all uses of private enum variants with a struct that has
one private field pointing at a private enum.

RFC: 0006-remove-priv
2014-04-15 19:17:44 -07:00
bors
6fcf43e50e auto merge of #13511 : Meyermagic/rust/enum_typeid, r=alexcrichton
Fixes #13507.

I haven't familiarized myself with this part of the rust compiler, so hopefully there are no mistakes (despite the simplicity of the commit). It is also 5am.
2014-04-15 17:31:54 -07:00
Kiet Tran
79d1e5df21 Support lifetime suggestion for method
This includes a change to the way lifetime names are generated. Say we
figure that `[#0, 'a, 'b]` have to be the same lifetimes, then instead
of just generating a new lifetime `'c` like before to replace them, we
would reuse `'a`. This is done so that when the lifetime name comes
from an impl, we don't give something that's completely off, and we
don't have to do much work to figure out where the name came from. For
example, for the following code snippet:

```rust
struct Baz<'x> {
    bar: &'x int
}

impl<'x> Baz<'x> {
    fn baz1(&self) -> &int {
        self.bar
    }
}
```

`[#1, 'x]` (where `#1` is BrAnon(1) and refers to lifetime of `&int`)
have to be marked the same lifetime. With the old method, we would
generate a new lifetime `'a` and suggest `fn baz1(&self) -> &'a int`
or `fn baz1<'a>(&self) -> &'a int`, both of which are wrong.
2014-04-15 15:47:47 -04:00
bors
189584e792 auto merge of #13489 : JustAPerson/rust/crate-file-name, r=alexcrichton
Before, the `--crate-file-name` flag only checked crate attributes for
possible crate types. Now, if any type is specified by one or more
`--crate-type` flags, only the filenames for those types will be
emitted, and any types specified by crate attributes will be ignored.
2014-04-15 11:02:03 -07:00
Meyer S. Jacobs
b9f7ac591c Fixes #13507
Fixes hashing of DefId for ty_enum.

Adds tests for cross-crate TypeId equivalence for various types.
2014-04-14 17:39:52 -07:00
JustAPerson
0162f8e6e1 Only check --crate-type flags if present.
Before, normal compilation and the --crate-file-name flag would
generate output based on both #![crate_type] attributes and
--crate-type flags. Now, if one or more flag is specified by command
line, only those will be used.

Closes #11573.
2014-04-14 16:53:06 -05:00
bors
168b2d1a3f auto merge of #13496 : alexcrichton/rust/issue-13495, r=sfackler
This bug was introduced in #13384 by accident, and this commit continues the
work of #13384 by finishing support for loading a syntax extension crate without
registering it with the local cstore.

Closes #13495
2014-04-14 14:36:54 -07:00
bors
246ebd2d5a auto merge of #13493 : Manishearth/rust/newattr-everywhere, r=alexcrichton
See #13478
2014-04-14 12:21:52 -07:00
bors
347e9e4ffe auto merge of #13480 : edwardw/rust/vtable-ice, r=alexcrichton
A mismatched type with more type parameters than the expected one causes
`typeck` looking up out of the bound of type parameter vector, which
leads to ICE.

Closes #13466
2014-04-14 11:00:20 -07:00
Manish Goregaokar
713e87526e Use new attribute syntax in python files in src/etc too (#13478) 2014-04-14 21:00:31 +05:30
Steven Fackler
eb0473df93 Make Result::{unwrap, unwrap_err} require Show
`foo.ok().unwrap()` and `foo.err().unwrap()` are the fallbacks for types
that aren't `Show`.

Closes #13379
2014-04-13 23:47:53 -07:00
Alex Crichton
e163ab2151 rustc: Don't link in syntax extensions
This bug was introduced in #13384 by accident, and this commit continues the
work of #13384 by finishing support for loading a syntax extension crate without
registering it with the local cstore.

Closes #13495
2014-04-13 11:29:28 -07:00
bors
465109df62 auto merge of #13452 : Ryman/rust/fix_uint_as_u, r=alexcrichton
Fixes #13359.
2014-04-13 10:36:47 -07:00
bors
7240fad25e auto merge of #13471 : Ryman/rust/feature_syntax_error, r=brson
The current error message is misleading, it asks users to add `#[feature(..)]` which ends up being treated as an outer attribute, which then has no error unless `attribute_usage` lint is enforced. The code will still fail and the user might not understand why.
2014-04-13 08:51:49 -07:00
bors
2f79054650 auto merge of #13463 : alexcrichton/rust/c-linkage-oh-my, r=brson
Previously, upstream C libraries were linked in a nondeterministic fashion
because they were collected through iter_crate_data() which is a nodeterministic
traversal of a hash map. When upstream rlibs had interdependencies among their
native libraries (such as libfoo depending on libc), then the ordering would
occasionally be wrong, causing linkage to fail.

This uses the topologically sorted list of libraries to collect native
libraries, so if a native library depends on libc it just needs to make sure
that the rust crate depends on liblibc.
2014-04-13 02:16:54 -07:00
bors
96aeb7e3c3 auto merge of #13461 : eddyb/rust/cleanup-at-fn, r=luqmana 2014-04-12 22:21:56 -07:00
Kevin Butler
888517df4d libsyntax: update helper to stringify TyU* and TyI* to take into account having a value.
Fixes #13359.
2014-04-13 02:39:19 +01:00
Edward Wang
fc043c054f Check bounds when looking up type parameters
A mismatched type with more type parameters than the expected one causes
`typeck` looking up out of the bound of type parameter vector, which
leads to ICE.

Closes #13466
2014-04-12 21:14:24 +08:00
Kevin Butler
c48a3efb17 librustc: Improve error message for missing feature attributes. 2014-04-12 00:25:32 +01:00
Alex Crichton
e6072fa0c4 rustc: Deterministically link upstream C libraries
Previously, upstream C libraries were linked in a nondeterministic fashion
because they were collected through iter_crate_data() which is a nodeterministic
traversal of a hash map. When upstream rlibs had interdependencies among their
native libraries (such as libfoo depending on libc), then the ordering would
occasionally be wrong, causing linkage to fail.

This uses the topologically sorted list of libraries to collect native
libraries, so if a native library depends on libc it just needs to make sure
that the rust crate depends on liblibc.
2014-04-11 12:20:33 -07:00
bors
8b6091e8f1 auto merge of #13236 : liigo/rust/rename-benchharness, r=huonw
Closes #12640

based on PR #13030, rebased, and passed all tests.
2014-04-11 10:01:43 -07:00
Eduard Burtescu
9d570ad8c1 rustc: remove the last mentions of @fn. 2014-04-11 18:03:16 +03:00
Eduard Burtescu
f0c0c2ae91 rustc: remove proc -> once || coercions. 2014-04-11 18:03:16 +03:00
Eduard Burtescu
402d946868 rustc: fix fallout from removing ast::Sigil and use ty::TraitStore in ty::ClosureTy. 2014-04-11 18:03:10 +03:00
bors
65abf96fb6 auto merge of #13424 : eddyb/rust/ty-mut-in-store, r=nikomatsakis
Cleans up some remnants of the old mutability system and only allows vector/trait mutability in `VstoreSlice` (`&mut [T]`) and `RegionTraitStore` (`&mut Trait`).
2014-04-11 05:01:38 -07:00
Liigo Zhuang
408f484b66 libtest: rename BenchHarness to Bencher
Closes #12640
2014-04-11 17:31:13 +08:00
Eduard Burtescu
ee4c770f8b rustc: fix the fallout from moving mutability into VstoreSlice and RegionTraitStore. 2014-04-11 09:01:31 +03:00
bors
cea8def620 auto merge of #13440 : huonw/rust/strbuf, r=alexcrichton
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it.

Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269
2014-04-10 21:01:41 -07:00
Alex Crichton
1f2c18a0af rustc: Don't allow priv use to shadow pub use
Previously, a private use statement would shadow a public use statement, all of
a sudden publicly exporting the privately used item. The correct behavior here
is to only shadow the use for the module in question, but for now it just
reverts the entire name to private so the pub use doesn't have much effect.

The behavior isn't exactly what we want, but this no longer has backwards
compatibility hazards.
2014-04-10 15:22:01 -07:00
Alex Crichton
df533c6e87 rustc: Don't succeed on shadowed nonexistent import
Previously resolve was checking the "import resolution" for whether an import
had succeeded or not, but this was the same structure filled in by a previous
import if a name is shadowed. Instead, this alters resolve to consult the local
resolve state (as opposed to the shared one) to test whether an import succeeded
or not.

Closes #13404
2014-04-10 15:22:00 -07:00
Alex Crichton
83d2c0b8a6 rustc: Disallow importing through use statements
Resolve is currently erroneously allowing imports through private `use`
statements in some circumstances, even across module boundaries. For example,
this code compiles successfully today:

    use std::c_str;
    mod test {
        use c_str::CString;
    }

This should not be allowed because it was explicitly decided that private `use`
statements are purely bringing local names into scope, they are not
participating further in name resolution.

As a consequence of this patch, this code, while valid today, is now invalid:

    mod test {
        use std::c_str;

        unsafe fn foo() {
            ::test::c_str::CString::new(0 as *u8, false);
        }
    }

While plausibly acceptable, I found it to be more consistent if private imports
were only considered candidates to resolve the first component in a path, and no
others.

Closes #12612
2014-04-10 15:22:00 -07:00
Kasey Carrothers
0bf4e900d4 Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated associated variable and function names. 2014-04-10 15:22:00 -07:00
Alex Crichton
3f2c55f7d5 rustc: Use realpath() for sysroot/rpath
When calculating the sysroot, it's more accurate to use realpath() rather than
just one readlink() to account for any intermediate symlinks that the rustc
binary resolves itself to.

For rpath, realpath() is necessary because the rpath must dictate a relative
rpath from the destination back to the originally linked library, which works
more robustly if there are no symlinks involved.

Concretely, any binary generated on OSX into $TMPDIR requires an absolute rpath
because the temporary directory is behind a symlink with one layer of
indirection. This symlink causes all relative rpaths to fail to resolve.

cc #11734
cc #11857
2014-04-10 15:22:00 -07:00
Alex Crichton
25a6b6ef8b rustc: Add a realpath utility function
This is required in rustc to resolve symlinks for utilities such as the sysroot
and the rpath values which are encoded into binaries.
2014-04-10 15:22:00 -07:00
Alex Crichton
f9e17e1d33 rustc: Don't rpath to librustrt.dylib
This library no longer exists, there's no reason for this rpath to exist any
more.
2014-04-10 15:22:00 -07:00
Alex Crichton
ec996737fe rustc: Remove absolute rpaths
Concerns have been raised about using absolute rpaths in #11746, and this is the
first step towards not relying on rpaths at all. The only current use case for
an absolute rpath is when a non-installed rust builds an executable that then
moves from is built location. The relative rpath back to libstd and absolute
rpath to the installation directory still remain (CFG_PREFIX).

Closes #11746
Rebasing of #12754
2014-04-10 15:22:00 -07:00
Felix S. Klock II
da25539c1a Generalized the pretty-print entry points to support -o <file>. 2014-04-10 15:21:59 -07:00
Huon Wilson
6e63b12f5f Remove some internal ~[] from several libraries.
Some straggling instances of `~[]` across a few different libs. Also,
remove some public ones from workcache.
2014-04-10 15:21:58 -07:00
Eduard Bopp
342e8b59be Fix outdated lint warning about inner attribute
It suggested adding a semicolon instead of the new syntax using an exclamation
mark.
2014-04-10 15:21:58 -07:00
Kevin Ballard
8135032779 Remove references to @Trait from a compiler error message 2014-04-10 15:21:57 -07:00
Michael Woerister
5099b8c863 debuginfo: Don't create debuginfo for statics inlined from other crates.
Fixes issue #13213, that is linker errors when the inlined static has been optimized out of the exporting crate.
2014-04-10 15:21:57 -07:00
Michael Woerister
c26d25466d debuginfo: Implement discriminator type metadata re-use.
An optimization for sharing the type metadata of generic enum discriminators between monomorphized instances (fixes issue #12840)
2014-04-10 15:21:57 -07:00
Michael Woerister
43e8ace76b debuginfo: Improve source code position assignment for inlined functions.
This commit makes sure that code inlined from other functions isn't assigned the source position of the call site, since this leads to undesired behavior when setting line breakpoints (issue #12886)
2014-04-10 15:21:57 -07:00
Eduard Burtescu
a62eba7abf rustc: move mutability from ty_vec and ty_trait to VstoreSlice and RegionTraitStore. 2014-04-10 20:18:46 +03:00