Commit Graph

3299 Commits

Author SHA1 Message Date
Manish Goregaokar
e2b7458a97
Rollup merge of #48020 - RalfJung:type-alias-bounds, r=petrochenkov
Warn about more ignored bounds in type aliases

It seems that all bounds in type aliases are entirely ignored, not just type bounds. This extends the warning appropriately.

I assume this should be made a hard error with the next epoch? I can't see any reason to accept these programs. (And suddenly enforcing these type bounds would be a breaking change.)
2018-02-07 08:30:57 -08:00
Manish Goregaokar
83a9f4980e Fill in long diagnostic 2018-02-06 11:46:42 -08:00
Ralf Jung
ac183f83df improve wording: bounds -> generic bounds 2018-02-06 16:28:25 +01:00
Manish Goregaokar
d0ab8f03bb Convert tyvar_behind_raw_pointer to hard error for the 2018 epoch 2018-02-05 22:16:42 -05:00
Ralf Jung
2aae22746e Warn about more ignored bounds on type aliases 2018-02-05 21:20:57 +01:00
Ralf Jung
c83dd03062 Clarify 'trait bounds ignored' wording 2018-02-05 17:31:46 +01:00
bors
9af374abf9 Auto merge of #47915 - eddyb:layout-of, r=nikomatsakis
rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf.

This PR provides `tcx.layout_of(param_env.and(ty))` as the idiomatic replacement for the existing `(tcx, param_env).layout_of(ty)` and removes fragile (coherence-wise) layout-related tuple impls.

r? @nikomatsakis
2018-02-04 03:33:44 +00:00
bors
3d292b793a Auto merge of #47845 - Zoxc:gen-fixes, r=nikomatsakis
Generator bugfixes

r? @nikomatsakis
2018-02-03 17:28:08 +00:00
bors
6c15dffc43 Auto merge of #47791 - estebank:mismatched-trait-impl, r=nikomatsakis
Tweak presentation on lifetime trait mismatch

 - On trait/impl method discrepancy, add label pointing at trait signature.
 - Point only at method definition when referring to named lifetimes on lifetime mismatch.
 - When the sub and sup expectations are the same, tweak the output to avoid repeated spans.

Fix #30790, CC #18759.
2018-02-03 01:26:56 +00:00
bors
56733bc9f8 Auto merge of #47738 - nikomatsakis:issue-47139-master, r=arielb1
remove intercrate ambiguity hints

The scheme was causing overflows during coherence checking (e.g. #47139). This is sort of a temporary fix; the proper fix I think involves reworking trait selection in deeper ways.

cc @sgrif -- this *should* fix diesel

cc @qnighy -- I'd like to discuss you with alternative techniques for achieving the same end. =) Actually, it might be good to put some energy into refactoring traits first.

r? @eddyb
2018-02-01 07:33:35 +00:00
Eduard-Mihai Burtescu
9c3dc7e872 rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. 2018-02-01 00:01:08 +02:00
Niko Matsakis
514ae7d917 change overlapping_impls to take a tcx and create the infcx 2018-01-30 14:00:24 -05:00
Niko Matsakis
4c210afb19 make overlapping_impls call closures instead of returning 2018-01-30 13:43:41 -05:00
John Kåre Alsaker
77bc26f4f3 Require yield types to be sized 2018-01-29 10:02:04 +01:00
John Kåre Alsaker
ad058cfafe Make pattern visiting consistent 2018-01-29 10:02:03 +01:00
Esteban Küber
67696be160 Point only at method signatures and point at trait
- On mismatch between impl and trait method, point at the trait
   signature.
 - Point only at the method signature instead of the whole body on
   trait/impl mismatch errors.
2018-01-28 17:06:30 -08:00
Eduard-Mihai Burtescu
46a9bdda78 rustc: replace "lvalue" terminology with "place" in the code. 2018-01-29 01:49:29 +02:00
Eduard-Mihai Burtescu
06a0e4f7ae rustc: move expr_is_lval to rustc_typeck and rename to is_place_expr. 2018-01-29 01:24:25 +02:00
Eduard-Mihai Burtescu
3f4a489f8f rustc_typeck: rename LvalueOp to PlaceOp. 2018-01-29 01:20:18 +02:00
Eduard-Mihai Burtescu
2c4a75bf09 rustc_typeck: rename LvaluePreference::PreferMutLvalue to Needs::MutPlace. 2018-01-29 00:59:25 +02:00
Eduard-Mihai Burtescu
800166cf96 rustc: remove LvaluePreference argument from Ty::builtin_deref. 2018-01-29 00:42:51 +02:00
David Wood
c71cec8834
end_point handling multibyte characters correctly. 2018-01-27 11:46:27 +00:00
Alex Crichton
6da912e2a1 Merge branch 'explain' of https://github.com/estebank/rust into rollup 2018-01-26 06:50:31 -08:00
Alex Crichton
ab623f2dc2 Merge branch 'cache-ty-collect' of https://github.com/michaelwoerister/rust into rollup 2018-01-25 13:50:25 -08:00
Alex Crichton
024e3aaff7 Rollup merge of #47696 - Zoxc:variance-rg, r=nikomatsakis
Make use of the implemented red/green algorithm for variance

r? @michaelwoerister
2018-01-25 13:49:50 -08:00
Alex Crichton
0ee698e4a6 Rollup merge of #47668 - nikomatsakis:issue-47511, r=eddyb
do not ICE when return type includes unconstrained anon region

It turns out that this *can* happen after all, if the region is only
used in projections from the input types.

Fixes https://github.com/rust-lang/rust/issues/47511

r? @eddyb
2018-01-25 13:49:49 -08:00
Guillaume Gomez
a809da3fee Rollup merge of #47702 - etaoins:fix-into-cast-paren-precedence, r=petrochenkov
Fix into() cast paren check precedence

As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are:

```
error[E0308]: mismatched types
 --> main.rs:4:10
  |
4 |     test(foo as i8);
  |          ^^^^^^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
  |
4 |     test(foo as i8.into());
  |
```

```
error[E0308]: mismatched types
 --> main.rs:4:10
  |
4 |     test(*foo);
  |          ^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
  |
4 |     test(*foo.into());
  |
```

As suggested by @petrochenkov switch the precedence check to `PREC_POSTFIX`. This catches both `as` and unary operators. Fixes #47699.

r? @petrochenkov
2018-01-25 15:52:15 +01:00
Guillaume Gomez
e26aac5a9f Rollup merge of #47534 - estebank:suggest-public-traits, r=petrochenkov
On missing method do not suggest private traits

When encountering a method call for an ADT that doesn't have any
implementation of it, we search for traits that could be implemented
that do have that method. Filter out private non-local traits that would
not be able to be implemented.

This doesn't account for public traits that are in a private scope, but
works as a first approximation and is a more correct behavior than the
current one.

Fix #45781.
2018-01-25 15:52:11 +01:00
John Kåre Alsaker
62afc43a84 Make use of the implemented red/green algorithm for variance 2018-01-24 12:07:37 +01:00
Ryan Cumming
65b1e86aed Fix into() cast paren check precedence
As discussed in #47699 the logic for determining if an expression needs
parenthesis when suggesting an `.into()` cast is incorrect. Two broken
examples from nightly are:

```
error[E0308]: mismatched types
 --> main.rs:4:10
  |
4 |     test(foo as i8);
  |          ^^^^^^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
  |
4 |     test(foo as i8.into());
  |
```

```
error[E0308]: mismatched types
 --> main.rs:4:10
  |
4 |     test(*foo);
  |          ^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
  |
4 |     test(*foo.into());
  |
```

As suggested by @petrochenkov switch the precedence check to
PREC_POSTFIX. This catches both `as` and unary operators. Fixes #47699.
2018-01-24 20:31:36 +11:00
Esteban Küber
482f7f1978 Rename -Z explain to -Z teach 2018-01-23 11:34:57 -08:00
Esteban Küber
3dac0f5a9c Create StructuredDiagnostic
Create the concept of an `StructuredDiagnostic` that is self-contained
with enough knowledge of all variables to create a `DiagnosticBuilder`,
including different possible versions (one line output and expanded
explanations).
2018-01-23 11:01:38 -08:00
Michael Woerister
a5d7aae8cf Make ty::Generics::type_param_to_index use DefId instead of DefIndex as key. 2018-01-23 10:44:52 +01:00
John Kåre Alsaker
ccf0d8399e Adds support for immovable generators. Move checking of invalid borrows across suspension points to borrowck. Fixes #44197, #45259 and #45093. 2018-01-23 05:10:38 +01:00
Esteban Küber
ffb827aff3 Fix test redux 2018-01-22 15:46:51 -08:00
Esteban Küber
864f6d180b Only emit expanded diagnostic information once 2018-01-22 15:46:51 -08:00
Esteban Küber
fdfb9a2963 Add explanation for E0607 2018-01-22 15:46:50 -08:00
Esteban Küber
9adf2b2225 Add --explain for extended error explanations 2018-01-22 15:46:49 -08:00
Niko Matsakis
215d66b998 do not ICE when return type includes unconstrained anon region
It turns out that this *can* happen after all, if the region is only
used in projections from the input types.
2018-01-22 17:36:43 -05:00
Esteban Küber
4121ddb041 Do not suggest private traits that have missing method
When encountering a method call for an ADT that doesn't have any
implementation of it, we search for traits that could be implemented
that do have that method. Filter out private non-local traits that would
not be able to be implemented.

This doesn't account for public traits that are in a private scope, but
works as a first approximation and is a more correct behavior than the
current one.
2018-01-22 08:29:24 -08:00
bors
b887317da6 Auto merge of #47158 - rkruppe:repr-transparent, r=eddyb
Implement repr(transparent)

r? @eddyb for the functional changes. The bulk of the PR is error messages and docs, might be good to have a doc person look over those.

cc #43036
cc @nox
2018-01-22 08:10:41 +00:00
Guillaume Gomez
6bb1b0dd37 Rollup merge of #47247 - estebank:suggest-cast, r=petrochenkov
Suggest casting on numeric type error

Re #47168.
2018-01-21 23:11:37 +01:00
Robin Kruppe
2be697bc21 Implement repr(transparent) 2018-01-16 08:58:32 +01:00
Esteban Küber
4a7691692c Further tweaks to the output
- Properly address Variant Ctors
- Show signature if span of trait method without `self` is not available
2018-01-15 12:35:15 -08:00
Esteban Küber
afe8d13a66 Use single source of truth for expr precedence
Introduce a new unified type that holds the expression precedence for
both AST and HIR nodes.
2018-01-15 02:02:37 -08:00
Esteban Küber
09efaaf076 Use s::u::p::expr_precedence and fix message
- Use `syntax::util::parser::expr_precedence` to determine wether
   parenthesis are needed around the casting target.
 - Update message to not incorrectly mention rounding on `.into()`
   suggestions, as those types that do have that implemented will never
   round.
2018-01-14 22:46:24 -08:00
Esteban Küber
509ea8efc6 Only suggest casting numeric types using into() 2018-01-14 22:46:24 -08:00
Esteban Küber
af91d9955b Use into for casting when possible 2018-01-14 22:46:24 -08:00
Esteban Küber
aec16237e4 Suggest casting on numeric type error 2018-01-14 22:46:23 -08:00
Vadim Petrochenkov
d19e4c4a85 syntax: Rewrite parsing of impls
Properly parse impls for the never type `!`
Recover from missing `for` in `impl Trait for Type`
Prohibit inherent default impls and default impls of auto traits
Change wording in more diagnostics to use "auto traits"
Some minor code cleanups in the parser
2018-01-14 18:10:05 +03:00