Commit Graph

69607 Commits

Author SHA1 Message Date
Michael Hewson
0b27dcc665 modify ExplicitSelf::determine to take an is_self_type predicate closure, instead of infcx 2017-11-08 04:31:48 -05:00
Lukas Kalbertodt
e65214441d Add Option::filter() according to RFC 2124 2017-11-08 10:23:12 +01:00
Guillaume Gomez
661c507a2e Rollup merge of #45849 - GuillaumeGomez:more-shortcut, r=QuietMisdreavus
Add "-" shortcut

Fixes #45847.

r? @Havvy
2017-11-08 10:09:18 +01:00
Guillaume Gomez
6392a164f0 Rollup merge of #45830 - pornel:dosglobs, r=dtolnay
Warn about lack of args glob expansion in Windows shell

Because all shells on Linux/macOS expand globs, and even MinGW on Windows emulates this behavior, it's easy to forget that Windows by itself doesn't support glob expansion. This PR documents this cross-platform difference.
2017-11-08 10:09:17 +01:00
Guillaume Gomez
1db95a2354 Rollup merge of #45766 - GuillaumeGomez:trait-methods-list, r=QuietMisdreavus
Add more elements in the sidebar

Fixes #45740.

r? @rust-lang/docs
2017-11-08 10:09:16 +01:00
Guillaume Gomez
0f6e0107c3 Rollup merge of #45582 - GuillaumeGomez:doc-unix-missing-links, r=frewsxcv
Add missing links and examples

r? @rust-lang/docs
2017-11-08 10:09:15 +01:00
bors
49bee9d09a Auto merge of #45735 - tirr-c:issue-45730, r=arielb1
Forbid casting to/from a pointer of unknown kind

Fixes #45730.

Before, it ICE'd when `pointer_kind` encountered `TyInfer`.
2017-11-08 07:12:15 +00:00
bors
e177df3d5c Auto merge of #45379 - cuviper:unit_from_iter, r=alexcrichton
impl FromIterator<()> for ()

This just collapses all unit items from an iterator into one.  This is
more useful when combined with higher-level abstractions, like
collecting to a `Result<(), E>` where you only care about errors:

```rust
use std::io::*;
data = vec![1, 2, 3, 4, 5];
let res: Result<()> = data.iter()
    .map(|x| writeln!(stdout(), "{}", x))
    .collect();
assert!(res.is_ok());
```
2017-11-08 01:32:12 +00:00
Guillaume Gomez
ac398a33a9 Add more elements in the sidebar 2017-11-07 23:45:06 +01:00
Guillaume Gomez
5e116985eb Add "-" shortcut 2017-11-07 22:44:18 +01:00
Nick Cameron
b98290cb1f save-analysis: run rustfmt 2017-11-08 10:43:05 +13:00
Nick Cameron
1328c29d4a save-analysis: fix bug with method ids
This just handles a missing entry, doesn't try to recover, because I couldn't actually find a test case.

cc https://github.com/rust-lang-nursery/rls/issues/558
2017-11-08 10:08:19 +13:00
bors
ee2286149a Auto merge of #44932 - cuviper:unsized-ptr-is_null, r=alexcrichton
Remove `T: Sized` on pointer `as_ref()` and `as_mut()`

`NonZero::is_zero()` was already casting all pointers to thin `*mut u8` to check for null.  The same test on unsized fat pointers can also be used with `as_ref()` and `as_mut()` to get fat references.

(This PR formerly changed `is_null()` too, but checking just the data pointer is not obviously correct for trait objects, especially if `*const self` sorts of methods are ever allowed.)
2017-11-07 20:55:01 +00:00
Nick Cameron
95937990c5 save-analysis: fix regression from #45709
closes https://github.com/nrc/rls-analysis/issues/117
2017-11-08 09:46:06 +13:00
Guillaume Gomez
cef0573734 Add missing links and examples 2017-11-07 20:42:26 +01:00
Michael Hewson
1d29966d3b wrap error code in DiagnosticId::Error so it compiles 2017-11-07 14:32:59 -05:00
Robin Kruppe
ce4664956f Clean up 2017-11-07 20:13:19 +01:00
Robin Kruppe
0a843df264 Implement more efficient saturation 2017-11-07 20:13:19 +01:00
Robin Kruppe
354a5cb250 Make trans const eval error on overflow and NaN, matching HIR const eval. 2017-11-07 20:13:19 +01:00
Robin Kruppe
e999e7b8b2 Extract (f32::MAX + 0.5 ULP) constant 2017-11-07 20:13:19 +01:00
Robin Kruppe
964ba2a6e7 Fix bug in rustc_apfloat 2017-11-07 20:13:19 +01:00
Robin Kruppe
0d6b52c2f3 Saturating casts between integers and floats (both directions).
This affects regular code generation as well as constant evaluation in trans,
but not the HIR constant evaluator because that one returns an error for
overflowing casts and NaN-to-int casts. That error is conservatively
correct and we should be careful to not accept more code in constant
expressions.
The changes to code generation are guarded by a new -Z flag, to be able
to evaluate the performance impact. The trans constant evaluation changes
are unconditional because they have no run time impact and don't affect
type checking either.
2017-11-07 20:13:19 +01:00
Michael Hewson
0d739b5b97 Update/improve documentation of ExpliciSelf 2017-11-07 13:36:10 -05:00
Michael Hewson
6fd215647d Add arbitrary_self_types feature gate error to some tests 2017-11-07 13:36:10 -05:00
Michael Hewson
aa0df3da3d get the old error messages back
- added some old code that used ExplicitSelf::determine to check for eqtype with the expected self type in the simple cases
- this fixes problems with error messages being worse in those cases, which caused some compile-fail tests to fail
2017-11-07 13:36:10 -05:00
Michael Hewson
d03eb2cc2d Fix some of the tests
- removed the inherent impls compile-fail test, because we’ll be
supporting them
- remove E0308-2 because it’s gonna be supported now (behind a feature
gate)
- replaced the mismatched method receiver error message with something
better, so fixed the tests that that broke
2017-11-07 13:36:10 -05:00
Michael Hewson
9a592e61ff Improve feature gate error, and return after emitting errors instead of looping forever 2017-11-07 13:36:10 -05:00
Michael Hewson
a3f5866fe8 Fix the lifetime error in ExplicitSelf
Had to take the infer context as a parameter instead of the type
context, so that the function can be called during inference
2017-11-07 13:36:10 -05:00
Michael Hewson
7dff08de57 Rewrote check_method_receiver and ExplicitSelf, got a borrow checker error
Rewrote ExplicitSelf, adding a new `Other` variant for arbitrary self
types. It’s a bit more sophisticated now, and checks for type equality,
so you have to pass the type context and param env as arguments.
There’s a borrow-checker error here that I have to fix

Rewrote check_method_receiver, so it acts as if arbitrary self types
are allowed, and then checks for ExplicitSelf::Other at the end and
disallows it unless the feature is present.
2017-11-07 13:36:10 -05:00
Michael Hewson
497397ab4b initial implementation of arbitrary_self_types
If the feature is enabled, allow method `self` types to be any type
that auto-derefs to `self`.
- Currently, this supports inherent methods as well as trait methods.
The plan AFAIK is to only allow this for trait methods, so I guess it
won’t stay this way
- Dynamic dispatch isn’t implemented yet, so the compiler will ICE if
you define a trait method that takes `self: Rc<Self>` and try to call
it on an `Rc<Trait>`. I will probably just make those methods
non-object-safe initially.
2017-11-07 13:36:10 -05:00
Michael Hewson
edc8c760e0 add tests for the arbitrary_self_types, which won't pass yet 2017-11-07 13:36:10 -05:00
bors
7f6417e9b7 Auto merge of #45822 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests

- Successful merges: #45470, #45588, #45682, #45714, #45751, #45764, #45778, #45782, #45784
- Failed merges:
2017-11-07 18:04:33 +00:00
Kornel
53de42e333 Warn about non-portability of glob patterns 2017-11-07 17:01:56 +00:00
Michael Woerister
d141abfda7 Always treat #[rustc_std_internal_symbol]s as root TransItems. 2017-11-07 16:41:42 +01:00
Michael Woerister
a1364cd0db incr.comp.: Acknowledge the fact that shift operations can panic at runtime. 2017-11-07 15:49:51 +01:00
kennytm
0d53ecd0c7
Rollup merge of #45784 - harpocrates:fix/print-parens-cast-lt, r=kennytm
Pretty print parens around casts on the LHS of `<`/`<<`

When pretty printing a cast expression occuring on the LHS of a `<` or `<<` expression, we should add parens around the cast. Otherwise, the `<`/`<<` gets interpreted as the beginning of the generics for the type on the RHS of the cast.

Consider:

    $ cat parens_cast.rs
    macro_rules! negative {
        ($e:expr) => { $e < 0 }
    }

    fn main() {
        negative!(1 as i32);
    }

Before this PR, the output of the following is not valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { 1 as i32 < 0; }

After this PR, the output of the following is valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { (1 as i32) < 0; }

I've gone through several README/wiki style documents but I'm still not sure where to test this though. I'm not even sure if this sort of thing is tested...
2017-11-07 22:40:20 +08:00
kennytm
1683b830a8
Rollup merge of #45782 - frewsxcv:frewsxcv-shorthands-helpers, r=manishearth
Display all emission types in error msg if user inputs invalid option.

before:

```
> rustc --emit foo
error: unknown emission type: `foo`
```

after:

```
> rustc --emit foo
error: unknown emission type: `foo` - expected one of: `llvm-bc`, `asm`, `llvm-ir`, `mir`, `obj`, `metadata`, `link`, `dep-info`
```
2017-11-07 22:40:19 +08:00
kennytm
6c8a2f659e
Rollup merge of #45778 - Havvy:patch-1, r=steveklabnik
Update reference link in doc's 404

It's currently linking to a page that says it's on the page I'm changing the link too.
2017-11-07 22:40:17 +08:00
kennytm
4b2a5da8c9
Rollup merge of #45764 - QuietMisdreavus:rustdoc-doctest-lints, r=GuillaumeGomez
rustdoc: add #[allow(unused)] to every doctest

More information in #45750 - this is behavior that was documented but not actually implemented.

I also reordered how outer attributes are applied to doctests. Previously, attributes from `#![doc(test(attr(...)))]` would be applied *after* attributes from within the test itself, meaning if a doctest tried to override lints that would be set crate-wide, it wouldn't work at all. This gives a better scope of how lints can be applied.

Closes #45750
2017-11-07 22:40:16 +08:00
kennytm
d8238e4314
Rollup merge of #45751 - estebank:issue-44684, r=nikomatsakis
Handle anon lifetime arg being returned with named lifetime return type

When there's a lifetime mismatch between an argument with an anonymous
lifetime being returned in a method with a return type that has a named
lifetime, show specialized lifetime error pointing at argument with a
hint to give it an explicit lifetime matching the return type.

```
error[E0621]: explicit lifetime required in the type of `other`
  --> file2.rs:21:21
   |
17 |     fn bar(&self, other: Foo) -> Foo<'a> {
   |                   ----- consider changing the type of `other` to `Foo<'a>`
...
21 |                     other
   |                     ^^^^^ lifetime `'a` required
```

Follow up to #44124 and #42669. Fix #44684.
2017-11-07 22:40:15 +08:00
kennytm
264bfc418c
Rollup merge of #45714 - sdroege:thread-panic-docs, r=dtolnay
Update the std::thread docs and clarify that panics can nowadays be caught
2017-11-07 22:40:13 +08:00
kennytm
eae36714df
Rollup merge of #45682 - RalfJung:rwlock-guards, r=alexcrichton
RwLock guards are Sync if T is

Currently, the compiler requires `T` to also be `Send`.  There is no reason for
that.  `&Rw{Read,Write}LockGuard` only provides a shared referenced to `T`, sending
that across threads is safe if `T` is `Sync`.

Cc @oconnor663
2017-11-07 22:40:12 +08:00
kennytm
843dc4bd76
Rollup merge of #45588 - Keruspe:master, r=alexcrichton
rustbuild: don't try to install rls if ToolState is not Testing

We already do that for the Dist Step so we would end up trying to install something that we didn't dist.
2017-11-07 22:40:11 +08:00
kennytm
8074361f46
Rollup merge of #45470 - GuillaumeGomez:unix-metadata-ext, r=QuietMisdreavus
add missing docs for MetadataExt

r? @rust-lang/docs
2017-11-07 22:40:09 +08:00
bors
7ade24f672 Auto merge of #45666 - Amanieu:tls-model, r=alexcrichton
Allow overriding the TLS model

This PR adds the ability to override the default "global-dynamic" TLS model with a more specific one through a target json option or a command-line option. This allows for better code generation in certain situations.

This is similar to the `-ftls-model=` option in GCC and Clang.
2017-11-07 14:24:15 +00:00
Michael Woerister
3c6f620ea0 incr.comp.: Add -Zincremental-verify-ich, which allows to perform a consistency check for stored query result fingerprints. 2017-11-07 15:22:29 +01:00
Michael Woerister
81fd279e81 incr.comp.: Don't filter out StmtDecls from hir::Block during hashing as these make a difference for the RegionScopeTree. 2017-11-07 15:18:00 +01:00
Michael Woerister
faad4ea3b7 incr.comp.: Sort exported symbols list in order to achieve stable incr. comp. hash. 2017-11-07 15:15:45 +01:00
Michael Woerister
102eaa5c10 incr.comp.: Always require Session when decoding Spans (as to avoid silently wrong results). 2017-11-07 15:14:32 +01:00
Michael Woerister
a174951272 incr.comp.: Make assertion in try_mark_green() more targeted. 2017-11-07 15:04:10 +01:00