102610 Commits

Author SHA1 Message Date
Guillaume Gomez
c981c994d4 Move E0594 to new error code system 2019-11-18 23:38:25 +01:00
Gabriel Smith
0207a15fa1 test: Update tests with fallout of changes
The error messages of the two tests effected degraded in quality. The
errors no longer suggest types in other modules as they now assume that
the arguments are const args, not type args.
2019-11-18 17:23:22 -05:00
Gabriel Smith
eaf8fd0569 test: const-generics: Update tests removing unrequired braces
Braces were left in cases where generic args were in the generic const
paths.
2019-11-18 17:23:22 -05:00
Gabriel Smith
fb6cfde5ba rustc: lowering: Lower type args as const args when resolved in value
namespace
2019-11-18 17:23:22 -05:00
bors
0ccee30773 Auto merge of #58281 - mark-i-m:synthesis, r=estebank
Add outlives suggestions for some lifetime errors

This PR implements suggestion diagnostics for some lifetime mismatch errors. When the borrow checker finds that some lifetime 'a doesn't outlive some other lifetime 'b that it should outlive, then in addition to the current lifetime error, we also emit a suggestion for how to fix the problem by adding a bound:

- If a and b are normal named regions, suggest to add the bound `'a: 'b`
- If b is static, suggest to replace a with static
- If b also needs to outlive a, they must be the same, so suggest unifying  them

We start with a simpler implementation that avoids diagnostic regression or implementation complexity:
- We only makes suggestions for lifetimes the user can already name (eg not closure regions or elided regions)
- For now, we only emit a help note, not an actually suggestion because it is significantly easier.

Finally, there is one hack: it seems that implicit regions in async fn are given the name '_ incorrectly. To avoid suggesting '_: 'x, we simply filter out such lifetimes by name.

For more info, see this internals thread:

https://internals.rust-lang.org/t/mechanical-suggestions-for-some-borrow-checker-errors/9049/3

TL;DR Make suggestions to add a `where 'a: 'b` constraint for some lifetime errors. Details are in the paper linked from the internals thread above.

r? @estebank

TODO
- [x] Clean up code
- [x] Only make idiomatic suggestions
     - [x] don't suggest naming `&'a self`
     - [x] rather than `'a: 'static`, suggest replacing `'a` with `'static`
     - [x] rather than `'a: 'b, 'b: 'a`, suggest replacing `'a` with `'b` or vice versa
- [x] Performance (maybe need a perf run when this is closer to the finish line?)
     - perf run was clean...
     - EDIT: perf run seems to only check non-error performance... How do we check that error performance didn't regress?
- [x] Needs ui tests
- [x] Integrate the `help` message into the main lifetime `error`
2019-11-18 22:08:31 +00:00
Gabriel Smith
7b4642f441 resolve: late: Check if type arg is really a const arg
A path type argument could be a generic const argument due to
limitations as to what we can determine at parsing. We double check just
to be sure by trying to resolve in the type namespace first, and if that
fails we try again in the value namespace. If resolution in the value
namespace succeeds, we have a generic const argument on our hands.
2019-11-18 17:01:48 -05:00
Gabriel Smith
128ca7415f rustc: hir: Add method to check validity of a Res/Def in a namespace 2019-11-18 17:01:48 -05:00
Gabriel Smith
041a612dad resolve: Allow idents to resolve to primitives in the type namespace 2019-11-18 17:01:33 -05:00
Vadim Petrochenkov
f74fe812fe resolve: Give derive helpers highest priority during resolution 2019-11-19 00:50:53 +03:00
Esteban Küber
a7678779a1 Reword help and add test 2019-11-18 12:30:21 -08:00
Agustin Fernandez
aae76304f9 Add more context to async fn trait error. Suggest async-trait. 2019-11-18 12:08:15 -08:00
Esteban Küber
614da98454 review comments 2019-11-18 11:46:14 -08:00
bors
3e525e3f6d Auto merge of #54733 - GuillaumeGomez:stabilize-rustdoc-theme, r=ollie27,Dylan-DPC
Stabilize rustdoc theme options

Closes #54730

This PR stabilizes the `--themes` (now `--theme`) and `--theme-checker` (now `--check-theme`) options, for allowing users to add custom themes to their documentation.

Rustdoc includes two themes by default: `light` and `dark`. Using the `--theme` option, you can give rustdoc a CSS file to include as an extra theme for that render. Themes are named after the CSS file used, so using `--theme /path/to/your/custom-theme.css` will add a theme called `custom-theme` to the documentation.

Even though the CLI flag to add a theme is getting stabilized, there's no guarantee that a theme file will always have the same effect on documentation generated with future versions of rustdoc. To aid in ensuring that a theme will work, the flag `--check-theme` is also available, which compares the CSS rules defined by a custom theme against the ones used in the `light` theme. If the `light` theme defines a CSS rule that the custom theme does not, rustdoc will report an error. (Rustdoc also performs this check for themes given to `--theme`, but only reports a warning when a difference is found.)
2019-11-18 19:03:21 +00:00
Aaron Hill
a11abe0d6b
Update test output 2019-11-18 14:01:37 -05:00
Aaron Hill
f87177b1c5
Replace bool with new FallbackMode enum 2019-11-18 14:01:37 -05:00
Aaron Hill
61c75bdb11
Add explanation of unconstrained opaque type 2019-11-18 14:01:36 -05:00
Aaron Hill
0e2ccaaa3e
Fix 'type annotations needed' error with opaque types
Related: #66426

This commit adds handling for opaque types during inference variable
fallback. Type variables generated from the instantiatino of opaque
types now fallback to the opque type itself.

Normally, the type variable for an instantiated opaque type is either
unified with the concrete type, or with the opaque type itself (e.g when
a function returns an opaque type by calling another function).

However, it's possible for the type variable to be left completely
unconstrained. This can occur in code like this:

```rust
pub type Foo = impl Copy;
fn produce() -> Option<Foo> {
    None
}
```

Here, we'll instantatiate the `Foo` in `Option<Foo>` to a fresh type
variable, but we will never unify it with anything due to the fact
that we return a `None`.

This results in the error message:

`type annotations needed: cannot resolve `_: std::marker::Copy``

pointing at `pub type Foo = impl Copy`.

This message is not only confusing, it's incorrect. When an opaque type
inference variable is completely unconstrained, we can always fall back
to using the opaque type itself. This effectively turns that particular
use of the opaque type into a non-defining use, even if it appears in a
defining scope.
2019-11-18 14:01:36 -05:00
Guillaume Gomez
cd13335ae2 Update ui tests 2019-11-18 19:00:10 +01:00
Guillaume Gomez
4610867c2b Add long error explanation for E0594 2019-11-18 19:00:10 +01:00
Esteban Küber
0ff73535ed Move trait_ref_to_existential to a closure
review comment
2019-11-18 09:55:54 -08:00
Guillaume Gomez
45b83c9164 Fix Makefile themes check 2019-11-18 18:53:45 +01:00
Guillaume Gomez
a9e8d4c0c5 Remove redundant html check 2019-11-18 16:49:44 +01:00
Nadrieril
1425ae1154 Tweak diagnostics code 2019-11-18 15:49:29 +00:00
Guillaume Gomez
71c7dace89 improve error messages and documentation 2019-11-18 16:43:48 +01:00
Guillaume Gomez
b004a50f73 remove -Z option from rustdoc theme checker tool 2019-11-18 16:43:48 +01:00
Guillaume Gomez
530d866aef Apply review comments 2019-11-18 16:43:48 +01:00
Guillaume Gomez
8f9014d98f Rename rustdoc options --themes and --check-themes to --theme and --check-theme 2019-11-18 16:43:48 +01:00
Guillaume Gomez
685b63a163 remove unstable docs 2019-11-18 16:43:48 +01:00
Guillaume Gomez
7cbf31aa04 rename check-theme option into check-themes 2019-11-18 16:43:48 +01:00
Guillaume Gomez
bbfd63c89a Improve documentation, add checks for themes option arguments, make sure the themes file names are js compatible 2019-11-18 16:43:48 +01:00
Guillaume Gomez
6f2d1f51eb Fix typos
Co-Authored-By: Oliver Middleton <olliemail27@gmail.com>
2019-11-18 16:43:48 +01:00
Guillaume Gomez
8f44c604d2 Rename theme-checker option to check-theme 2019-11-18 16:43:48 +01:00
Guillaume Gomez
82872addf1 Add sentence to tell other options are ignored when running check-theme 2019-11-18 16:43:48 +01:00
Guillaume Gomez
e365120243 Prevent invalid html characters in themes name 2019-11-18 16:43:48 +01:00
QuietMisdreavus
d350008c88 add test for rustdoc's --themes flag 2019-11-18 16:43:47 +01:00
Guillaume Gomez
f3e4279ccc Apply review comments 2019-11-18 16:43:47 +01:00
Guillaume Gomez
dcccd28e42 Warn instead of failing for themes 2019-11-18 16:43:47 +01:00
Guillaume Gomez
3eba28432f Add documentation for stabilized flags 2019-11-18 16:43:47 +01:00
Guillaume Gomez
add6204484 Stabilize rustdoc theme options 2019-11-18 16:43:47 +01:00
Nadrieril Feneanar
2079ae3a52
Update src/test/ui/pattern/issue-53820-slice-pattern-large-array.rs
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-18 15:40:49 +00:00
Simon Sapin
74b571402f Use drop_in_place in array::IntoIter::drop
This skips the loop when the element type is known not to have drop glue, even in debug mode.
2019-11-18 15:56:26 +01:00
bors
a0d40f8bdf Auto merge of #66459 - eddyb:update-llvm-wasm-dwarf, r=alexcrichton
Update src/llvm-project to include rust-lang/llvm-project#27.

See https://github.com/rust-lang/llvm-project/pull/27, which works around https://github.com/rust-lang/llvm-project/pull/20#discussion_r344425408 (where I stumbled over some UB in DWARF emission for WASM, resulting in non-deterministic output).

r? @alexcrichton cc @yurydelendik
2019-11-18 09:14:12 +00:00
Harald Hoyer
de122e673a
std::error::Chain: remove Copy
remove Copy from Iterator as per comment
https://github.com/rust-lang/rust/issues/58520#issuecomment-553682166
2019-11-18 09:01:34 +01:00
Camille GILLOT
a65091ffff Rename generated lifetime. 2019-11-18 08:41:28 +01:00
Camille GILLOT
35cba9eb0b Retire EnumLiftImpl. 2019-11-18 08:41:28 +01:00
Camille GILLOT
033d1df19b Retire BraceStructLiftImpl. 2019-11-18 08:41:28 +01:00
Camille GILLOT
2add2075de Create derive proc-macro for Lift trait. 2019-11-18 08:41:28 +01:00
bors
9966af3897 Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
Make a test compatible across python versions.

Progress on #65063

This PR allows this test to work on both python2 and python3, ~~and it also allows `./x.py test` to fully complete on my system without python2 installed at all.~~
2019-11-18 06:09:04 +00:00
bors
d67ca28354 Auto merge of #66238 - ehuss:stabilize-rustdoc-edition, r=GuillaumeGomez
rustdoc: Stabilize `edition` annotation.

The rustdoc `edition` annotation is currently ignored on stable. This means that the tests will be ignored, unless there is a `rust` annotation, then it will use the global edition. I suspect this was just an oversight during the edition stabilization, but I don't know. Example:

```rust
/// ```edition2018
/// // This code block was ignored on stable.
/// ```

/// ```rust,edition2018
/// // This code block would use whatever edition is passed on the command line.
/// ```
```

AFAIK, it is not possible to write a test that verifies stable behavior, as all tests appear to set RUSTC_BOOTSTRAP which forces all tests to run as "nightly", even on a stable release.

Closes #65980
2019-11-18 03:06:42 +00:00
bors
361791bb5f Auto merge of #65456 - estebank:trait-bound-borrow, r=matthewjasper
Suggest borrowing when it would satisfy an unmet trait bound

When there are multiple implementors for the same trait that is present
in an unmet binding, modify the E0277 error to refer to the parent
obligation and verify whether borrowing the argument being passed in
would satisfy the unmet bound. If it would, suggest it.

Fix #56368.
2019-11-18 00:05:38 +00:00