Commit graph

4519 commits

Author SHA1 Message Date
Yuki Okushi
a16db3dcda
Rollup merge of #82774 - JohnTitor:bad-diag-for-anon-params-with-ref, r=estebank
Fix bad diagnostics for anon params with ref and/or qualified paths

Fixes #82729
It's easier to review with hiding whitespace changes.
2021-03-17 15:20:48 +09:00
Yuki Okushi
2d99e68940 Emit more pretty diagnostics for qualified paths 2021-03-17 09:57:58 +09:00
Yuki Okushi
8240f1a3d3 Fix bad diagnostics for anon params with qualified paths 2021-03-17 07:45:19 +09:00
Yuki Okushi
ea355bc6be Fix bad diagnostics for anon params with ref 2021-03-17 07:45:19 +09:00
bors
e655fb6221 Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper
Implement (but don't use) valtree and refactor in preparation of use

This PR does not cause any functional change. It refactors various things that are needed to make valtrees possible. This refactoring got big enough that I decided I'd want it reviewed as a PR instead of trying to make one huge PR with all the changes.

cc `@rust-lang/wg-const-eval` on the following commits:

* 2027184 implement valtree
* eeecea9 fallible Scalar -> ScalarInt
* 042f663 ScalarInt convenience methods

cc `@eddyb` on ef04a6d

cc `@rust-lang/wg-mir-opt` for cf1700c (`mir::Constant` can now represent either a `ConstValue` or a `ty::Const`, and it is totally possible to have two different representations for the same value)
2021-03-16 22:42:56 +00:00
bors
f5d8117c33 Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis
2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled

This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments

To do so, we

- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code

Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`
2021-03-16 19:19:06 +00:00
Oli Scherer
c4d564c780
Update compiler/rustc_middle/src/ty/consts/valtree.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16 18:31:33 +01:00
Oli Scherer
5b9bd903c0
Update compiler/rustc_middle/src/ty/consts/valtree.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16 18:31:25 +01:00
Oli Scherer
f0997fa1e8
Update compiler/rustc_mir/src/const_eval/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16 18:26:09 +01:00
Yuki Okushi
ec074276ab
Rollup merge of #83196 - tmiasko:valid-range-delay-span-bug, r=oli-obk
Use delay_span_bug instead of panic in layout_scalar_valid_range

#83054 introduced validation of scalar range attributes, but panicking
code that uses the attribute remained reachable. Use `delay_span_bug`
instead to avoid the ICE.

Fixes #83180.
2021-03-16 23:54:03 +09:00
bors
f24ce9b014 Auto merge of #82838 - Amanieu:rustdoc_asm, r=nagisa
Allow rustdoc to handle asm! of foreign architectures

This allows rustdoc to process code containing `asm!` for architectures other than the current one. Since this never reaches codegen, we just replace target-specific registers and register classes with a dummy one.

Fixes #82869
2021-03-16 10:05:46 +00:00
bors
195ad4830e Auto merge of #82898 - oli-obk:tait_🧊, r=nikomatsakis
Add a `min_type_alias_impl_trait` feature gate

This new feature gate only permits type alias impl trait to be constrained by function and trait method return types. All other possible constraining sites like const/static types, closure return types and binding types are now forbidden and gated under the `type_alias_impl_trait` and `impl_trait_in_bindings` feature gates (which are both marked as incomplete, as they have various ways to ICE the compiler or cause query cycles where they shouldn't).

r? `@nikomatsakis`

This is best reviewed commit-by-commit
2021-03-16 04:24:48 +00:00
bors
4c10c84c63 Auto merge of #83153 - Aaron1011:eval-always-extern_mod_stmt_cnum, r=michaelwoerister
Mark `extern_mod_stmt_cnum` as `eval_always`

This query reads from global untracked state, so it always needs to be
evaluated.
2021-03-16 01:33:06 +00:00
Tomasz Miąsko
335427a3db Use delay_span_bug instead of panic in layout_scalar_valid_range
83054 introduced validation of scalar range attributes, but panicking
code that uses the attribute remained reachable. Use `delay_span_bug`
instead to avoid the ICE.
2021-03-16 00:00:00 +00:00
Oli Scherer
c2683aa569 Explain each variant of TAIT usage with examples 2021-03-15 17:39:18 +00:00
Oli Scherer
4a6dc8e203 Only allow tait defining uses in function and method return position 2021-03-15 17:36:57 +00:00
Oli Scherer
cdbb0ff8ca Special case type aliases from impl trait in const/static types 2021-03-15 17:33:28 +00:00
Oli Scherer
1f7df1956a Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour
This makes `type_alias_impl_trait` not actually do anything anymore
2021-03-15 17:32:43 +00:00
Roxane
189d206522 Fix error after rebase 2021-03-15 13:16:18 -04:00
Roxane
22eaffe71a Add comments with examples and tests 2021-03-15 13:16:04 -04:00
Oli Scherer
f261a82a8d Use tracing instrumentation for better bug diagnosing 2021-03-15 16:53:05 +00:00
Aaron Hill
e70d47b3b5
Mark extern_mod_stmt_cnum as eval_always
This query reads from global untracked state, so it always needs to be
evaluated.
2021-03-15 12:26:49 -04:00
Dylan DPC
2816c110e0
Rollup merge of #83144 - hyd-dev:parse-sess-created, r=oli-obk
Introduce `rustc_interface::interface::Config::parse_sess_created` callback

Resolves #82900.

cc `@oli-obk`
2021-03-15 16:23:00 +01:00
Dylan DPC
9b16c7a712
Rollup merge of #83132 - Aaron1011:fix/incr-cache-dummy, r=estebank
Don't encode file information for span with a dummy location

Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.
2021-03-15 16:22:58 +01:00
Dylan DPC
d1f5f1d156
Rollup merge of #83127 - Aaron1011:time-macros-impl-warn, r=petrochenkov
Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`

Now that future-incompat-report support has landed in nightly Cargo, we
can start to make progress towards removing the various proc-macro
back-compat hacks that have accumulated in the compiler.

This PR introduces a new lint `proc_macro_back_compat`, which results in
a future-incompat-report entry being generated. All proc-macro
back-compat warnings will be grouped under this lint. Note that this
lint will never actually become a hard error - instead, we will remove
the special cases for various macros, which will cause older versions of
those crates to emit some other error.

I've added code to fire this lint for the `time-macros-impl` case. This
is the easiest case out of all of our current back-compat hacks - the
crate was renamed to `time-macros`, so seeing a filename with
`time-macros-impl` guarantees that an older version of the parent `time`
crate is in use.

When Cargo's future-incompat-report feature gets stabilized, affected
users will start to see future-incompat warnings when they build their
crates.
2021-03-15 16:22:57 +01:00
Dylan DPC
8ec9b2a0ac
Rollup merge of #83113 - osa1:refactor_try_index_step, r=jonas-schievink
Minor refactoring in try_index_step

Merges `if-let` and `if x.is_some() { ... }` blocks
2021-03-15 16:22:56 +01:00
Dylan DPC
f1061d1dff
Rollup merge of #83108 - jyn514:remove-unused, r=estebank
Remove unused `opt_local_def_id_to_hir_id` function

Found while investigating #82933 - all LocalDefIds are expected to have
HirIds, there's no point in pretending otherwise.
2021-03-15 16:22:53 +01:00
Dylan DPC
75a15bf275
Rollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwco
Find more invalid doc attributes

- Lint on `#[doc(123)]`, `#[doc("hello")]`, etc.
- Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]`
- Add hyphen to "crate level"
- Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string
2021-03-15 16:22:52 +01:00
Dylan DPC
b8622f2b3b
Rollup merge of #83054 - tmiasko:rustc_layout_scalar_valid_range, r=davidtwco
Validate rustc_layout_scalar_valid_range_{start,end} attributes

Fixes #82251, fixes #82981.
2021-03-15 16:22:51 +01:00
Dylan DPC
4eca4929ec
Rollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkor
Custom error on literal names from other languages

This detects all Java literal types and all single word C data types, and suggests the corresponding Rust literal type.
2021-03-15 16:22:50 +01:00
hyd-dev
4709dcd476
Change the .unwrap to .expect with a helpful message 2021-03-15 20:45:45 +08:00
Oli Scherer
1ffd21a15c Pacify tidy 2021-03-15 12:19:29 +00:00
Smitty
5eae9af193 Custom error on literal names from other languages
This detects all Java literal types and all single word C data types,
and suggests the corresponding Rust literal type.
2021-03-15 08:11:02 -04:00
Oli Scherer
9f407ae5ee Do not expose fallible to_int operation on Scalar.
Any use of it has been shown to be a bug in the past.
2021-03-15 12:06:52 +00:00
Oli Scherer
0dd5a1b622 Explain pointer and dyn Trait handling in const_to_valtree 2021-03-15 12:06:52 +00:00
Oli Scherer
c01c49430c Explain how we encode enums at the encoding site 2021-03-15 12:06:52 +00:00
Oli Scherer
f646c1e434 Explain why we do not allow const_to_valtree to read from statics 2021-03-15 12:06:52 +00:00
Oli Scherer
bc8641a487 Document valtree 2021-03-15 12:06:52 +00:00
Oli Scherer
c30c1be1e6 s/ConstantSource/ConstantKind/ 2021-03-15 12:06:52 +00:00
bors
7a7bbdb3ab Auto merge of #83118 - erikdesjardins:removezst, r=oli-obk
Rebase and fixup #80493: Remove MIR assignments to ZST types

closes #80493

cc `@simonvandel`

r? `@oli-obk`
2021-03-15 11:30:33 +00:00
hyd-dev
d7ab3c77b3
Add rustc_interface::interface::Config::parse_sess_created 2021-03-15 18:24:58 +08:00
bors
2a55274e0c Auto merge of #82999 - cuviper:rustc-rayon-0.3.1, r=Mark-Simulacrum
Update to rustc-rayon 0.3.1

This pulls in rust-lang/rustc-rayon#8 to fix #81425. (h/t `@ammaraskar)`

That revealed weak constraints on `rustc_arena::DropArena`, because its
`DropType` was holding type-erased raw pointers to generic `T`. We can
implement `Send` for `DropType` (under `cfg(parallel_compiler)`) by
requiring all `T: Send` before they're type-erased.
2021-03-15 08:49:25 +00:00
bors
3963c3da02 Auto merge of #83074 - Aaron1011:new-sort-fix, r=jackh726
Avoid sorting predicates by `DefId`

Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.
2021-03-15 06:20:24 +00:00
Aaron Hill
18f89790da
Bump recursion_limit in a few places
This is needed to get rustdoc to succeed on `dist-x86_64-linux-alt`
2021-03-14 23:02:01 -04:00
Aaron Hill
f190bc4f47
Introduce proc_macro_back_compat lint, and emit for time-macros-impl
Now that future-incompat-report support has landed in nightly Cargo, we
can start to make progress towards removing the various proc-macro
back-compat hacks that have accumulated in the compiler.

This PR introduces a new lint `proc_macro_back_compat`, which results in
a future-incompat-report entry being generated. All proc-macro
back-compat warnings will be grouped under this lint. Note that this
lint will never actually become a hard error - instead, we will remove
the special cases for various macros, which will cause older versions of
those crates to emit some other error.

I've added code to fire this lint for the `time-macros-impl` case. This
is the easiest case out of all of our current back-compat hacks - the
crate was renamed to `time-macros`, so seeing a filename with
`time-macros-impl` guarantees that an older version of the parent `time`
crate is in use.

When Cargo's future-incompat-report feature gets stabilized, affected
users will start to see future-incompat warnings when they build their
crates.
2021-03-14 21:31:46 -04:00
Aaron Hill
7429c688a5
Don't encode file information for span with a dummy location
Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.
2021-03-14 20:22:13 -04:00
Erik Desjardins
47f8bacc46 remove unnecessary condition
`_local` isn't visited in `_local = <rhs>` statements in the situation
we care about
2021-03-14 20:21:20 -04:00
Roxane
74fc64303f Only borrow place for matching under specific conditions 2021-03-14 19:42:00 -04:00
Roxane
685a4c6b6b Use the correct FakeReadCause 2021-03-14 19:28:57 -04:00
Amanieu d'Antras
ba00ddc39a Address review comments 2021-03-14 23:21:03 +00:00