Commit Graph

4969 Commits

Author SHA1 Message Date
Vadim Petrochenkov
1cbdf4e7d3 syntax: Extra diagnostics for _ used in an identifier position 2016-03-31 10:15:36 +03:00
bors
a11129701c Auto merge of #32479 - eddyb:eof-not-even-twice, r=nikomatsakis
Prevent bumping the parser past the EOF.

Makes `Parser::bump` after EOF into an ICE, forcing callers to avoid repeated EOF bumps.
This ICE is intended to break infinite loops where EOF wasn't stopping the loop.

For example, the handling of EOF in `parse_trait_items`' recovery loop fixes #32446.
But even without this specific fix, the ICE is triggered, which helps diagnosis and UX.

This is a `[breaking-change]` for plugins authors who eagerly eat multiple EOFs.
See https://github.com/docopt/docopt.rs/pull/171 for such an example and the necessary fix.
2016-03-28 20:50:42 -07:00
bors
44a77f6769 Auto merge of #32267 - durka:inclusive-range-error, r=nrc
melt the ICE when lowering an impossible range

Emit a fatal error instead of panicking when HIR lowering encounters a range with no `end` point.

This involved adding a method to wire up `LoweringContext::span_fatal`.

Fixes #32245 (cc @nodakai).

r? @nrc
2016-03-28 15:08:49 -07:00
NODA, Kai
7b69ad9158
Type macro is tracked at rust-lang/rust#27245, not 27336
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-03-27 16:48:57 +08:00
Eduard Burtescu
5efdde0de1 rustc: move cfg, infer, traits and ty from middle to top-level. 2016-03-27 01:05:54 +02:00
Eduard Burtescu
221d0fbad0 syntax: Stop the bump loop for trait items at } and EOF. 2016-03-26 21:37:53 +02:00
Jeffrey Seyfried
4b6b506ef4 Improve the error message for paths with too many initial supers 2016-03-26 18:23:54 +00:00
Manish Goregaokar
b55d7729c2 Rollup merge of #32435 - nrc:fix-err-recover, r=nikomatsakis
Some fixes for error recovery in the compiler
2016-03-26 13:42:03 +05:30
Manish Goregaokar
128b2ad829 Rollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, r=pnkfelix
Restrict constants in patterns

This implements [RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md). The primary change is to limit the types of constants used in patterns to those that *derive* `Eq` (note that implementing `Eq` is not sufficient). This has two main effects:

1. Floating point constants are linted, and will eventually be disallowed. This is because floating point constants do not implement `Eq` but only `PartialEq`. This check replaces the existing special case code that aimed to detect the use of `NaN`.
2. Structs and enums must derive `Eq` to be usable within a match.

This is a [breaking-change]: if you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement
`Eq`. Something like the following:

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*):

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`):

```rust
match foo {
    c if c == SOME_CONST => ...
}
```

Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details.

cc https://github.com/rust-lang/rust/issues/31434

r? @pnkfelix
2016-03-26 09:07:21 +05:30
Manish Goregaokar
b8b17a54cf Rollup merge of #32131 - petrochenkov:prim, r=eddyb
resolve: Minimize hacks in name resolution of primitive types

When resolving the first unqualified segment in a path with `n` segments and `n - 1` associated item segments, e.g. (`a` or `a::assoc` or `a::assoc::assoc` etc) try to resolve `a` without considering primitive types first. If the "normal" lookup fails or results in a module, then try to resolve `a` as a primitive type as a fallback.

This way backward compatibility is respected, but the restriction from E0317 can be lifted, i.e. primitive names mostly can be shadowed like any other names.

Furthermore, if names of primitive types are [put into prelude](https://github.com/petrochenkov/rust/tree/prim2) (now it's possible to do), then most of names will be resolved in conventional way and amount of code relying on this fallback will be greatly reduced. Although, it's not entirely convenient to put them into prelude right now due to temporary conflicts like `use prelude::v1::*; use usize;` in libcore/libstd, I'd better wait for proper glob shadowing before doing it.
I wish the `no_prelude` attribute were unstable as intended :(

cc @jseyfried @arielb1
r? @eddyb
2016-03-26 09:07:20 +05:30
Niko Matsakis
2536ae55a4 fix error message 2016-03-25 15:14:45 -04:00
Niko Matsakis
977636156a unit-test symbol-names and item-paths 2016-03-25 14:07:19 -04:00
Niko Matsakis
93e44432e1 check for both partialeq and eq 2016-03-25 10:02:56 -04:00
bors
64a13a4660 Auto merge of #31908 - jseyfried:disallow_shadowed_traits, r=nikomatsakis
Disallow methods from traits that are not in scope

This PR only allows a trait method to be used if the trait is in scope (fixes #31379).
This is a [breaking-change]. For example, the following would break:
```rust
mod foo {
    pub trait T { fn f(&self) {} }
    impl T for () {}
}

mod bar { pub use foo::T; }

fn main() {
    pub use bar::*;
    struct T; // This shadows the trait `T`,
    ().f() // making this an error.
}
```
r? @nikomatsakis
2016-03-25 05:03:13 -07:00
Niko Matsakis
7f661ec417 new tests for RFC #1445 2016-03-25 06:45:43 -04:00
Niko Matsakis
56ebf2b046 fallout in existing tests 2016-03-25 06:45:42 -04:00
Vadim Petrochenkov
77f033bac1 Lift the restriction on reusing names of primitive types 2016-03-25 00:41:09 +03:00
Vadim Petrochenkov
8d4b1d1cf3 Introduce name resolution fallback for primitive types 2016-03-25 00:41:09 +03:00
Alex Burka
861644f2af address nits 2016-03-24 01:42:23 -04:00
Alex Burka
9f899a6659 error during parsing for malformed inclusive range
Now it is impossible for `...` or `a...` to reach HIR lowering
without a rogue syntax extension in play.
2016-03-24 01:42:23 -04:00
Alex Burka
cd80c1bb55 test errors for malformed inclusive ranges 2016-03-24 01:33:31 -04:00
Nick Cameron
180d6b55ca Tests 2016-03-24 15:54:22 +13:00
Brian Anderson
addde1fd6f Make warnings of renamed and removed lints themselves lints
This adds the `renamed_and_removed_lints` warning, defaulting
to the warning level.

Fixes #31141
2016-03-23 23:41:48 +00:00
bors
26cfc269a0 Auto merge of #32410 - Ticki:master, r=eddyb
Add support for naked functions

See https://github.com/rust-lang/rfcs/pull/1201#issuecomment-199442239

This PR adds `#[naked]` for marking naked functions.
2016-03-23 03:49:02 -07:00
Ticki
4869417b61 Add test for the feature gating of naked 2016-03-22 15:00:26 +01:00
bors
6cc502c986 Auto merge of #32253 - durka:derive-31886, r=alexcrichton
derive: assume enum repr defaults to isize

derive: assume enum repr defaults to isize

Fixes #31886.

Spawned from #32139.

r? @alexcrichton
2016-03-21 21:07:28 -07:00
bors
173676efdc Auto merge of #32367 - tiehuis:tiehuis-E0412-help, r=nagisa
Alter E0412 help message wording

The initial wording does not make sense due to an extra 'to'.

There are two potential candidates we can change this to:
 - 'you can import it into scope'
 - 'to import it into scope'

In keeping the changes minimal, we choose the first, as this is more in line with the grammar of the extended candidates help message.
2016-03-20 04:18:13 -07:00
tiehuis
63b66bfbcd Update tests which reference E0421 2016-03-20 19:18:32 +13:00
bors
b6fcab5c7c Auto merge of #32358 - Manishearth:pr-32053, r=Manishearth
Add note if method is called on a function object

rebase of #32053
2016-03-19 21:15:23 -07:00
bors
78e8a00514 Auto merge of #32306 - nikomatsakis:issue-32278, r=eddyb
create fewer region variables in coercions

Fixes #32278.

r? @eddyb
2016-03-19 18:39:50 -07:00
Daniel J Rollins
88ad22998b Add Help and Suggestion to issue-29124 tests 2016-03-19 22:06:45 +05:30
Daniel J Rollins
234371216e Use last path segment for uncalled method note if span_to_segment fails
PR: #32053
2016-03-19 22:06:45 +05:30
Daniel J Rollins
fa0efa69c5 Add test for issue 29124 2016-03-19 22:06:45 +05:30
Eduard-Mihai Burtescu
34bd8f3a20 Rollup merge of #32332 - jonas-schievink:issue32323, r=arielb1
liveness: substitute bound regions with free ones before normalizing the return type

Fixes #32323

r? @arielb1
2016-03-19 12:30:01 +02:00
Niko Matsakis
bca07b5ebb make suggestion stuff not swallow errors
The older code would sometimes swallow errors or fail to produce a
suggestion. The newer code does not. However, just printing everything
would produce a bunch of new and kind of annoying errors, so continue
to swallow `T: 'a` errors so long as there are other things to show.
2016-03-18 16:38:52 -04:00
Niko Matsakis
1922041e7f change coercion to use target region if not LUB 2016-03-18 16:38:29 -04:00
Alex Burka
9d0748f7eb cfail test for #31886 2016-03-18 15:03:55 -04:00
bors
fc9e1d0f55 Auto merge of #32309 - aturon:overlap-warning, r=nikomatsakis
Change inherent overlap error to a warning for now, to ease the breakage

Closes #32247

r? @nikomatsakis
2016-03-18 11:30:30 -07:00
Aaron Turon
e477703bbf Change inherent overlap error to a warning for now, to ease the breakage. 2016-03-18 09:48:30 -07:00
bors
235d77457d Auto merge of #32080 - eddyb:transcendent, r=nikomatsakis
Refactor call & function handling in trans, enable MIR bootstrap.

Non-Rust and Rust ABIs were combined into a common codepath, which means:
* The ugly `__rust_abi` "clown shoes" shim for C->Rust FFI is gone, fixes #10116.
* Methods, *including virtual ones* support non-Rust ABIs, closes #30235.
* Non-Rust ABIs also pass fat pointers in two arguments; the result should be identical.
* Zero-sized types are never passed as arguments; again, behavior shouldn't change.

Additionally, MIR support for calling intrinsics (through old trans) was implemented.
Alongside assorted fixes, it enabled MIR to launch 🚀 and do a *complete* bootstrap.
To try it yourself, `./configure --enable-orbit` *or* `make RUSTFLAGS="-Z orbit"`.
2016-03-18 06:54:58 -07:00
Jonas Schievink
fcaefcfdb0 liveness: substitute bound regions with free ones before normalizing the return type
Fixes #32323
2016-03-18 11:44:16 +01:00
Eduard Burtescu
473f804491 Add #[rustc_no_mir] to make tests pass with -Z orbit. 2016-03-17 22:48:07 +02:00
Eduard Burtescu
6c0674e613 trans: Remove the foreign module. 2016-03-17 21:51:52 +02:00
Eduard Burtescu
b05556e06d trans: Rename MonoId to Instance and start using it in more places. 2016-03-17 21:51:32 +02:00
Jeffrey Seyfried
ed8a2e230d Add test 2016-03-17 11:53:18 +00:00
Corey Farwell
abd1cea145 Stop ignoring expected note/help messages in compiletest suite.
Original issue: https://github.com/rust-lang/rust/issues/21195

Relevant PR: https://github.com/rust-lang/rust/pull/30778

Prior to this commit, if a compiletest testcase included the text
"HELP:" or "NOTE:" (note the colons), then it would indicate to the
compiletest suite that we should verify "help" and "note" expected
messages.

This commit updates this check to also check "HELP" and "NOTE" (not the
absense of colons) so that we always verify "help" and "note" expected
messages.
2016-03-16 21:53:58 -04:00
bors
6e0f2f2f05 Auto merge of #32284 - jseyfried:name_conflict_diagnostics, r=eddyb
Resolve: improve diagnostics for duplicate definitions and imports

This PR improves and regularizes the diagnostics for duplicate definitions and imports.

After this PR, the second of two duplicate definitions/imports will have the following form:
> a(n) [value|type|module|trait|extern crate] named \`*name*\` has already been [defined|imported] in this [module|block|trait|enum]

with a note referencing this first of the two duplicate definitions/imports:
> previous [definition|import] of \`*name*\` here

The error indices remain unchanged.

r? @eddyb
2016-03-16 16:18:12 -07:00
Jeffrey Seyfried
b3c626547c Fix fallout in tests 2016-03-16 08:52:33 +00:00
Aaron Turon
e36620dd9c Introduce ICE when the topmost projection restriction kicks in, as per issue #32205 2016-03-14 15:05:15 -07:00
Aaron Turon
d80189d305 Test fixes, added README for tests 2016-03-14 15:05:14 -07:00