Commit graph

3440 commits

Author SHA1 Message Date
Aman Arora caf06bf5f5 Mark the lint doc as compile_fail 2021-02-01 22:13:42 -05:00
Aman Arora cc5e6db5f2 Migrations first pass 2021-02-01 18:38:41 -05:00
Aman Arora d3e85014a7 Process mentioned upvars for analysis first pass after ExprUseVisitor
- This allows us add fake information after handling migrations if
  needed.
- Capture analysis also priortizes what we see earlier, which means
  fake information should go in last.
2021-02-01 18:32:50 -05:00
Aman Arora bf4bdd95c3 Add lint for 2229 migrations 2021-01-31 23:21:04 -05:00
Jonas Schievink 9165676d91
Rollup merge of #81590 - KodrAus:stabilize/int_bits_const, r=m-ou-se
Stabilize int_bits_const

Closes #76904

The FCP to stabilize the `int_bits_const` feature completed on the tracking issue.
2021-01-31 16:36:57 +01:00
Jonas Schievink 36af32a740
Rollup merge of #81572 - pierwill:edit-error-codes-1, r=jonas-schievink
Edit multiple error code Markdown files

Makes small edits to several error code files. Fixes some missing punctuation. Changes some wording, grammar, and formatting for clarity and readability.

Adds a link to the rustup book in E0658.
2021-01-31 16:36:54 +01:00
Jonas Schievink 86c01ddc22
Rollup merge of #81571 - schteve:fix_e0759_typo, r=jonas-schievink
Fix typo in E0759

Minor typo in E0759 error message.
2021-01-31 16:36:52 +01:00
Jonas Schievink 024848d013
Rollup merge of #81568 - osa1:remove_old_fixme, r=jonas-schievink
Fix an old FIXME in redundant paren lint

Referenced bug was fixed a while ago
2021-01-31 16:36:51 +01:00
Jonas Schievink 991b31377c
Rollup merge of #81480 - b-naber:nested_fields_suggestion, r=estebank
Add suggestion for nested fields

Closes https://github.com/rust-lang/rust/issues/81220

r? ```@estebank```
2021-01-31 16:36:46 +01:00
Jonas Schievink ed5614599a
Rollup merge of #81255 - sunfishcode:wasi-no-export-dynamic, r=alexcrichton
Don't link with --export-dynamic on wasm32-wasi

Remove --export-dynamic from the link arguments on the wasm32-wasi
target, as it emits spurious exports and increases code size.

Leave it in place for wasm32-unknown-unknown and
wasm32-unknown-emscripten. Even though it isn't a great solution
there, users are likely depending on its behavior there.
2021-01-31 16:36:44 +01:00
Jonas Schievink 99f2f5a830
Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obk
Remove const_in_array_repeat

Fixes #80371. Fixes #81315. Fixes #80767. Fixes #75682.

I thought there might be some issue with `Repeats(_, 0)`, but if you increase the items in the array it still ICEs. I'm not sure if this is the best fix but it does fix the given issue.
2021-01-31 16:36:42 +01:00
Jonas Schievink 7e3a8ec688
Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakis
2229: Fix issues with move closures and mutability

This PR fixes two issues when feature `capture_disjoint_fields` is used.

1. Can't mutate using a mutable reference
2. Move closures try to move value out through a reference.

To do so, we
1. Compute the mutability of the capture and store it as part of the `CapturedPlace`  that is written in TypeckResults
2. Restrict capture precision. Note this is temporary for now, to allow the feature to be used with move closures and ByValue captures and might change depending on discussions with the lang team.
    - No Derefs are captured for ByValue captures, since that will result in value behind a reference getting moved.
    - No projections are applied to raw pointers since these require unsafe blocks. We capture
    them completely.

r? `````@nikomatsakis`````
2021-01-31 16:36:41 +01:00
Ashley Mannix 8940a2652e stabilize int_bits_const 2021-01-31 21:50:47 +10:00
bors 9b32429822 Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obk
codegen: assume constants cannot fail to evaluate

https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :)

r? `@oli-obk`
2021-01-31 07:03:09 +00:00
Jonas Schievink 33cd862733
Rollup merge of #81547 - pierwill:edit-typeck-mod-docs, r=davidtwco
Edit rustc_typeck top-level docs

Edit punctuation and wording in note on type variables vs. type parameters.

Also add missing punctuation and two inter-doc links.
2021-01-31 01:47:41 +01:00
Jonas Schievink 3e8ae5dcba
Rollup merge of #81472 - Aaron1011:fix/revert-cursor-clone, r=petrochenkov
Clone entire `TokenCursor` when collecting tokens

Reverts PR #80830
Fixes taiki-e/pin-project#312

We can have an arbitrary number of `None`-delimited group frames pushed
on the stack due to proc-macro invocations, which can legally be exited.
Attempting to account for this would add a lot of complexity for a tiny
performance gain, so let's just use the original strategy.
2021-01-31 01:47:34 +01:00
Jonas Schievink 84b6f46d6e
Rollup merge of #81422 - estebank:dotdot_sugg, r=davidtwco
Account for existing `_` field pattern when suggesting `..`

Follow up to #80017.
2021-01-31 01:47:33 +01:00
Jonas Schievink 1e99f26894
Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se
Stabilize by-value `[T; N]` iterator `core::array::IntoIter`

Tracking issue: https://github.com/rust-lang/rust/issues/65798

This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135.

This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2021-01-31 01:47:25 +01:00
pierwill fabb332c1a Edit multiple error code Markdown files
Makes small edits to several error code files. Fixes some
missing punctuation. Changes some wording, grammar, and formatting
for clarity and readability.

Adds a link to the rustup book in E0658.
2021-01-30 15:57:46 -08:00
kadmin 6946534d84 Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
b-naber 9946b54823 add suggestion for nested fields 2021-01-30 23:19:41 +01:00
Ömer Sinan Ağacan 8b5187f7ea Fix an old FIXME in redundant paren lint
Referenced bug was fixed a while ago
2021-01-30 22:39:56 +03:00
pierwill adfb04fc4e Edit rustc_typeck top-level docs
Edit punctuation and wording in note on type variables
vs. type parameters.

Also add missing punctuation and two inter-doc links.
2021-01-30 10:04:19 -08:00
bors fd20a8be0d Auto merge of #81453 - jumbatm:clashing-extern-decl-perf, r=nagisa
clashing_extern_declarations: Use symbol interning to avoid string alloc.

Use symbol interning as a hack to avoid allocating a string for every symbol name we store in the seen set. This hopefully addresses the minor perf regression described in https://github.com/rust-lang/rust/pull/80009#issuecomment-763526902.

r? `@nagisa`
2021-01-30 16:41:05 +00:00
Steve Heindel 642d27d40a Fix typo in E0759 2021-01-30 09:48:37 -05:00
Ralf Jung 944237f6cd codegen: assume constants cannot fail to evaluate
also don't submit code to LLVM when the session has errors
2021-01-30 12:29:57 +01:00
Yuki Okushi 5df611c5b1
Rollup merge of #81515 - eltociear:patch-7, r=jonas-schievink
Fix typo in pat.rs

parentesized -> parenthesized
2021-01-30 13:37:01 +09:00
Yuki Okushi ba40cea487
Rollup merge of #81505 - henryboisdequin:cold_path-not-pub, r=sanxiyn
`fn cold_path` doesn't need to be pub

Fixes #81429

Note: this PR also fixes a small typo that I found
2021-01-30 13:36:58 +09:00
Yuki Okushi 774ba83226
Rollup merge of #81473 - sanxiyn:write-only-field, r=oli-obk
Warn write-only fields

cc `@Boscop's` example in #49256.
2021-01-30 13:36:52 +09:00
Yuki Okushi fe27dea4b5
Rollup merge of #81468 - est31:cfg_version, r=petrochenkov
cfg(version): treat nightlies as complete

This PR makes cfg(version) treat the nightlies
for version 1.n.0 as 1.n.0, even though that nightly
version might not have all stabilizations and features
of the released 1.n.0. This is done for greater
convenience for people who want to test a newly
stabilized feature on nightly, or in other words,
give newly stabilized features as many eyeballs
as possible.

For users who wish to pin nightlies, this commit adds
a -Z assume-incomplete-release option that they can
enable if they run into any issues due to this change.
Implements the suggestion in https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454
2021-01-30 13:36:50 +09:00
Yuki Okushi 7fa991fb85
Rollup merge of #81291 - sexxi-goose:fix-struct-update-functional-record-update-syntax-error, r=nikomatsakis
Support FRU pattern with `[feature(capture_disjoint_fields)]`

In case of a functional record update syntax for creating a structure, `ExprUseVisitor` to only detect the precise use of some of the field in the `..x` part of the syntax. However, when we start building MIR, we
1. First, build the place for `x`
2. and then, add precise field projections so that only some parts of `x` end up getting read.

When `capture_disjoint_fields` is enabled, and FRU is used within a closure `x` won't be completely captured, and therefore the first step will fail. This PR updates `mir_build` to create a place builder in the first step and then create place from the builder only after applying the field projection.

Closes https://github.com/rust-lang/project-rfc-2229/issues/32
r? ``````@nikomatsakis``````
2021-01-30 13:36:46 +09:00
Yuki Okushi 91ea1cbc17
Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-se
Stabilize `unsigned_abs`

Resolves #74913.

This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`.

I have gone ahead and used this in a couple locations throughout the repository.
2021-01-30 13:36:44 +09:00
Simonas Kazlauskas 915a04e2a4 Consider Scalar to be a bool only if its unsigned
This seems right, given that conceptually bools are unsigned, but the
implications of this change may have more action at distance that I'm
not sure how to exhaustively consider.

For instance there are a number of cases where code attaches range
metadata if `scalar.is_bool()` holds. Supposedly it would no longer be
attached to the `repr(i8)` enums? Though I'm not sure why booleans are
being special-cased here in the first place...

Fixes #80556
2021-01-30 00:49:10 +02:00
Aman Arora 0f4bab246b Fixme for closure origin when reborrow is implemented 2021-01-29 16:25:01 -05:00
Aman Arora fadf03ee1b Fix typos 2021-01-29 16:01:27 -05:00
Aman Arora ffd53277dc Add fixme for precise path diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora c748f32ee4 Fix incorrect use mut diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora 604cbdcfdd Fix unused 'mut' warning for capture's root variable 2021-01-29 15:37:42 -05:00
Aman Arora 3488082582 Compute mutability of closure captures
When `capture_disjoint_fields` is not enabled, checking if the root variable
binding is mutable would suffice.

However with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.

This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in `ty::CapturedPlace` and then use
`ty::CapturedPlace::mutability` in mir_build and borrow_check.
2021-01-29 15:37:40 -05:00
Aman Arora b421cd56d9 Restrict precision of captures with capture_disjoint_fields set
- No Derefs in move closure, this will result in value behind a reference getting moved.
- No projections are applied to raw pointers, since these require unsafe blocks. We capture
  them completely.

Motivations for these are recorded here: https://hackmd.io/71qq-IOpTNqzMkPpAI1dVg?view
2021-01-29 15:37:05 -05:00
Ikko Ashimine 718398ccaf
Fix typo in pat.rs
parentesized -> parenthesized
2021-01-29 23:30:55 +09:00
bors b122908617 Auto merge of #81470 - tmiasko:remove-allocations, r=matthewjasper
Avoid memory allocation when removing dead blocks

Use `reachable_as_bitset` to reuse a bitset from the traversal rather
than allocating it seprately. Additionally check if there are any
unreachable blocks before proceeding.
2021-01-29 13:10:09 +00:00
Henry Boisdequin fd5fb86f05 fix typo 2021-01-29 16:08:49 +05:30
bors c4e33b51c1 Auto merge of #81419 - rylev:canocalize-extern-entries, r=petrochenkov
Pre-canoncalize ExternLocation::ExactPaths

This stores pre-canacolized paths inside `ExternLocation::ExactPaths` so that we don't need to canoncalize them every time we want to compare them to source lib paths.

This is related to #81414.
2021-01-29 10:11:16 +00:00
Ryan Levick 6c7ecd007f Pre-canoncalize ExternLocation::ExactPaths 2021-01-29 11:02:12 +01:00
Henry Boisdequin c2c2e8dde1 fn cold_path doesn't need to be pub 2021-01-29 14:03:01 +05:30
est31 d8b5745d46 Treat nightlies for a version as complete
This commit makes cfg(version) treat the nightlies
for version 1.n.0 as 1.n.0, even though that nightly
version might not have all stabilizations and features
of the released 1.n.0. This is done for greater
convenience for people who want to test a newly
stabilized feature on nightly.

For users who wish to pin nightlies, this commit adds
a -Z assume-incomplete-release option that they can
enable if there are any issues due to this change.
2021-01-29 07:59:19 +01:00
bors 099f27b6cb Auto merge of #81440 - tmiasko:always-live-locals, r=matthewjasper
Visit only statements in always live locals

No functional changes intended.
2021-01-29 06:56:29 +00:00
bors 74500b9978 Auto merge of #81493 - JohnTitor:rollup-sa4m4zh, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #79570 (rustc: Stabilize `-Zrun-dsymutil` as `-Csplit-debuginfo`)
 - #79819 (Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint)
 - #79991 (rustdoc: Render HRTB correctly for bare functions)
 - #80215 (Use -target when linking binaries for Mac Catalyst)
 - #81158 (Point to span of upvar making closure FnMut)
 - #81176 (Improve safety of `LateContext::qpath_res`)
 - #81287 (Split rustdoc JSON types into separately versioned crate)
 - #81306 (Fuse inner iterator in FlattenCompat and improve related tests)
 - #81333 (clean up some const error reporting around promoteds)
 - #81459 (Fix rustdoc text selection for page titles)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-29 00:58:43 +00:00
Yuki Okushi 046a414c19
Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk
clean up some const error reporting around promoteds

These are some error reporting simplifications enabled by https://github.com/rust-lang/rust/pull/80579.

Further simplifications are possible but could be blocked on making `const_err` a hard error.

r? ``````@oli-obk``````
2021-01-29 09:17:38 +09:00