Commit Graph

85756 Commits

Author SHA1 Message Date
kennytm
409382e100
Rollup merge of #55244 - wesleywiser:issue-50411, r=nikomatsakis
Don't rerun MIR passes when inlining

Fixes #50411

r? @nikomatsakis

I updated your commit message with additional details. Let me know if any of that is incorrect. I also added the appropriate `compile-flags` directive to the test.

Thanks for you help on this!

cc @RalfJung related to your PR #55086
2018-10-28 16:38:47 +08:00
kennytm
883b8199ca
Rollup merge of #55191 - GuillaumeGomez:fix-sub-variant, r=QuietMisdreavus
Fix sub-variant doc display

Fixes #54758.

<img width="1440" alt="screen shot 2018-10-19 at 01 34 11" src="https://user-images.githubusercontent.com/3050060/47189939-43481d00-d33f-11e8-868f-cf479fc79e62.png">

r? @QuietMisdreavus
2018-10-28 16:38:46 +08:00
kennytm
b9763de9b5
Rollup merge of #55148 - SimonSapin:path-fromstr, r=oli-obk
Implement FromStr for PathBuf

Initially landed in https://github.com/rust-lang/rust/pull/48292 and reverted in https://github.com/rust-lang/rust/pull/50401. This time, use `std::string::ParseError` as suggested in https://github.com/rust-lang/rust/issues/44431#issuecomment-428112632
2018-10-28 16:38:45 +08:00
Christopher Durham
0757c0fa7f Add ManuallyDrop::take
https://internals.rust-lang.org/t/mini-rfc-manuallydrop-take/8679
2018-10-28 04:16:58 -04:00
David Wood
0d06b8c8e5
Add note linking to Rust 2018 path semantics docs.
This commit extends existing path suggestions to link to documentation
on the changed semantics of `use` in Rust 2018.
2018-10-28 09:16:10 +01:00
Zack M. Davis
faea5bbc65 single-use-lifetime lint: don't false-positive on the anonymous lifetime 2018-10-28 00:14:41 -07:00
Zack M. Davis
fd28753e83 structured suggestions for single-use lifetime lint on fns and methods
It would be nice to demonstrate the shining correctness here with more
run-rustfix tests than this, but unfortunately, that doesn't work with
multipart suggestions yet (#53934).

While we're here, reword the zero-use lifetime suggestion to "elide
the unused lifetime" instead of "remove it". (It's classier.)
2018-10-28 00:14:41 -07:00
bors
1982f1887a Auto merge of #55297 - petrochenkov:uni, r=Mark-Simulacrum
Partial implementation of uniform paths 2.0 to land before beta

Reimplementation of uniform paths using in-scope resolution rather than canaries is a minor breaking change due to stricter future-proofing, so it needs to be landed before beta or backported later.

I hope to implement at least something until beta so we have less to backport.
r? @Mark-Simulacrum
2018-10-28 03:07:37 +00:00
bors
18311a6c47 Auto merge of #54683 - zackmdavis:critique_of_pure_lints, r=petrochenkov
lint reasons (RFC 2883, part 1)

This implements the `reason =` functionality described in [the RFC](https://github.com/rust-lang/rfcs/blob/master/text/2383-lint-reasons.md) under a `lint_reasons` feature gate.

![lint_reasons_pt_1](https://user-images.githubusercontent.com/1076988/46252097-eed51000-c418-11e8-8212-939d3f02f95d.png)
2018-10-28 00:28:03 +00:00
Vadim Petrochenkov
c57f0a7201 resolve: Desugar empty import groups into synthetic dummy imports
so that they are correctly resolved on 2018 edition
2018-10-28 03:06:38 +03:00
Vadim Petrochenkov
1f257bd022 resolve: Make sure macros and imports are resolved in full parent scope
Slightly simplify `fn build_reduced_graph_for_use_tree`
2018-10-28 02:56:12 +03:00
Vadim Petrochenkov
acdbd0643c resolve: More precise spans for privacy errors 2018-10-28 02:56:12 +03:00
Vadim Petrochenkov
b45b4daba7 resolve: Absolute paths may be undetermined on 2018 edition
due to macro-expanded `extern crate` items adding names to extern prelude.
2018-10-28 02:56:11 +03:00
Vadim Petrochenkov
171df347ff resolve: Refactor away legacy_macro_imports/LegacyMacroImports 2018-10-28 02:56:11 +03:00
Vadim Petrochenkov
dd3738a2ba resolve: Record full parent scope data for imports 2018-10-28 02:56:11 +03:00
Nick Fitzgerald
dc77d49775 Make a bunch of trivial methods of NonNull be #[inline] 2018-10-28 00:59:04 +02:00
Zack M. Davis
b7546150b2 back out bogus Ok-wrapping suggestion on ? arm type mismatch
This suggestion was introduced in #51938 / 6cc78bf8d7 (while
introducing different language for type errors coming from `?` rather
than a `match`), but it has a lot of false-positives (as repeatedly
reported in Issues #52537, #52598, #54578, #55336), and incorrect
suggestions carry more badness than marginal good suggestions do
goodness. Just get rid of it (unless and until someone figures out how
to do it correctly).

Resolves #52537, resolves #54578.
2018-10-27 14:55:07 -07:00
Zack M. Davis
f66ea66acd wherein the status of empty and reason-only lint attributes is clarified
We avoid an ICE by checking for an empty meta-item list before we
index into the meta-items, and leave commentary about where we'd like
to issue unused-attributes lints in the future. Note that empty lint
attributes are already accepted by the stable compiler; generalizing
this to weird reason-only lint attributes seems like the
conservative/consilient generalization.
2018-10-27 12:31:20 -07:00
Zack M. Davis
f90de1110d in which lint reasons are restricted to come last in the attribute
Vadim Petrochenkov suggested this in review ("an error? just to be
conservative"), and it turns out to be convenient from the
implementer's perspective: in the initial proposed implementation (or
`HEAD~2`, as some might prefer to call it), we were doing an entire
whole iteration over the meta items just to find the reason (before
iterating over them to set the actual lint levels). This way, we can
just peek at the end rather than adding that extra loop (or
restructuring the existing code). The RFC doesn't seem to take a
position on this, and there's some precedent for restricting things to
be at the end of a sequence (we only allow `..` at the end of a struct
pattern, even if it would be possible to let it appear anywhere in the
sequence).
2018-10-27 12:31:20 -07:00
Zack M. Davis
dc0609c247 feature-gate lint reasons
We take stability seriously, so we shy away from making even seemingly
"trivial" features insta-stable.
2018-10-27 12:31:20 -07:00
bors
cae6efc37d Auto merge of #54183 - qnighy:by-value-object-safety, r=oli-obk
Implement by-value object safety

This PR implements **by-value object safety**, which is part of unsized rvalues #48055. That means, with `#![feature(unsized_locals)]`, you can call a method `fn foo(self, ...)` on trait objects. One aim of this is to enable `Box<FnOnce>`  in the near future.

The difficulty here is this: when constructing a vtable for a trait `Foo`, we can't just put the function `<T as Foo>::foo` into the table. If `T` is no larger than `usize`, `self` is usually passed directly. However, as the caller of the vtable doesn't know the concrete `Self` type, we want a variant of `<T as Foo>::foo` where `self` is always passed by reference.

Therefore, when the compiler encounters such a method to be generated as a vtable entry, it produces a newly introduced instance called `InstanceDef::VtableShim(def_id)` (that wraps the original instance). the shim just derefs the receiver and calls the original method. We give different symbol names for the shims by appending `::{{vtable-shim}}` to the symbol path (and also adding vtable-shimness as an ingredient to the symbol hash).

r? @eddyb
2018-10-27 19:29:35 +00:00
Zack M. Davis
630c6a544f introducing lint reason annotations (RFC 2383)
This is just for the `reason =` name-value meta-item; the
`#[expect(lint)]` attribute also described in the RFC is a problem for
another day.

The place where we were directly calling `emit()` on a match block
(whose arms returned a mutable reference to a diagnostic-builder) was
admittedly cute, but no longer plausibly natural after adding the
if-let to the end of the `LintSource::Node` arm.

This regards #54503.
2018-10-27 12:28:48 -07:00
bors
b3b8760971 Auto merge of #55385 - davidtwco:issue-55288, r=oli-obk
NLL: cast causes failure to promote to static

Fixes #55288. See commit messages for more details.

r? @oli-obk
cc @nikomatsakis
cc @pnkfelix
cc @RalfJung
2018-10-27 16:50:41 +00:00
Niko Matsakis
a1be20c9ce error_reporting/mod.rs: rustfmt 2018-10-27 09:06:03 -04:00
Niko Matsakis
b24b88734d select.rs: rustfmt 2018-10-27 09:06:03 -04:00
Niko Matsakis
d4e4e374e7 apply minimum bounds when checking closure signature
Required for test expect-fn-supply-fn.rs to pass; otherwise we have
unconstrained inference variables that get inferred to `'empty`.
2018-10-27 09:06:03 -04:00
Niko Matsakis
bf51840952 distinguish user-type annotations from other annotations
In particular, we don't want to preserve the universes for the `'_`
variables that appear in there. And we don't expect to find any
placeholders, which justifies this as harmless.

(In particular, if you have a query like `Foo(!1, !2, ?3)`, then you
care about the universe of `?3`, since it may control whether `?3 =
!1` and `?3 = !2` is a valid answer. But without any placeholders, we
don't really care: any placeholders that would appear in the output
must therefore come from some fresh universe anyway.)
2018-10-27 09:06:03 -04:00
Niko Matsakis
80d9f8bb48 when canonicalizing query responses, preserve infer-var universes 2018-10-27 09:06:03 -04:00
Niko Matsakis
7f9ab60afb extend query response to potentially contain fresh universes
The idea here is that an incoming query may refer to some universes,
and they query response may contain fresh universes that go beyond
those. When we instantiate the query response in the caller's scope,
therefore, we map those new universes into fresh universes for the
caller.
2018-10-27 09:06:03 -04:00
Niko Matsakis
3ef27d82e0 allow canonicalized regions to carry universe and track max-universe
But.. we don't really use it for anything right now.
2018-10-27 09:06:01 -04:00
Niko Matsakis
784746f57e convert placeholder region vids in NLL mode as we see them 2018-10-27 08:41:12 -04:00
Niko Matsakis
018c515f07 move PlaceholderIndices into MirTypeckRegionConstraints struct 2018-10-27 08:41:12 -04:00
Guillaume Gomez
2fd378b82b Fix sub-variant doc display 2018-10-27 14:05:34 +02:00
Oliver Scherer
c04893afbb Fix an ICE in the min_const_fn analysis 2018-10-27 13:34:35 +02:00
Simonas Kazlauskas
5e50acf443 Make the Atomic types repr(C) to ensure newtype 2018-10-27 13:47:12 +03:00
Oliver Middleton
01674fbe06 Correct alignment of atomic types and (re)add Atomic{I,U}128
LLVM requires that atomic loads and stores be aligned to at least the size of the type.
2018-10-27 13:47:11 +03:00
David Wood
6208bd8e03
Refactor and add PlaceContext::AscribeUserTy.
This commit refactors `PlaceContext` to split it into four different
smaller enums based on if the context represents a mutating use,
non-mutating use, maybe-mutating use or a non-use (this is based on the
recommendation from @oli-obk on Zulip[1]).

This commit then introduces a `PlaceContext::AscribeUserTy` variant.
`StatementKind::AscribeUserTy` is now correctly mapped to
`PlaceContext::AscribeUserTy` instead of `PlaceContext::Validate`.
`PlaceContext::AscribeUserTy` can also now be correctly categorized as a
non-use which fixes an issue with constant promotion in statics after a
cast introduces a `AscribeUserTy` statement.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/122657-wg-nll/subject/.2355288.20cast.20fails.20to.20promote.20to.20'static/near/136536949
2018-10-27 12:11:37 +02:00
David Wood
8a0d8c5ab5
Test for cast causing static promotion failure.
This commit adds a test that ensures that a cast in a static doesn't
stop const promotion within the static.
2018-10-27 12:11:02 +02:00
David Wood
9169f817b3
Add helpful logging statements.
This commit adds logging statements to `promote_consts` and
`qualify_consts` to make it easier to understand what it is doing.
2018-10-27 12:10:58 +02:00
bors
f32f1113c9 Auto merge of #55150 - pnkfelix:issues-47215-54797-fix-ice-from-moving-out-of-thread-local-under-ast-borrowck, r=nikomatsakis
Do not allow moving out of thread local under ast borrowck

AST borrowck failed to prevent moving out of a thread-local static.

This was broken. And it also (sometimes?) caused an ICE during drop elaboration.

Fix #47215
Fix #54797
2018-10-27 09:56:37 +00:00
Masaki Hara
2f7ea4a872 Add more tests on unsized locals autoderef and borrowck. 2018-10-27 17:17:24 +09:00
bors
42c11de47b Auto merge of #55053 - Emerentius:test_all_again, r=alexcrichton
Add option to run all tests, again

This is a repeat of https://github.com/rust-lang/rust/pull/53527, which had to be reverted to land https://github.com/rust-lang/rust/pull/54116. It will break clippy until `compiletest-rs` can be updated and I believe we're closing on a new release date, so this may need to be delayed again until after 1.30 is out (?)

Closes #50363 again
2018-10-27 07:12:11 +00:00
Hsiang-Cheng Yang
4cb611f3d1
Update string.rs
remove unused variable i in example String::with_capacity()
2018-10-27 14:33:07 +08:00
bors
10f42cbde0 Auto merge of #55274 - pnkfelix:issue-54570-proj-path-into-pats-with-type-take-2, r=nikomatsakis
Handle bindings in substructure of patterns with type ascriptions

This attempts to follow the outline described by @nikomatsakis [here](https://github.com/rust-lang/rust/issues/47184#issuecomment-420041056). Its a bit more complicated than expected for two reasons:

 1. In general it handles sets of type ascriptions, because such ascriptions can be nested within patterns
 2.  It has a separate types in the HAIR, `PatternTypeProjections` and `PatternTypeProjection`, which are analogues to the corresponding types in the MIR.

The main reason I added the new HAIR types was because I am worried that the current implementation is inefficent, and asymptotically so: It makes copies of vectors as it descends the patterns, even when those accumulated vectors are never used.

Longer term, I would like to used a linked tree structure for the `PatternTypeProjections` and `PatternTypeProjection`, and save the construction of standalone vectors for the MIR types. I didn't want to block landing this on that hypoethetical revision; but I figured I could at least make the future change easier by differentiating between the two types now.

Oh, one more thing: This doesn't attempt to handle `ref x` (in terms of ensuring that any necessary types are ascribed to `x` in that scenario as well). We should open an issue to investigate supporting that as well. But I didn't want to block this PR on that future work.

Fix #54570
2018-10-27 00:39:11 +00:00
Felix S. Klock II
639a3ffadc add user_ty.projs support to AscribeUserType. 2018-10-26 23:47:53 +02:00
Felix S. Klock II
82ab668a55 Further foundational stuff on ProjectionKind before I add it to AscribeUserType. 2018-10-26 23:47:53 +02:00
Felix S. Klock II
47e2d825e1 Add intern table for List<ProjectionElem<'tcx, (), ()>>.
Also added alias `ProjectionKind<'tcx>` for `ProjectionElem<'tcx, (), ()>`.
2018-10-26 23:47:53 +02:00
Felix S. Klock II
92cbe4772a Add test for normalization during field-lookup on patterns with ascribed types.
As a drive-by, also added test analogous to existing
static_to_a_to_static_through_tuple, but now apply to a struct instead
of a tuple.
2018-10-26 23:47:53 +02:00
Felix S. Klock II
f09a0eb9c1 regression test for ICE I encountered in my patch. 2018-10-26 23:47:53 +02:00
Felix S. Klock II
7e761967ad Update mir-opt tests to reflect change to AscribeUserType to carry a UserTypeProjection. 2018-10-26 23:47:53 +02:00