Commit Graph

9421 Commits

Author SHA1 Message Date
Tyler Mandry
1662888126 Rollup merge of #68479 - Tyg13:unused_parens_return, r=Centril
Implement `unused_parens` for block return values

Fixes #68386

r? @Centril
2020-01-24 00:30:59 -08:00
Tyler Mandry
e7752aefdc Rollup merge of #68469 - ollie27:skip_count, r=sfackler
Avoid overflow in `std::iter::Skip::count`

The call to `count` on the inner iterator can overflow even if `Skip` itself would return less that `usize::max_value()` items.

Fixes #68139
2020-01-24 00:30:56 -08:00
Tyler Mandry
143059deaf Rollup merge of #68438 - Aaron1011:fix/tait-non-defining, r=estebank
Account for non-types in substs for opaque type error messages

Fixes #68368

Previously, I assumed that the substs contained only types, which caused
the computed index number to be wrong.
2020-01-24 00:30:55 -08:00
Tyler Mandry
eb769ed6b0 Rollup merge of #68424 - estebank:suggest-borrow-for-non-copy-vec, r=davidtwco
Suggest borrowing `Vec<NonCopy>` in for loop

Partially address #64167.
2020-01-24 00:30:53 -08:00
Esteban Küber
55dce720b2 Account for ty::Error when suggesting impl Trait or Box<dyn Trait> 2020-01-23 17:04:09 -08:00
Tomasz Miąsko
2fd6c4a18a Remove unused ignore-license directives
The tidy check was removed in rust-lang/rust#53617
2020-01-24 00:00:00 +00:00
Matthew Jasper
f30a8186f7 Make pointers to statics internal 2020-01-23 21:38:15 +00:00
Matthew Maurer
72aaa3a414 rustc: Allow cdylibs to link against dylibs
Previously, rustc mandated that cdylibs could only link against rlibs as
dependencies (not dylibs).
This commit disables that restriction and tests that it works in a
simple case.
2020-01-23 13:10:04 -08:00
Linus Färnstrand
61fecfb82f Add test accessing the module level int/float consts 2020-01-23 20:55:07 +01:00
Linus Färnstrand
6ce16cfa42 Remove no longer valid test 2020-01-23 20:55:06 +01:00
Esteban Küber
6eaf59dfc8 use diagnostic_item and modify wording 2020-01-23 11:51:56 -08:00
Tuomas Lappeteläinen
ad1cdecaeb add a test for #60976
The test fails on 1.36.0 but passes on master.
2020-01-23 15:37:39 +02:00
Tyler Lanphear
6f7e89ffe3 unused-parens: implement for block return values 2020-01-23 00:42:35 -05:00
bors
462fc37fa8 Auto merge of #68298 - Mark-Simulacrum:binary-depdep-fix, r=petrochenkov
Avoid declaring a fake dependency edge

When we're producing an rlib, we do not need anything more than an rmeta file
for each of our dependencies (this is indeed utilized by Cargo for pipelining).
Previously, we were still storing the paths of possible rlib/dylib crates, which
meant that they could still plausibly be accessed. With -Zbinary-dep-depinfo,
that meant that Cargo thought that rustc was using both the rlib and an (earlier
emitted) rmeta, and so needed a recompile, as the rlib may have finished writing
*after* compilation started (for more detail, see issue 68149).

This commit changes metadata loading to not store the filepaths of dylib/rlib if
we're going to end up creating an rlib only.

Fixes #68149.
2020-01-23 03:48:07 +00:00
Tyler Mandry
1077adae12 Rollup merge of #68425 - phi-gamma:try-method, r=varkor
Fix try-op diagnostic in E0277 for methods

For methods the try-op diagnostic displays the empty string where
it has more descriptive strings like “a function” otherwise:

    error[E0277]: the `?` operator can only be used in  that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
                                                      ^^
       | |             ^^ cannot use the `?` operator in  that returns `()`
                                                        ^^

I’m seeing this on nightly (rustc 1.42.0-nightly (b5a3341f1
2020-01-20)) and [on the playpen](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0e7ce7792c2aceb8056941710d539124).

The changeset add strings for impl methods and trait provided
methods and test cases for the option type.
2020-01-22 16:02:17 -08:00
Tyler Mandry
bd090c9e8a Rollup merge of #68388 - varkor:toogeneric-wf, r=eddyb
Make `TooGeneric` error in WF checking a proper error

`TooGeneric` is encountered during WF checking when we cannot determine that a constant involving a generic parameter will always be evaluated successfully (rather than resulting in an error). In these cases, the burden of proof should be with the caller, so that we can avoid post-monomorphisation tim errors (which was the previous previous behaviour). This commit ensures that this situation produces a proper compiler error, rather than silently ignoring it or ICEing.

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

r? @eddyb
2020-01-22 16:02:13 -08:00
Tomasz Miąsko
d915c016c9 Use check-pass mode for lint tests 2020-01-23 00:00:00 +00:00
Tomasz Miąsko
5c73d21eaa Use check-pass mode for nll tests 2020-01-23 00:00:00 +00:00
Oliver Middleton
9d3e84432d Avoid overflow in std::iter::Skip::count
The call to `count` on the inner iterator can overflow even if `Skip` itself would return less that `usize::max_value()` items.
2020-01-22 20:28:28 +00:00
bors
ae66171b41 Auto merge of #68069 - JohnTitor:fix-closure-ice, r=matthewjasper
Attempt to fix ICE #68025

Fixes #68025
2020-01-22 13:10:49 +00:00
Aaron Hill
4ee4287b1d Account for non-types in substs for opaque type error messages
Fixes #68368

Previously, I assumed that the substs contained only types, which caused
the computed index number to be wrong.
2020-01-21 18:49:01 -05:00
Esteban Küber
c775927d7f Suggest borrowing Vec<NonCopy> in for loop
Partially address #64167.
2020-01-21 11:11:00 -08:00
Mazdak Farrokhzad
58504823f5 Rollup merge of #68399 - Centril:check-match-unify, r=oli-obk
check_match: misc unifications and ICE fixes

These are some unifications made as a by-product of working on `hir::ExprKind::Let`.

Fixes https://github.com/rust-lang/rust/issues/68396.
Fixes https://github.com/rust-lang/rust/issues/68394.
Fixes https://github.com/rust-lang/rust/issues/68393.

r? @oli-obk @matthewjasper
2020-01-21 19:42:25 +01:00
Mazdak Farrokhzad
3484e2fab4 Rollup merge of #68140 - ecstatic-morse:const-trait-bound-opt-out, r=oli-obk
Implement `?const` opt-out for trait bounds

For now, such bounds are treated exactly the same as unprefixed ones in all contexts. [RFC 2632](https://github.com/rust-lang/rfcs/pull/2632) does not specify whether such bounds are forbidden outside of `const` contexts, so they are allowed at the moment.

Prior to this PR, the constness of a trait bound/impl was stored in `TraitRef`. Now, the constness of an `impl` is stored in `ast::ItemKind::Impl` and the constness of a bound in `ast::TraitBoundModifer`. Additionally, constness of trait bounds is now stored in an additional field of `ty::Predicate::Trait`, and the combination of the constness of the item along with any `TraitBoundModifier` determines the constness of the bound in accordance with the RFC. Encoding the constness of impls at the `ty` level is left for a later PR.

After a discussion in \#wg-grammar on Discord, it was decided that the grammar should not encode the mutual exclusivity of trait bound modifiers. The grammar for trait bound modifiers remains `[?const] [?]`. To encode this, I add a dummy variant to `ast::TraitBoundModifier` that is used when the syntax `?const ?` appears. This variant causes an error in AST validation and disappears during HIR lowering.

cc #67794

r? @oli-obk
2020-01-21 19:42:20 +01:00
Philipp Gesang
02e66baac6 Test try diagnostics for impl and trait methods
Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
2020-01-21 18:56:56 +01:00
bors
ce361fb24f Auto merge of #68267 - estebank:lt-sugg, r=petrochenkov
Tweak lifetime definition errors

Taking inspiration from the narrative in @fasterthanlime's https://fasterthanli.me/blog/2019/declarative-memory-management/, add suggestions to some lifetime definition errors.
2020-01-21 06:28:33 +00:00
varkor
dd0507c054 Make TooGeneric error in WF checking a proper error
`TooGeneric` is encountered during WF checking when we cannot determine that a constant involving a generic parameter will always be evaluated successfully (rather than resulting in an error). In these cases, the burden of proof should be with the caller, so that we can avoid post-monomorphisation tim errors (which was the previous previous behaviour). This commit ensures that this situation produces a proper compiler error, rather than silently ignoring it or ICEing.
2020-01-21 01:03:15 +00:00
Mazdak Farrokhzad
58eb03d20f check_match: simplify check_arm 2020-01-20 23:39:24 +01:00
Yuki Okushi
8d2bac8dff Rollup merge of #68302 - anp:caller-fn-ptr, r=eddyb,oli-obk
Fix #[track_caller] and function pointers

Starting with failing tests, fix the miscompilation and ICE caused by `ReifyShim` bug.

Fixes #68178.
2020-01-21 07:32:45 +09:00
Yuki Okushi
bff216c56f Rollup merge of #68297 - Aaron1011:fix/new-const-prop-bounds, r=oli-obk
Filter and test predicates using `normalize_and_test_predicates` for const-prop

Fixes #68264

Previously, I attempted to use
`substitute_normalize_and_test_predicates` to detect unsatisfiable
bounds. Unfortunately, since const-prop runs in a generic environment
(we don't have any of the function's generic parameters substituted),
this could lead to cycle errors when attempting to normalize predicates.

This check is replaced with a more precise check. We now only call
`normalize_and_test_predicates` on predicates that have the possibility
of being proved unsatisfiable - that is, predicates that don't depend
on anything local to the function (e.g. generic parameters). This
ensures that we don't hit cycle errors when we normalize said
predicates, while still ensuring that we detect unsatisfiable
predicates.

I haven't been able to come up with a minimization of the Diesel issue - however, I've verified that it compiles successfully.
2020-01-21 07:32:44 +09:00
Yuki Okushi
eff6381c32 Rollup merge of #68290 - petrochenkov:passcheck, r=oli-obk
Fix some tests failing in `--pass check` mode

Warnings reported at codegen or linking time either have to be converted to errors (preferable), or the tests for them need to be marked with `// ignore-pass` (as a last resort).

ecd5852194 turned them from errors to warnings, but that shouldn't be necessary because it's still clear from the `.stderr` output that the errors are lints and not hard-coded.
2020-01-21 07:32:42 +09:00
Mark Rousskov
be663bf850 Correct rmeta/rlib test 2020-01-20 16:00:01 -05:00
Mazdak Farrokhzad
78f0c7fd64 check_match: unify some lowering code and fix some ICEs 2020-01-20 19:46:27 +01:00
Mark Rousskov
a804a45528 Fix UI test
fmt::Formatter is still not Send/Sync, but the UI test emitted two errors, for
the dyn Write and the Void inside Formatter. As of this PR, the Void is now
gone, but the dyn Write remains.
2020-01-20 12:17:12 -05:00
Mazdak Farrokhzad
71450c7aad generalize bindings_with_variant_name lint 2020-01-20 18:00:04 +01:00
Mazdak Farrokhzad
25460ebef6 transparent_enums: test alignment 2020-01-20 11:18:05 +01:00
Mazdak Farrokhzad
93efe41b4e stabilize transparent_enums 2020-01-20 11:18:05 +01:00
Dylan MacKenzie
23ea42cfd1 Update tests 2020-01-20 01:28:10 -08:00
Dylan DPC
5d8edc99aa Rollup merge of #68335 - RalfJung:drop-in-place, r=Mark-Simulacrum
Remove real_drop_in_place

In af9b057156, I added `real_drop_in_place` because Stacked Borrows at the time couldn't handle transmuting of mutable references to raw pointers and back. Stacked Borrows 2, however, doesn't have any issue with these transmutes, so it is time to remove this hack again.
2020-01-20 11:14:46 +05:30
Esteban Küber
2102723887 review comments 2020-01-19 17:31:34 -08:00
Esteban Küber
78d3ea5484 When encountering an expected named lifetime and none are present, suggest adding one 2020-01-19 17:31:33 -08:00
Esteban Küber
6ba08755df When encountering an undefined named lifetime, point to where it can be
This doesn't mention that using an existing lifetime is possible, but
that would hopefully be clear as always being an option. The intention
of this is to teach newcomers what the lifetime syntax is.
2020-01-19 17:31:33 -08:00
bors
29b854fb74 Auto merge of #68057 - Aaron1011:fix/marker-trait-selection, r=matthewjasper
Don't discard marker trait impls when inference variables are present

Fixes #61651

Previously, we would unconditionally discard impl candidates for marker
traits during trait selection. However, if the predicate had inference
variables, this could have the effect of constrainting inference
variables (due to a successful trait selection) when we would have
otherwise failed due to mutliple applicable impls,

This commit prevents marker trait impls from being discarded while the
obligation predicate has any inference variables, ensuring that
discarding impls will never cause us to incorrectly constraint inference
variables.
2020-01-20 00:10:48 +00:00
Adam Perry
72dffac6cf Test that ReifyShim + caller_location return the def site. 2020-01-19 14:26:28 -08:00
Adam Perry
fd90e56120 Add failing #[track_caller] test with fn pointers. 2020-01-19 14:26:28 -08:00
Yuki Okushi
2ecc48ffa1 Fix ICE #68025 2020-01-20 07:06:27 +09:00
Ralf Jung
95934937bb fix real_drop_in_place in comments 2020-01-19 10:11:16 -06:00
Dylan DPC
d276e6942e Rollup merge of #68348 - xfix:patch-14, r=nagisa
Make iter::Empty<T> Send and Sync for any T

Continuing from #57682

It's quite funny, when I initially submitted this pull request, I said "Likely nobody will be using that property of `iter::empty`", but then a year later I got a compilation error because it wasn't `Send` and `Sync`.

Unfortunately, `PhantomData<fn() -> T>` still errors out. Oh well. I proposed `
struct PhantomFnWorkaround<T>(fn() -> T);`, but dtolnay did not like it, so using explicit implementations.
2020-01-19 17:22:09 +05:30
csmoe
cd7b5edc2c update test ui for raw-ptr borrow inside generator 2020-01-19 13:22:41 +08:00
Mazdak Farrokhzad
57b6843100 slice_patterns: address review comments 2020-01-18 19:33:47 +01:00