Commit Graph

60509 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu
bb04da4822 Don't leak the compiler's internal representation of scopes in error messages. 2017-01-04 05:48:18 +02:00
Andrew Cann
70b7bd94cc Fix build after rebase 2017-01-04 11:07:32 +08:00
bors
a68622c899 Auto merge of #38809 - alexcrichton:rustbuild-fresh, r=brson
rustbuild: Fix a few rebuilding issues

Did a bit of investigation and found a few small unrelated issues, but this should help clean up a lot of errors we've been seeing locally.
2017-01-04 01:51:06 +00:00
bors
468227129d Auto merge of #38066 - bluss:string-slice-error, r=sfackler
Use more specific panic message for &str slicing errors

Separate out of bounds errors from character boundary errors, and print
more details for character boundary errors.

It reports the first error it finds in:

1. begin out of bounds
2. end out of bounds
3. begin <= end violated
3. begin not char boundary
5. end not char boundary.

Example:

    &"abcαβγ"[..4]

    thread 'str::test_slice_fail_boundary_1' panicked at 'byte index 4 is not
    a char boundary; it is inside 'α' (bytes 3..5) of `abcαβγ`'

Fixes #38052
2017-01-03 23:51:42 +00:00
Jeremy Soller
c6858a1429 Revert cargo.lock 2017-01-03 15:47:14 -07:00
Jeremy Soller
537b3aa3fd Remove -lc, -lm from the target spec - the cross compiler will link those 2017-01-03 15:42:41 -07:00
Alex Crichton
3ab778b4af rustbuild: Update where we look for mtime changes
Recent versions of Cargo lift less output up into the "main" directory, so let's
look more inside the `deps` folder for changes to propagate differences.

Closes #38744
Closes #38746
2017-01-03 14:17:02 -08:00
Alex Crichton
753dff63c6 rustbuild: Allow create_sysroot in stage0
Despite what the comment says, we actually need to do this. We're not cleaning
out the stage0 compiler's sysroot, but rather just our own sysroot that we
assembled previously.
2017-01-03 14:07:30 -08:00
Ariel Ben-Yehuda
4cab2931c8 simplify Copy implementation error reporting
Span the affected fields instead of reporting the field/variant name.
2017-01-04 00:03:34 +02:00
comex
b32246279d Fix lint attributes on non-item nodes.
Currently, late lint checking uses two HIR visitors: LateContext and
IdVisitor.  IdVisitor only overrides visit_id, and for each node searches
for builtin lints previously added to the session; LateContext overrides
a number of methods, and runs late lints.  When LateContext encounters an
item, it first has IdVisitor walk everything in it except nested items
(OnlyBodies), then recurses into it itself - i.e. there are two separate
walks.

Aside from apparently being unnecessary, this separation prevents lint
attributes (allow/deny/warn) on non-item HIR nodes from working
properly.  Test case:

// generates warning without this change
fn main() { #[allow(unreachable_code)] loop { break; break; } }

LateContext contains logic to merge attributes seen into the current lint
settings while walking (with_lint_attrs), but IdVisitor does not.  So
such attributes will affect late lints (because they are called from
LateContext), and if the node contains any items within it, they will
affect builtin lints within those items (because that IdVisitor is run
while LateContext is within the attributed node), but otherwise the
attributes will be ignored for builtin lints.

This change simply removes IdVisitor and moves its visit_id into
LateContext itself.  Hopefully this doesn't break anything...

Also added walk calls to visit_lifetime and visit_lifetime_def
respectively, so visit_lifetime_def will recurse into the lifetime and
visit_lifetime will recurse into the name.  In principle this could
confuse lint plugins.  This is "necessary" because walk_lifetime calls
visit_id on the lifetime; of course, an alternative would be directly
calling visit_id (which would require manually iterating over the
lifetimes in visit_lifetime_def), but that seems less clean.
2017-01-03 22:30:41 +01:00
Mina Naguib
ae23f036f0 Doc fix 2017-01-03 14:52:14 -05:00
Ariel Ben-Yehuda
e41920a1c3 rustfmt coherence::builtin 2017-01-03 21:51:28 +02:00
Ariel Ben-Yehuda
243e45aac3 normalize field types in copy implementations
Fixes #34377.
2017-01-03 21:50:18 +02:00
Ariel Ben-Yehuda
d938ba4769 coherence: check builtin impls after the specialization graph is ready
Fixes #33187.
2017-01-03 21:50:18 +02:00
Ariel Ben-Yehuda
7309babf17 coherence: code cleanup 2017-01-03 21:50:18 +02:00
Ariel Ben-Yehuda
f8a2f9838d coherence: move the builtin trait checks to their own module
no functional changes
2017-01-03 21:50:18 +02:00
Eduard-Mihai Burtescu
fbdadcbed4 Properly ban the negation of unsigned integers in type-checking. 2017-01-03 21:48:17 +02:00
Jeremy Fitzhardinge
a8fa2cff28 rustc: use -Xlinker when specifying an rpath with ',' in it
The `-Wl` option splits its parameters on commas, so if rustc specifies
`-Wl,-rpath,<path>` when `<path>` contains commas, the path gets split up
and the linker gets a partial path and spurious extra parameters.

Gcc/clang support the more verbose `-Xlinker` option to pass options
to the linker directly, so use it for comma-containing paths.

Fixes rust issue #38795.
2017-01-03 11:40:48 -08:00
comex
7883543100 Print attributes on expressions when pretty printing. 2017-01-03 20:24:53 +01:00
Felix S. Klock II
ab8e92514c Regression test and exploratory unit test. 2017-01-03 09:58:05 -05:00
Felix S. Klock II
ae13a72ded Dont check stability for items that are not pub to universe.
Includes special case handling for trait methods.

Fix #38412.
2017-01-03 09:57:49 -05:00
abhijeetbhagat
d910837e78 Fix process module tests to run on Windows 2017-01-03 17:50:30 +05:30
bors
8f62c29200 Auto merge of #38473 - zackmdavis:issue_kebab, r=sanxiyn
prefer hyphens in test files named after issue numbers

We have a lot of tests with filenames honoring particular issues by
number. Typically, these are called issue-${issue_no}.rs (note the
hyphen):

```
$ find . -regextype posix-egrep -regex '.*/issue-[0-9]*.rs' | wc
   1289    1289   35935
```

We also had a much smaller number of files that are like this, but don't
have a hyphen in between the substring `issue` and the number:

```
$ find . -regextype posix-egrep -regex '.*/issue[0-9]*.rs'
./debuginfo/issue14411.rs
./debuginfo/issue12886.rs
./debuginfo/issue13213.rs
./debuginfo/issue22656.rs
./debuginfo/issue7712.rs
./compile-fail/issue32829.rs
./run-pass/issue24353.rs
./run-pass/issue34796.rs
./run-pass/issue18173.rs
./run-pass/issue22346.rs
./run-pass/auxiliary/issue13507.rs
./run-pass/issue26127.rs
./run-pass/issue22008.rs
./run-pass/issue34569.rs
./run-pass/issue29927.rs
./run-pass/issue36260.rs
```

Some would argue that the inconsistency is æsthetically displeasing,
hence this trivial patch. (Note that run-pass/auxiliary/issue13507.rs
has an excuse; it's `use`d in run-pass/issue-13507-2.rs; the matter of
there being two different compile-fail tests with different name
conventions for issue no. 32829 is also neglected here for the sake of
keeping this trivial cleanup patch as trivial as possible for ease of
review.)
2017-01-03 09:42:22 +00:00
Andrew Cann
c0cd145c1f Fix make tidy 2017-01-03 15:54:23 +08:00
Andrew Cann
f947890226 Change file structure, add comments for inhabitedness.rs 2017-01-03 15:54:23 +08:00
Andrew Cann
e9ffc409bc Spelling. s/forrest/forest 2017-01-03 15:54:23 +08:00
Niko Matsakis
699b25ff3a fix comment that got split in two 2017-01-03 15:54:23 +08:00
Andrew Cann
9f83e962de Fix build after rebase.
Mostly just rename stuff.
Visibility checks use DefIds rather than NodeIds now.
2017-01-03 15:54:23 +08:00
Andrew Cann
4136ba072e Remove E0001 diagnostic 2017-01-03 15:48:29 +08:00
Andrew Cann
a1570828b2 Amend compile-fail tests 2017-01-03 15:48:29 +08:00
Andrew Cann
5ba61edbd0 Disable unreachable patterns error entirely 2017-01-03 15:48:29 +08:00
Andrew Cann
44a70f0221 Fix inhabitedness bug 2017-01-03 15:48:29 +08:00
Andrew Cann
7946597f75 Refactor is_uninhabited
We now cache the inhabitedness of types in the GlobalCtxt.

Rather than calculating whether a type is visibly uninhabited from a given
NodeId we calculate the full set of NodeIds from which a type is visibly
uninhabited then cache that set. We can then use that to answer queries about
the inhabitedness of a type relative to any given node.
2017-01-03 15:48:29 +08:00
Andrew Cann
9482492ab6 Add drain method to AccumulateVec/ArrayVec
You can now call .drain(..) on SmallVec, AccumulateVec and ArrayVec
2017-01-03 15:48:29 +08:00
Andrew Cann
f8c4d10e95 Fix test I broke 2017-01-03 15:48:29 +08:00
Andrew Cann
56f355c83a Fix build after rebase 2017-01-03 15:48:29 +08:00
Andrew Cann
d2827aa9bc Fix build after rebase 2017-01-03 15:48:29 +08:00
bors
7766b509b3 Auto merge of #38791 - dylanmckay:foreign-item-dc, r=eddyb
Don't warn about dead foreign items if the 'allow(dead_code)' attribute is present

This functionality was missing, and should have existed previously.

Fixes #38780
2017-01-03 07:41:43 +00:00
Andrew Cann
cfc45d52bb Style fix 2017-01-03 15:33:31 +08:00
Andrew Cann
9ba9cd5fd5 Improve error message, fix and add tests.
Changes the non-exhaustive match error message to generate more general
witnesses.
2017-01-03 15:33:31 +08:00
Andrew Cann
9c5e86d0cd More pattern matching for empty types changes
Fix is_uninhabited for enum types. It used to assume that an enums variant's
fields were all private.

Fix MIR generation for irrefutable Variant pattern matches. This allows code
like this to work:

    let x: Result<32, !> = Ok(123);
    let Ok(y) = x;

Carry type information on dummy wildcard patterns. Sometimes we need to expand
these patterns into their constructors and we don't want to be expanding a
TyError into a Constructor::Single.
2017-01-03 15:33:31 +08:00
Andrew Cann
bcdbe942e1 Make is_useful handle empty types properly 2017-01-03 15:31:46 +08:00
Andrew Cann
9ad20442e8 Start enabling empty types in pattern matching.
Remove the assumption at the start of is_useful that any suitably-long array of
wildcard patterns is useful relative the any empty vector. Instead we just
continue to recurse column-wise over the matrix.

This assumption is false in the presence of empty types.
eg. in the simplest case:

let x: ! = ...;
match x {
    // This pattern should not be considered useful by the algorithm
    _   => ...
}
2017-01-03 15:30:19 +08:00
Simon Sapin
3b208d2dac Reduce the size of static data in std_unicode::tables.
`BoolTrie` works well for sets of code points spread out through
most of Unicode’s range, but is uses a lot of space for sets
with few, mostly low, code points.

This switches a few of its instances to a similar but simpler trie
data structure.

 ## Before

`size_of::<BoolTrie>()` is 1552, which is added to
`table.r3.len() * 8 + t.r5.len() + t.r6.len() * 8`:

* `Cc_table`: 1632
* `White_Space_table`: 1656
* `Pattern_White_Space_table`: 1640
* Total: 4928 bytes

 ## After

`size_of::<SmallBoolTrie>()` is 32, which is added to
`t.r1.len() + t.r2.len() * 8`:

* `Cc_table`: 51
* `White_Space_table`: 273
* `Pattern_White_Space_table`: 193
* Total: 517 bytes

 ## Difference

Every Rust program with `std` statically linked should be about 4 KB smaller.
2017-01-03 08:28:58 +01:00
bors
1659d65e03 Auto merge of #38782 - clarcharr:stupid, r=GuillaumeGomez
Reword 'stupid' and 'crazy' in docs.

These terms are not very descriptive and are better reworded as something else.
2017-01-03 02:21:00 +00:00
Jeffrey Seyfried
fd532a1608 Add regression test. 2017-01-03 02:11:32 +00:00
Jeffrey Seyfried
a2fc566d41 Fold all spans in the AST. 2017-01-03 02:00:40 +00:00
Dylan McKay
09178e455e Don't warn about dead foreign items if the 'allow(dead_code)' attribute is present
This functionality was missing, and should have existed previously.

Fixes #38780
2017-01-03 14:54:15 +13:00
Clar Charr
8ffc3e7790 Reword 'stupid' and 'crazy' in docs. 2017-01-02 16:29:19 -05:00
bors
d3a2efa14b Auto merge of #38543 - philipc:unsized-debuginfo, r=michaelwoerister
Fix debuginfo for unsized struct members

The member was given the size of a fat pointer, which caused
llvm to emit DWARF attributes for a 128-bit bitfield.
2017-01-02 20:17:01 +00:00