Commit Graph

4165 Commits

Author SHA1 Message Date
bors
29a39700a1 auto merge of #13525 : Ryman/rust/issue_5997, r=alexcrichton
Closes #5997.
2014-04-17 21:21:24 -07:00
bors
4c50cf38a0 auto merge of #13565 : alexcrichton/rust/issue-13560, r=brson
Syntax-only crates are no longer registered with the cstore, so there's no need
to allocate crate numbers to them. This ends up leaving gaps in the crate
numbering scheme which is not expected in the rest of the compiler.

Closes #13560
2014-04-17 15:51:27 -07:00
bors
99c258cd74 auto merge of #13261 : pnkfelix/rust/fsk-fix-12856, r=nikomatsakis
Fix #12856.

I wanted to put this up first because I wanted to get feedback about the second commit in the series, commit 8599236.  Its the more invasive part of the patch and is largely just belt-and-suspenders assertion checking; in the commit message I mentioned at least one other approach we could take here.  Or we could drop the belt-and-suspenders and just rely on the guard added in the first patch, commit 8d6a005 (which is really quite trivial on its own).

So any feedback on what would be better is appreciated.

r? @nikomatsakis
2014-04-17 12:46:26 -07:00
Felix S. Klock II
3099451020 Add result sanity check to is_to_be_inferred.
This version of `is_to_be_inferred` double-checks the result from
`inferred_map` by querying the `named_region_map` and `ast_map` and
then asserts that the `inferred_map` state is consistent with its own
findings.  (See issue 13261 for further discussion of the approaches).
2014-04-17 20:40:51 +02:00
Kevin Butler
f829d208a3 Catch forward declarations in default type params at AST conversion. 2014-04-17 18:24:52 +01:00
Kevin Butler
52a53e8ae7 Change error for out of scope type params to be more helpful. 2014-04-17 18:24:52 +01:00
Kevin Butler
14e1fd4629 Add span to error for missing type params on enums. 2014-04-17 18:24:52 +01:00
bors
903fbd2635 auto merge of #13569 : alexcrichton/rust/ignore-bytecode, r=brson
The name of the file changed awhile back and this spot wasn't updated to
continue ignoring the bytecode from rlibs when copying into staticlibs.
2014-04-17 06:16:24 -07:00
Felix S. Klock II
b25fe99331 Extended syntax::{fold, ast_map} to include lifetimes.
Part of this required added an override of `fold_type_method` in the
Folder for Ctx impl; it follows the same pattern as `fold_method`.

Also, as a drive-by fix, I moved all of the calls to `folder.new_id`
in syntax::fold's no-op default traversal to really be the first
statement in each function.

  * This is to uphold the invariant that `folder.new_id` is always
    called first (an unfortunate requirement of the current `ast_map`
    code), an invariant that we seemingly were breaking in e.g. the
    previous `noop_fold_block`.

  * Now it should be easier to see when adding new code that this
    invariant must be upheld.

  * (note that the breakage in `noop_fold_block` may not have mattered
    so much previously, since the only thing that blocks can bind are
    lifetimes, which I am only adding support for now.)
2014-04-17 11:42:30 +02:00
Felix S. Klock II
0e30f07abc Guard variance inference for params bound in non-variance context.
Before adding a variance constrant for a given early-bound param,
check if it was meant to be inferred.

To support the above, added `fn is_to_be_inferred` to
`variance::ConstraintContext`.
2014-04-17 11:25:46 +02:00
bors
18536190e1 auto merge of #13557 : FlaPer87/rust/ls-behind-z, r=brson
Closes #13549
2014-04-17 01:31:27 -07:00
bors
787f4151e3 auto merge of #13550 : brson/rust/man, r=alexcrichton
--no-analysis, --dep-info, -C relocation-model, remove --gen-crate-map
2014-04-16 21:56:22 -07:00
bors
1dec47711d auto merge of #13503 : edwardw/rust/lifetime-ice, r=nikomatsakis
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-16 20:31:25 -07:00
Alex Crichton
6807eab800 rustc: Fix omission of bytecode in staticlibs
The name of the file changed awhile back and this spot wasn't updated to
continue ignoring the bytecode from rlibs when copying into staticlibs.
2014-04-16 17:29:08 -07:00
bors
b8d62147aa auto merge of #13418 : ktt3ja/rust/move-out-of, r=brson
This commit changes the way move errors are reported when some value is
captured by a PatIdent. First, we collect all of the "cannot move out
of" errors before reporting them, and those errors with the same "move
source" are reported together. If the move is caused by a PatIdent (that
binds by value), we add a note indicating where it is and suggest the
user to put `ref` if they don't want the value to move. This makes the
"cannot move out of" error in match expression nicer (though the extra
note may not feel that helpful in other places :P). For example, with
the following code snippet,

```rust
enum Foo {
    Foo1(~u32, ~u32),
    Foo2(~u32),
    Foo3,
}

fn main() {
    let f = &Foo1(~1u32, ~2u32);
    match *f {
        Foo1(num1, num2) => (),
        Foo2(num) => (),
        Foo3 => ()
    }
}
```

Errors before the change:

```rust
test.rs:10:9: 10:25 error: cannot move out of dereference of `&`-pointer
test.rs:10         Foo1(num1, num2) => (),
                   ^~~~~~~~~~~~~~~~
test.rs:10:9: 10:25 error: cannot move out of dereference of `&`-pointer
test.rs:10         Foo1(num1, num2) => (),
                   ^~~~~~~~~~~~~~~~
test.rs:11:9: 11:18 error: cannot move out of dereference of `&`-pointer
test.rs:11         Foo2(num) => (),
                   ^~~~~~~~~
```

After:

```rust
test.rs:9:11: 9:13 error: cannot move out of dereference of `&`-pointer
test.rs:9     match *f {
                    ^~
test.rs:10:14: 10:18 note: attempting to move value to here (to prevent the move, use `ref num1` or `ref mut num1` to capture value by reference)
test.rs:10         Foo1(num1, num2) => (),
                        ^~~~
test.rs:10:20: 10:24 note: and here (use `ref num2` or `ref mut num2`)
test.rs:10         Foo1(num1, num2) => (),
                              ^~~~
test.rs:11:14: 11:17 note: and here (use `ref num` or `ref mut num`)
test.rs:11         Foo2(num) => (),
                        ^~~
```

Close #8064
2014-04-16 13:11:30 -07:00
Alex Crichton
4ba94e2c24 rustc: Don't allocate a cnum to syntax crates
Syntax-only crates are no longer registered with the cstore, so there's no need
to allocate crate numbers to them. This ends up leaving gaps in the crate
numbering scheme which is not expected in the rest of the compiler.

Closes #13560
2014-04-16 11:42:22 -07:00
Brian Anderson
111178d028 rustc: Slightly reword the --no-analysis description for clarity 2014-04-16 11:30:36 -07:00
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
Flavio Percoco
fcdc36b142 Move --ls behind -Z ls
Closes #13549
2014-04-16 17:45:06 +02: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