Commit graph

4740 commits

Author SHA1 Message Date
Aman Arora
88db752e57 Hash hir_owner in typeck results 2021-03-19 00:39:39 -04:00
Jennifer Wills
52dba13e41 Replace closures_captures and upvar_capture with closure_min_captures
make changes to liveness to use closure_min_captures

use different span

borrow check uses new structures

rename to CapturedPlace

stop using upvar_capture in regionck

remove the bridge

cleanup from rebase + remove the upvar_capture reference from mutability_errors.rs

remove line from livenes test

make our unused var checking more consistent

update tests

adding more warnings to the tests

move is_ancestor_or_same_capture to rustc_middle/ty

update names to reflect the closures

add FIXME

check that all captures are immutable borrows before returning

add surrounding if statement like the original

move var out of the loop and rename

Co-authored-by: Logan Mosier <logmosier@gmail.com>
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2021-03-18 20:45:49 -04:00
Santiago Pastorino
778e1978d5
Mark early otherwise optimization unsound 2021-03-18 20:57:44 -03:00
SparrowLii
b93590e5d8 correct macro names 2021-03-19 03:47:13 +08:00
Camille GILLOT
e5d09fbbe9 Simplify IntEncodedWithFixedSize. 2021-03-18 20:09:00 +01:00
Camille GILLOT
5003b3dc31 Move IntEncodedWithFixedSize to rustc_serialize. 2021-03-18 20:09:00 +01:00
SparrowLii
0fa158b38f Add simd_neg platform intrinsic 2021-03-19 02:16:21 +08:00
Camille GILLOT
458d044c5b Upgrade memmap to memmap2 in other crates. 2021-03-18 18:36:55 +01:00
Aaron Hill
390d1ef6d0
Extend proc_macro_back_compat lint to actix-web
Unlike the other cases of this lint, there's no simple way to detect if
an old version of the relevant crate (`syn`) is in use. The `actix-web`
crate only depends on `pin-project` v1.0.0, so checking the version of
`actix-web` does not guarantee that a new enough version of
`pin-project` (and therefore `syn`) is in use.

Instead, we rely on the fact that virtually all of the regressed crates
are pinned to a pre-1.0 version of `pin-project`. When this is the case,
bumping the `actix-web` dependency will pull in the *latest* version of
`pin-project`, which has an explicit dependency on a newer v dependency
on a newer version of `syn`.

The lint message tells users to update `actix-web`, since that's what
they're most likely to have control over. We could potentially tell them
to run `cargo update -p syn`, but I think it's more straightforward to
suggest an explicit change to the `Cargo.toml`

The `actori-web` fork had its last commit over a year ago, and appears
to just be a renamed fork of `actix-web`. Therefore, I've removed the
`actori-web` check entirely - any crates that actually get broken can
simply update `syn` themselves.
2021-03-18 12:09:14 -04:00
bors
9d0446f1a7 Auto merge of #83166 - cjgillot:defkey-vge, r=oli-obk
Iterate on DefId for variances and generics.

Split from #80347
2021-03-18 14:46:38 +00:00
Mara Bos
cfb4ad4f2a Remove unwrap_none/expect_none from compiler/. 2021-03-18 14:25:54 +01:00
bors
2aafe452b8 Auto merge of #82868 - petrochenkov:bto, r=estebank
Report missing cases of `bare_trait_objects`

Fixes https://github.com/rust-lang/rust/issues/65371
2021-03-18 05:27:26 +00:00
bors
81c1d7a150 Auto merge of #76447 - pickfire:async-pub, r=estebank
Detect async visibility wrong order, `async pub`

Partially address #76437.
2021-03-18 02:32:39 +00:00
Erik Desjardins
93c1380e0b remove inhabitedness check 2021-03-17 20:56:38 -04:00
Erik Desjardins
1205e82578 remove unnecessary and ineffective caching 2021-03-17 20:24:29 -04:00
Vadim Petrochenkov
b48530bf8b Report missing cases of bare_trait_objects 2021-03-18 03:02:44 +03:00
Vadim Petrochenkov
38ed36bba4 hir: Preserve used syntax in TyKind::TraitObject 2021-03-18 03:02:32 +03:00
Dylan DPC
1839d1d57d
Rollup merge of #83231 - DieracDelta:lp64d-abi-for-riscvgc-unknown-none-elf, r=estebank
Switch riscvgc-unknown-none-elf use lp64d ABI

Corrects #83229 by directly specifying the target abi in the spec in the same way as is done for the `riscv64gc-unknown-linux-gnu` target [here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs).
2021-03-18 00:28:17 +01:00
Dylan DPC
bcb9226efb
Rollup merge of #83216 - jyn514:register-tool, r=petrochenkov
Allow registering tool lints with `register_tool`

Previously, there was no way to add a custom tool prefix, even if the tool
itself had registered a lint:

 ```rust
 #![feature(register_tool)]
 #![register_tool(xyz)]
 #![warn(xyz::my_lint)]
 ```

```
$ rustc unknown-lint.rs  --crate-type lib
error[E0710]: an unknown tool name found in scoped lint: `xyz::my_lint`
 --> unknown-lint.rs:3:9
  |
3 | #![warn(xyz::my_lint)]
  |         ^^^
```

This allows opting-in to lints from other tools using `register_tool`.

cc https://github.com/rust-lang/rust/issues/66079#issuecomment-788589193, ``@chorman0773``
r? ``@petrochenkov``
2021-03-18 00:28:14 +01:00
Dylan DPC
7cd7dee315
Rollup merge of #83168 - Aaron1011:lint-procedural-masquerade, r=petrochenkov
Extend `proc_macro_back_compat` lint to `procedural-masquerade`

We now lint on *any* use of `procedural-masquerade` crate. While this
crate still exists, its main reverse dependency (`cssparser`) no longer
depends on it. Any crates still depending off should stop doing so, as
it only exists to support very old Rust versions.

If a crate actually needs to support old versions of rustc via
`procedural-masquerade`, then they'll just need to accept the warning
until we remove it entirely (at the same time as the back-compat hack).
The latest version of `procedural-masquerade` does work with the
latest rustc, but trying to check for the version seems like more
trouble than it's worth.

While working on this, I realized that the `proc-macro-hack` check was
never actually doing anything. The corresponding enum variant in
`proc-macro-hack` is named `Value` or `Nested` - it has never been
called `Input`. Due to a strange Crater issue, the Crater run that
tested adding this did *not* end up testing it - some of the crates that
would have failed did not actually have their tests checked, making it
seem as though the `proc-macro-hack` check was working.

The Crater issue is being discussed at
https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Nearly.20identical.20Crater.20runs.20processed.20a.20crate.20differently/near/230406661

Despite the `proc-macro-hack` check not actually doing anything, we
haven't gotten any reports from users about their build being broken.
I went ahead and removed it entirely, since it's clear that no one is
being affected by the `proc-macro-hack` regression in practice.
2021-03-18 00:28:10 +01:00
Dylan DPC
b688b694d0
Rollup merge of #83080 - tmiasko:inline-coverage, r=wesleywiser
Make source-based code coverage compatible with MIR inlining

When codegenning code coverage use the instance that coverage data was
originally generated for, to ensure basic level of compatibility with
MIR inlining.

Fixes #83061
2021-03-18 00:28:09 +01:00
Dylan DPC
16f6583f2d
Rollup merge of #82270 - asquared31415:asm-syntax-directive-errors, r=nagisa
Emit error when trying to use assembler syntax directives in `asm!`

The `.intel_syntax` and `.att_syntax` assembler directives should not be used, in favor of not specifying a syntax for intel, and in favor of the explicit `att_syntax` option using the inline assembly options.

Closes #79869
2021-03-18 00:28:06 +01:00
Vadim Petrochenkov
dac96d45af Fix use of bare trait objects everywhere 2021-03-18 02:18:58 +03:00
bors
b4adc21c4f Auto merge of #83188 - petrochenkov:field, r=lcnr
ast/hir: Rename field-related structures

I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.

- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")

Various visiting and other methods working with the fields are renamed correspondingly too.

The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-17 16:49:46 +00:00
Camille GILLOT
fcd6f20700 Iterate for super_predicates. 2021-03-17 17:30:50 +01:00
Justin Restivo
9a3e23fed2 riscvgc-unknown-none-elf use lp64d ABI 2021-03-17 10:45:58 -04:00
Joshua Nelson
620ecc01a2 Move some test-only code to test files
This also relaxes the bounds on some structs and moves them to the impl
block instead.
2021-03-17 10:31:30 -04:00
bors
04ae50179a Auto merge of #83090 - jackh726:bound_var_replacer_option, r=varkor
Make functions passed to BoundVarReplacer be optional

This means we can reuse the bound vars when we don't care to change them
2021-03-17 14:01:48 +00:00
Joshua Nelson
bb7c04ae9c Remove unnecessary forward_inner_docs hack
and replace it with `extended_key_value_attributes` feature.
2021-03-17 09:52:45 -04:00
bors
2c7490379d Auto merge of #83225 - JohnTitor:rollup-4hnuhb8, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #82774 (Fix bad diagnostics for anon params with ref and/or qualified paths)
 - #82826 ((std::net::parser): Fix capitalization of IP version names)
 - #83092 (More precise spans for HIR paths)
 - #83124 (Do not insert impl_trait_in_bindings opaque definitions twice.)
 - #83202 (Show details in cfg version unstable book)
 - #83203 (Don't warn about old rustdoc lint names (temporarily))
 - #83206 (Update books)
 - #83219 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-03-17 08:27:16 +00:00
Yuki Okushi
42e6d429c6
Rollup merge of #83203 - jyn514:rustdoc-warnings, r=Manishearth
Don't warn about old rustdoc lint names (temporarily)

Since https://github.com/rust-lang/rust/pull/80527, rustdoc users have an unpleasant situation: they can either use the new tool lint names (`rustdoc::non_autolinks`) or they can use the old names (`non_autolinks`). If they use the tool lints, they get a hard error on stable compilers, because rustc rejects all tool names it doesn't recognize (https://github.com/rust-lang/rust/issues/66079#issuecomment-788589193). If they use the old name, they get a warning to rename the lint to the new name. The only way to compile without warnings is to add `#[allow(renamed_removed_lints)]`, which defeats the whole point of the change: we *want* people to switch to the new name.

To avoid people silencing the lint and never migrating to the tool lint, this avoids warning about the old name, while still allowing you to use the new name. Once the new `rustdoc` tool name makes it to the stable channel, we can change these lints to warn again.

This adds the new lint functions `register_alias` and `register_ignored` - I didn't see an existing way to do this.

r? `@Manishearth` cc `@rust-lang/rustdoc`
2021-03-17 15:20:58 +09:00
Yuki Okushi
9c7aca58fc
Rollup merge of #83124 - cjgillot:iiib, r=petrochenkov
Do not insert impl_trait_in_bindings opaque definitions twice.

The reference to the item already appears inside the `OpaqueDef`. It does not need to be repeated as a statement.
2021-03-17 15:20:55 +09:00
Yuki Okushi
70edab895d
Rollup merge of #83092 - petrochenkov:qspan, r=estebank
More precise spans for HIR paths

`Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path.
This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span.

This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans).
r? ````@estebank````
2021-03-17 15:20:54 +09:00
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
bors
0c341226ad Auto merge of #83084 - nagisa:nagisa/features-native, r=petrochenkov
Adjust `-Ctarget-cpu=native` handling in cg_llvm

When cg_llvm encounters the `-Ctarget-cpu=native` it computes an
explciit set of features that applies to the target in order to
correctly compile code for the host CPU (because e.g. `skylake` alone is
not sufficient to tell if some of the instructions are available or
not).

However there were a couple of issues with how we did this. Firstly, the
order in which features were overriden wasn't quite right – conceptually
you'd expect `-Ctarget-cpu=native` option to override the features that
are implicitly set by the target definition. However due to how other
`-Ctarget-cpu` values are handled we must adopt the following order
of priority:

* Features from -Ctarget-cpu=*; are overriden by
* Features implied by --target; are overriden by
* Features from -Ctarget-feature; are overriden by
* function specific features.

Another problem was in that the function level `target-features`
attribute would overwrite the entire set of the globally enabled
features, rather than just the features the
`#[target_feature(enable/disable)]` specified. With something like
`-Ctarget-cpu=native` we'd end up in a situation wherein a function
without `#[target_feature(enable)]` annotation would have a broader
set of features compared to a function with one such attribute. This
turned out to be a cause of heavy run-time regressions in some code
using these function-level attributes in conjunction with
`-Ctarget-cpu=native`, for example.

With this PR rustc is more careful about specifying the entire set of
features for functions that use `#[target_feature(enable/disable)]` or
`#[instruction_set]` attributes.

Sadly testing the original reproducer for this behaviour is quite
impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in
particular on developer or CI machines.

cc https://github.com/rust-lang/rust/issues/83027 `@BurntSushi`
2021-03-17 05:46:08 +00:00
Erik Desjardins
bca761dc5d move to separate pass, cache layouts 2021-03-16 21:34:31 -04:00
Ivan Tham
21c157442c Add pub as optional check_front_matter
async-pub check created a regression for default
2021-03-17 09:04:08 +08:00
Ivan Tham
9321efd8f7 Detect pub fn attr wrong order like async pub
Redirects `const? async? unsafe? pub` to `pub const? async? unsafe?`.

Fix #76437
2021-03-17 09:02:19 +08: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
Joshua Nelson
e3031fe22a Allow registering tool lints with register_tool
Previously, there was no way to add a custom tool prefix, even if the tool
itself had registered a lint:

 ```
 #![feature(register_tool)]
 #![register_tool(xyz)]
 #![warn(xyz::my_lint)]
 ```

```
$ rustc unknown-lint.rs  --crate-type lib
error[E0710]: an unknown tool name found in scoped lint: `xyz::my_lint`
 --> unknown-lint.rs:3:9
  |
3 | #![warn(xyz::my_lint)]
  |         ^^^
```

This allows opting-in to lints from other tools using `register_tool`.
2021-03-16 17:33:03 -04:00
Augie Fackler
dcdb9ad3d2 llvm-wrapper: pass std::string instead of StringRef
LLVM change 5fbd1a333aa1a0b70903d036b98ea56c51ae5224 modified this
function to want std::string instead of StringRef, which is easily done.
2021-03-16 17:13:20 -04:00
Augie Fackler
0ed1c33ad9 llvm-wrapper: add alignment argument to CreateAtomicCmpXchg
As far as I can tell what we've been getting is llvm::MaybeAlign(), so
just use that for now. This is required sometime after
24539f1ef2471d07bd87f833cb0288fc0f251f4b.
2021-03-16 17:13:13 -04:00
Augie Fackler
af95484778 llvm-wrapper: adapt to function signature change of thinLTOResolvePrevailingInIndex
This changed in 54fb3ca96e261f7107cb1b5778c34cb0e0808be6 - I'm not
entirely sure it's correct that we're leaving config empty, but the one
case in LLVM that looked similar did that.
2021-03-16 16:45:21 -04:00
Simonas Kazlauskas
72fb4379d5 Adjust -Ctarget-cpu=native handling in cg_llvm
When cg_llvm encounters the `-Ctarget-cpu=native` it computes an
explciit set of features that applies to the target in order to
correctly compile code for the host CPU (because e.g. `skylake` alone is
not sufficient to tell if some of the instructions are available or
not).

However there were a couple of issues with how we did this. Firstly, the
order in which features were overriden wasn't quite right – conceptually
you'd expect `-Ctarget-cpu=native` option to override the features that
are implicitly set by the target definition. However due to how other
`-Ctarget-cpu` values are handled we must adopt the following order
of priority:

* Features from -Ctarget-cpu=*; are overriden by
* Features implied by --target; are overriden by
* Features from -Ctarget-feature; are overriden by
* function specific features.

Another problem was in that the function level `target-features`
attribute would overwrite the entire set of the globally enabled
features, rather than just the features the
`#[target_feature(enable/disable)]` specified. With something like
`-Ctarget-cpu=native` we'd end up in a situation wherein a function
without `#[target_feature(enable)]` annotation would have a broader
set of features compared to a function with one such attribute. This
turned out to be a cause of heavy run-time regressions in some code
using these function-level attributes in conjunction with
`-Ctarget-cpu=native`, for example.

With this PR rustc is more careful about specifying the entire set of
features for functions that use `#[target_feature(enable/disable)]` or
`#[instruction_set]` attributes.

Sadly testing the original reproducer for this behaviour is quite
impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in
particular on developer or CI machines.
2021-03-16 21:32:55 +02: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
Camille GILLOT
c74a3553ae Filter generics. 2021-03-16 20:07:26 +01:00
Camille GILLOT
4223db76b9 Iterate on inferred_outlives. 2021-03-16 20:07:26 +01:00
Camille GILLOT
58bca6f658 Iterate on explicit_predicates. 2021-03-16 20:07:26 +01:00
Camille GILLOT
dda31b97c8 Iterate on generics_of. 2021-03-16 20:07:25 +01:00
Camille GILLOT
6337594e3c Iterate on variances_of. 2021-03-16 20:07:25 +01: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
Joshua Nelson
c1b99f0b90 Don't warn about old rustdoc lint names (temporarily)
Right now, rustdoc users have an unpleasant situation: they can either
use the new tool lint names (`rustdoc::non_autolinks`) or they can use
the old names (`non_autolinks`). If they use the tool lints, they get a
hard error on stable compilers, because rustc rejects all tool names it
doesn't recognize. If they use the old name, they get a warning to
rename the lint to the new name. The only way to compile without
warnings is to add `#[allow(renamed_removed_lints)]`, which defeats the
whole point of the change: we *want* people to switch to the new name.

To avoid people silencing the lint and never migrating to the tool lint,
this avoids warning about the old name, while still allowing you to use
the new name. Once the new `rustdoc` tool name makes it to the stable
channel, we can change these lints to warn again.

This adds the new lint functions `register_alias` and `register_ignored`
- I didn't see an existing way to do this.
2021-03-16 13:13:59 -04: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
Vadim Petrochenkov
d1522b39dd ast: Reduce size of ExprKind by boxing fields of ExprKind::Struct 2021-03-16 11:41:24 +03:00
Vadim Petrochenkov
b25d3ba781 ast/hir: Rename field-related structures
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03: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
Erik Desjardins
899836306f remove assignments to ZST places 2021-03-15 21:57:52 -04: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
Erik Desjardins
affb081fa0 revert changes from #83118 to mark zst return place as unused 2021-03-15 20:18:03 -04: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
Jack Huey
ba27cae728 Make functions passed to BoundVarReplacer be optional 2021-03-15 19:00:37 -04:00
Tomasz Miąsko
5a9538acb5 Functions inlined into reachable functions are reachable
Consider functions to be reachable for code coverage purposes, either
when they reach the code generation directly, or indirectly as inlined
part of another function.
2021-03-15 23:26:03 +01:00
Tomasz Miąsko
1796cc0e6c Make source-based code coverage compatible with MIR inlining
When codegenning code coverage use the instance that coverage data was
originally generated for, to ensure basic level of compatibility with
MIR inlining.
2021-03-15 23:26:03 +01:00
Aaron Hill
d6a7c1d47f
Extend proc_macro_back_compat lint to procedural-masquerade
We now lint on *any* use of `procedural-masquerade` crate. While this
crate still exists, its main reverse dependency (`cssparser`) no longer
depends on it. Any crates still depending off should stop doing so, as
it only exists to support very old Rust versions.

If a crate actually needs to support old versions of rustc via
`procedural-masquerade`, then they'll just need to accept the warning
until we remove it entirely (at the same time as the back-compat hack).
The latest version of `procedural-masquerade` does not work with the
latest rustc, but trying to check for the version seems like more
trouble than it's worth.

While working on this, I realized that the `proc-macro-hack` check was
never actually doing anything. The corresponding enum variant in
`proc-macro-hack` is named `Value` or `Nested` - it has never been
called `Input`. Due to a strange Crater issue, the Crater run that
tested adding this did *not* end up testing it - some of the crates that
would have failed did not actually have their tests checked, making it
seem as though the `proc-macro-hack` check was working.

The Crater issue is being discussed at
https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Nearly.20identical.20Crater.20runs.20processed.20a.20crate.20differently/near/230406661

Despite the `proc-macro-hack` check not actually doing anything, we
haven't gotten any reports from users about their build being broken.
I went ahead and removed it entirely, since it's clear that no one is
being affected by the `proc-macro-hack` regression in practice.
2021-03-15 16:00:49 -04:00
Vadim Petrochenkov
7e66e9d6b0 More precise spans for HIR paths 2021-03-15 22:13:45 +03: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
Camelid
8f40e1180f Use pretty-printer instead of span_to_snippet 2021-03-14 14:39:25 -07:00
bors
d6eaea1c88 Auto merge of #83062 - JohnTitor:improve-reassign-err, r=davidtwco
Improve the wording for the `can't reassign` error

Follow-up for https://github.com/rust-lang/rust/pull/71976#discussion_r448186151.
Fixes #66736
2021-03-14 21:10:50 +00:00
Roxane
b6cf070eb4 Attempt to deal with nested closures properly 2021-03-14 17:07:59 -04:00
Roxane
d4f8729c89 Delay use of Place in favor of PlaceBuilder 2021-03-14 17:07:58 -04:00
Camelid
13076f90d2 Tweak diagnostics
- Tweak lint message
- Display multi-segment paths correctly
2021-03-14 14:00:02 -07:00
Camille GILLOT
e8b2e7b01c Assert there is no duplicate node. 2021-03-14 21:47:42 +01:00
Roxane
ec10b71d42 Introduce new fake reads 2021-03-14 16:31:26 -04:00
Camille GILLOT
17d3308d3f Remove dead code. 2021-03-14 21:28:39 +01:00
Camille GILLOT
3612953487 Do not insert impl_trait_in_bindings opaque definitions twice. 2021-03-14 20:26:19 +01:00
bors
bb4cdf8ec0 Auto merge of #82399 - petrochenkov:modin2, r=Aaron1011
expand: Resolve and expand inner attributes on out-of-line modules

Fixes https://github.com/rust-lang/rust/issues/81661
r? `@Aaron1011`
2021-03-14 17:36:06 +00:00
Vadim Petrochenkov
a4cc3cae04 expand: Resolve and expand inner attributes on out-of-line modules 2021-03-14 18:10:29 +03:00
bors
9320b121b5 Auto merge of #83082 - cjgillot:defkey-ii, r=oli-obk
Iterate on crate_inherent_impls for metadata.

Split from #80347

r? `@oli-obk`
2021-03-14 14:16:21 +00:00
Ömer Sinan Ağacan
14038c7df2 Remove duplicate asserts, replace eq assert with assert_eq 2021-03-14 17:06:18 +03:00
Ömer Sinan Ağacan
6ddd840f36 Minor refactoring in try_index_step
Merges `if-let` and `if x.is_some() { ... }` blocks
2021-03-14 16:00:07 +03:00
bors
84c08f82b4 Auto merge of #83044 - kubo39:set-llvm-code-model, r=nikic
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on https://github.com/rust-lang/rust/pull/74002
2021-03-14 11:46:57 +00:00
Joshua Nelson
e161a2fd73 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-14 01:37:13 -05:00
Yuki Okushi
33614023a1
Rollup merge of #82798 - jyn514:rustdoc-group, r=Manishearth,GuillaumeGomez
Rename `rustdoc` to `rustdoc::all`

When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like

```
warning: unknown lint: `rustdoc`
```

The lint group still worked when rustdoc ran, since rustdoc added the group itself.

This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints.

Follow-up to #80527.
r? ``@Manishearth``
2021-03-14 13:07:32 +09:00
Yuki Okushi
0d9a6edb50
Rollup merge of #82789 - csmoe:issue-82772, r=estebank
Get with field index from pattern slice instead of directly indexing

Closes #82772
r? ``@estebank``

https://github.com/rust-lang/rust/pull/82789#issuecomment-796921977
> ``@estebank`` So the real cause is we only generate single pattern for Box here
615b03aeaa/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs (L1130-L1132)
But in the replacing function, it tries to index on the 1-length pattern slice with field 1, thus out of bounds.
615b03aeaa/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs (L1346)
2021-03-14 13:07:31 +09:00
Yuki Okushi
f0ebc10410
Rollup merge of #82617 - camelid:everybody_loops-docs, r=jyn514
Document `everybody_loops`

cc `@jyn514`
2021-03-14 13:07:30 +09:00
Camelid
5134047c40 Add hyphen to "crate level"
"crate level attribute" -> "crate-level attribute"
2021-03-13 16:29:49 -08:00
Simon Vandel Sillesen
35566bfd7d Do not emit alloca for ZST local even if it is uninitialized 2021-03-13 18:01:14 -05:00
Simon Vandel Sillesen
bb36e3c7e7 Move ZST check inside UsedLocals 2021-03-13 18:00:28 -05:00
Simon Vandel Sillesen
4e901be57d Extend SimplifyLocals to remove ZST writes 2021-03-13 17:58:11 -05:00
Camelid
7e972a39b8 Report error for each invalid nested attribute 2021-03-13 13:55:15 -08:00
Camelid
8164a74eef Document everybody_loops 2021-03-13 13:52:48 -08:00
Camelid
7189c05bf8 Lint non-meta doc attributes
E.g., `#[doc(123)]`.
2021-03-13 13:25:27 -08:00
Camelid
9613a88db5 Refactor check_doc_attrs body
This change makes it easier to follow the control flow.

I also moved the end-of-line comments attached to some symbols to before
the symbol listing. This allows rustfmt to format the code; otherwise no
formatting occurs (see rust-lang/rustfmt#4750).
2021-03-13 13:13:27 -08:00
Amanieu d'Antras
fa3694fada Always lower asm! to valid HIR 2021-03-13 20:49:32 +00:00
bors
acca818928 Auto merge of #83064 - cjgillot:fhash, r=jackh726
Tweaks to stable hashing
2021-03-13 20:21:40 +00:00
Aaron Hill
06546d4b40
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-13 13:45:12 -05:00
bors
e7e1dc158c Auto merge of #83007 - Aaron1011:incr-verify-default, r=Mark-Simulacrum
Turn `-Z incremental-verify-ich` on by default

Issue #82920 showed that the kind of bugs caught by this flag have
soundness implications.
2021-03-13 17:52:22 +00:00
Aaron Hill
7d7c81a114
Always run incremental_verify_ich when re-computing query results
Issue #82920 showed that the kind of bugs caught by this flag have
soundness implications.

This causes performance regressions of up to 15.2% during incremental
compilation, but this is necessary to catch miscompilations caused by
bugs in query implementations.
2021-03-13 12:00:38 -05:00
bors
56f74c52c1 Auto merge of #83069 - tgnottingham:simplify-query-cache-iter, r=cjgillot
rustc_query_system: simplify QueryCache::iter

Minor cleanup to reduce a small amount of complexity and code bloat.
Reduces the number of mono items in rustc_query_impl by 15%.
2021-03-13 15:11:25 +00:00
Camille GILLOT
ab1782975a Iterate on crate_inherent_impls for metadata. 2021-03-13 14:17:55 +01:00
bors
32dce353de Auto merge of #82891 - cjgillot:monoparent, r=petrochenkov
Make def_key and HIR parenting consistent.

r? `@petrochenkov`
2021-03-13 12:28:04 +00:00
bors
178bd9130e Auto merge of #82878 - sexxi-goose:repr_packed, r=nikomatsakis
2229: Handle capturing a reference into a repr packed struct

RFC 1240 states that it is unsafe to capture references into a
packed-struct. This PR ensures that when a closure captures a precise
path, we aren't violating this safety constraint.

To acheive so we restrict the capture precision to the struct itself.

An interesting edge case where we decided to restrict precision:
```rust
struct Foo(String);

let foo: Foo;
let c = || {
    println!("{}", foo.0);
    let x = foo.0;
}
```

Given how closures get desugared today, foo.0 will be moved into the
closure, making the `println!`, safe. However this can be very subtle
and also will be unsafe if the closure gets inline.

Closes: https://github.com/rust-lang/project-rfc-2229/issues/33

r? `@nikomatsakis`
2021-03-13 09:47:07 +00:00
bors
f42888c15f Auto merge of #82436 - osa1:issue80258, r=nikomatsakis
Allow calling *const methods on *mut values

This allows `*const` methods to be called on `*mut` values.

TODOs:

- [x] ~~Remove debug logs~~ Done.
- [x] ~~I haven't tested, but I think this currently won't work when the `self` value has type like `&&&&& *mut X` because I don't do any autoderefs when probing. To fix this the new code in `rustc_typeck::check::method::probe` needs to reuse `pick_method` somehow as I think that's the function that autoderefs.~~ This works, because autoderefs are done before calling `pick_core`, in `method_autoderef_steps`, called by `probe_op`.
- [x] ~~I should probably move the new `Pick` to `pick_autorefd_method`. If not, I should move it to its own function.~~ Done.
- [ ] ~~Test this with a `Pick` with `to_ptr = true` and `unsize = true`.~~ I think this case cannot happen, because we don't have any array methods with `*mut [X]` receiver. I should confirm that this is true and document this. I've placed two assertions about this.
- [x] ~~Maybe give `(Mutability, bool)` a name and fields~~ I now have a `to_const_ptr` field in `Pick`.
- [x] ~~Changes in `adjust_self_ty` is quite hacky. The problem is we can't deref a pointer, and even if we don't have an adjustment to get the address of a value, so to go from `*mut` to `*const` we need a special case.~~ There's still a special case for `to_const_ptr`, but I'm not sure if we can avoid this.
- [ ] Figure out how `reached_raw_pointer` stuff is used. I suspect only for error messages.

Fixes #80258
2021-03-13 04:38:39 +00:00
Tyson Nottingham
adcbe49b16 rustc_query_system: simplify QueryCache::iter
Minor cleanup to reduce a small amount of complexity and code bloat.
Reduces the number of mono items in rustc_query_impl by 15%.
2021-03-12 17:34:14 -08:00
Yuki Okushi
fafbc91e0e
Rollup merge of #83037 - kubo39:merge-functions-in-llvm-new-pass-manager, r=nikic
Support merge_functions option in NewPM since LLVM >= 12

now we can pass this flag since https://reviews.llvm.org/D93002 has been merged.
2021-03-13 09:44:45 +09:00
Yuki Okushi
04e24ae67e
Rollup merge of #83020 - hi-rustin:rustin-patch-enum, r=lcnr
Emit the enum range assumption if the range only contains one element

close https://github.com/rust-lang/rust/issues/82871
2021-03-13 09:44:44 +09:00
Yuki Okushi
fa3f1865f6
Rollup merge of #82984 - camsteffen:lower-block, r=cjgillot
Simplify ast block lowering
2021-03-13 09:44:42 +09:00
Camille GILLOT
445b4e379c Make def_key and HIR parenting consistent. 2021-03-12 22:48:32 +01:00
Yuki Okushi
0466b6ac6d Improve the wording for the can't reassign error 2021-03-13 06:06:54 +09:00
Oli Scherer
11ddd22510 Run rustfmt 2021-03-12 13:46:39 +00:00
Oli Scherer
c51749af6e We won't support trait object constants in type level constants for the forseeable future 2021-03-12 13:00:16 +00:00
Oli Scherer
6ca1d87194 Visit mir::Constant::user_ty for completeness.
It's not necessary yet, but it may become necessary with things like lazy normalization.
2021-03-12 12:59:37 +00:00
Oli Scherer
20f737966e Replace a custom lift method with a Lift impl 2021-03-12 12:44:12 +00:00
Oli Scherer
3127a9c60f Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
Oli Scherer
3ecde6f5db Directly intern allocations so that we can write a Lift impl for them 2021-03-12 12:34:29 +00:00
Oli Scherer
914df2a493 Add ty helper function for mir constants
This is in preparation of the `literal` field becoming an enum that distinguishes between type level constants and runtime constants
2021-03-12 12:33:46 +00:00
Oli Scherer
d5eec653c0 Use the explicit error constant instead of fake dummies 2021-03-12 12:25:08 +00:00
Oli Scherer
0bb367e070 Split pretty printer logic for scalar int and scalar ptr
Value trees won't have scalar ptr at all, so we need a scalar int printing method anyway. This way we'll be able to share that method between all const representations.
2021-03-12 12:24:29 +00:00
Oli Scherer
b729cc9d61 Pull out ConstValue relating into its own function 2021-03-12 12:23:50 +00:00
Oli Scherer
5e8a89b2e5 Reduce the duplication in the relation logic for constants 2021-03-12 12:23:11 +00:00
Oli Scherer
4d917faa99 Reduce destructuring and re-interning where possible 2021-03-12 12:22:33 +00:00
Oli Scherer
019dba0ceb Resolve a FIXME around type equality checks in Relate for constants 2021-03-12 12:21:55 +00:00
Oli Scherer
09f7f91532 Add convenience conversion methods for ScalarInt 2021-03-12 12:20:54 +00:00
Oli Scherer
858216cabf Add fallible Scalar to ScalarInt conversion method 2021-03-12 12:20:14 +00:00
Oli Scherer
0fe4f38769 Intern valtree field vector 2021-03-12 12:19:17 +00:00
Oli Scherer
a4fbac163e Implement valtree
valtree is a version of constants that is inherently safe to be used within types.
This is in contrast to ty::Const which can have different representations of the same value. These representation differences can show up in hashing or equality comparisons, breaking type equality of otherwise equal types.
valtrees do not have this problem.
2021-03-12 12:16:14 +00:00
bors
338647db73 Auto merge of #82422 - petrochenkov:allunst, r=oli-obk
expand: Do not allocate `Lrc` for `allow_internal_unstable` list unless necessary

This allocation is done for any macro defined in the current crate, or used from a different crate.
EDIT: This also removes an `Lrc` increment from each *use* of such macro, which may be more significant.
Noticed when reviewing https://github.com/rust-lang/rust/pull/82367.
This probably doesn't matter, but let's do a perf run.
2021-03-12 11:46:50 +00:00
bors
0cc64a34e9 Auto merge of #82935 - henryboisdequin:diagnostic-cleanups, r=estebank
Diagnostic cleanups

Follow up to #81503
Helps with #82916 (don't show note if `span` is `DUMMY_SP`)
2021-03-12 09:05:38 +00:00
Ömer Sinan Ağacan
b24902ea18 Run analyses before thir-tree dumps
Fixes #83048
2021-03-12 10:08:44 +03:00
hi-rustin
d180f91824 Emit the enum range assumption if the range only contains one element
test: add test case

make tidy happy
2021-03-12 12:06:10 +08:00
Hiroki Noda
8357e57346 Add support for storing code model to LLVM module IR
This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on https://github.com/rust-lang/rust/pull/74002
2021-03-12 11:02:25 +09:00
Henry Boisdequin
26478c81fd Don't show note if span is DUMMY_SP 2021-03-12 06:18:33 +05:30
Yuki Okushi
14846d945d
Rollup merge of #83018 - oli-obk:float_check, r=davidtwco
Reintroduce accidentally deleted assertions.

These were removed in https://github.com/rust-lang/rust/pull/50198
2021-03-12 08:55:22 +09:00
Yuki Okushi
5ab8f53a71
Rollup merge of #83013 - hyd-dev:cfg-unix-windows, r=bjorn3
Adjust some `#[cfg]`s to take non-Unix non-Windows operating systems into account

This makes compilation to such targets (e.g. `wasm32-wasi`) easier.

cc rust-lang/miri#722 bb6d1d0a09 (r48100619)
2021-03-12 08:55:21 +09:00
Hiroki Noda
65ed23c282 Support merge_functions option in NewPM since LLVM >= 12
now we can pass this flag since https://reviews.llvm.org/D93002 has been
merged.
2021-03-12 08:16:10 +09:00
Guillaume Gomez
1d26e6b632 Improve code by removing similar function calls and using loops instead for collecting iterators 2021-03-11 22:33:40 +01:00
LeSeulArtichaut
6bf4147646 Add -Z unpretty flag for the THIR 2021-03-11 19:42:40 +01:00
LeSeulArtichaut
2a34428253 Make THIR data structures public 2021-03-11 19:42:39 +01:00
csmoe
77fb6a0f32 fix: check before index into generated patterns 2021-03-12 01:54:08 +08:00
csmoe
2fd2796aae add ui testcase for issue 82772 2021-03-12 01:53:55 +08:00
bors
61365c0625 Auto merge of #82495 - LeSeulArtichaut:eager-thir, r=oli-obk
Eagerly construct bodies of THIR

With this PR:
 - the THIR is no longer constructed lazily, but is entirely built before being passed to the MIR Builder
 - the THIR is now allocated in arenas instead of `Box`es

However, this PR doesn't make any changes to the way patterns are constructed: they are still boxed, and exhaustiveness checking is unchanged.

Implements MCP rust-lang/compiler-team#409.
Closes rust-lang/project-thir-unsafeck#1.
r? `@ghost` cc `@nikomatsakis` `@oli-obk`
2021-03-11 15:34:01 +00:00
Oli Scherer
c69b108d2a Reintroduce accidentally deleted assertions.
These were removed in https://github.com/rust-lang/rust/pull/50198
2021-03-11 14:56:03 +00:00
Camille GILLOT
34e92bbf65 Hash SyntaxContext first. 2021-03-11 12:31:31 +01:00
Camille GILLOT
fe2d728e62 Remove useless method. 2021-03-11 12:24:58 +01:00
Camille GILLOT
84bf599bac Add inlining. 2021-03-11 12:24:43 +01:00
hyd-dev
00c08727c8
Adjust some #[cfg]s to take non-Unix non-Windows operating systems into account 2021-03-11 18:03:32 +08:00
bors
04fce73196 Auto merge of #82641 - camelid:lang-item-docs, r=jyn514
Improve lang item generated docs

cc https://rust-lang.zulipchat.com/#narrow/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F/near/226738260

r? `@jyn514`
2021-03-11 06:38:22 +00:00
bors
b3ac52646f Auto merge of #82964 - Nicholas-Baron:shorten_middle_ty, r=jackh726
Shorten `rustc_middle::ty::mod`

Related to #60302.

This PR moves all `Adt*`, `Assoc*`, `Generic*`, and `UpVar*` types to separate files.
This, alongside some `use` reordering, puts `mod.rs` at ~2,200 lines, thus removing the `// ignore-tidy-filelength`.

The particular groups were chosen as they had 4 or more "substantive" members.
2021-03-11 04:09:44 +00:00
Josh Stone
f7e75a2124 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-10 17:53:35 -08:00
Tomasz Miąsko
1aee8083be Import small cold functions
The Rust code is often written under an assumption that for generic
methods inline attribute is mostly unnecessary, since for optimized
builds using ThinLTO, a method will be generated in at least one CGU and
available for import.

For example, deref implementations for Box, Vec, MutexGuard, and
MutexGuard are not currently marked as inline, neither is identity
implementation of From trait.

In PGO builds, when functions are determined to be cold, the default
multiplier of zero will stop the import, even for completely trivial
functions.

Increase slightly the default multiplier from 0 to 0.1 to import them
regardless.
2021-03-11 00:00:00 +00:00
Tomasz Miąsko
49431909a6 Validate rustc_layout_scalar_valid_range_{start,end} attributes 2021-03-11 00:00:00 +00:00
Tomasz Miąsko
1ba71abddd Inline Attribute::has_name 2021-03-11 16:04:14 +01:00
Nicholas-Baron
d022142ade Moved more of the capture related types into closure.rs 2021-03-10 14:32:14 -08:00
Nicholas-Baron
90cbb39d74 Moved more types into upvar.rs (now named closure.rs) 2021-03-10 14:32:14 -08:00
Nicholas-Baron
0ba5a6b6e5 Moved all Adt* types to adt.rs 2021-03-10 14:32:14 -08:00
Nicholas-Baron
ffcf7e8b6d Moved all Assoc* types to assoc.rs. 2021-03-10 14:32:13 -08:00
Nicholas-Baron
11e41b052f Moved types starting with 'Generic' into generics.rs. 2021-03-10 14:32:13 -08:00
Nicholas-Baron
5375575717 Moved UpVar* types to a separate file. 2021-03-10 14:32:13 -08:00
Nicholas-Baron
e4884c1d50 Grouped some ungrouped use and mod lines. 2021-03-10 14:32:13 -08:00