Commit Graph

9964 Commits

Author SHA1 Message Date
Vadim Petrochenkov
337ced2ef0 rustc_metadata: Merge get_ctor_def_id and get_ctor_kind
Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag
2021-12-22 11:05:54 +08:00
bors
8ad3c1dd1d Auto merge of #92149 - fee1-dead:cache-fix, r=oli-obk
Fix bad caching of `~const Drop` bounds

Fixes #92111.
2021-12-21 12:49:10 +00:00
bors
3d57c61a9e Auto merge of #92152 - matthiaskrgr:rollup-nmskpw6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90345 (Stabilise entry_insert)
 - #91412 (Improve suggestions for importing out-of-scope traits reexported as `_`)
 - #91770 (Suggest adding a `#[cfg(test)]` to to a test module)
 - #91823 (Make `PTR::as_ref` and similar methods `const`.)
 - #92127 (Move duplicates removal when generating results instead of when displaying them)
 - #92129 (JoinHandle docs: add missing 'the')
 - #92131 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-21 09:01:25 +00:00
Matthias Krüger
ee45a532f3
Rollup merge of #92131 - bjorn3:sync_cg_clif-2021-12-20, r=bjorn3
Sync rustc_codegen_cranelift

The main highlight this sync is improved support for inline assembly. Thanks `@nbdd0121!` Inline assembly is still disabled by default for builds in the main rust repo though. Cranelift will now also be built from the crates.io releases rather than the git repo. Git repos are incompatible with vendoring.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2021-12-21 08:33:43 +01:00
Matthias Krüger
790950a530
Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplett
Suggest adding a `#[cfg(test)]` to to a test module

closes #88138
2021-12-21 08:33:39 +01:00
bors
87e8639d8d Auto merge of #91903 - tmiasko:bit-set-hash, r=jackh726
Implement StableHash for BitSet and BitMatrix via Hash

This fixes an issue where bit sets / bit matrices the same word
content but a different domain size would receive the same hash.
2021-12-21 05:42:10 +00:00
Deadbeef
aaaad5b46b
Fix bad caching of ~const Drop bounds 2021-12-21 13:25:43 +08:00
Michael Goulet
f83508592b Suggest glob-import if we need to import a trait, but it has no visible name 2021-12-20 19:50:15 -08:00
Michael Goulet
c327627a68 Bail if printing item named _ in try_print_visible_def_path 2021-12-20 19:50:15 -08:00
Michael Goulet
1f2cf1e9b7 Prefer visibility paths where items are not named _ 2021-12-20 19:50:15 -08:00
bjorn3
3426a730ff Merge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_clif-2021-12-20 2021-12-20 18:56:35 +01:00
bors
84f962a89b Auto merge of #91924 - Aaron1011:serialize-adt-def, r=michaelwoerister
Fully serialize AdtDef

This avoids needing to invoke the `adt_def` query during
the decoding of another query's result.

Split out from https://github.com/rust-lang/rust/pull/91919
See https://github.com/rust-lang/rust/issues/91696#issuecomment-993043710
2021-12-20 10:35:48 +00:00
bors
60f3bd78ee Auto merge of #92041 - Aaron1011:remove-speculative-evaluation, r=jackh726
Remove 'speculative evaluation' of predicates

Performing 'speculative evaluation' introduces caching bugs that
cannot be fixed without invasive changes to projection.

Hopefully, we can win back most of the performance lost by
re-adding 'cache completion'

Fixes #90662
2021-12-20 07:30:16 +00:00
Nicholas Nethercote
f09b1facd0 Eliminate ObligationCauseData.
This makes `Obligation` two words bigger, but avoids allocating a lot of
the time.

I previously tried this in #73983 and it didn't help much, but local
timings look more promising now.
2021-12-20 09:29:20 +11:00
Matthias Krüger
9415c67ae5
Rollup merge of #92029 - nikic:section-flags-fix, r=davidtwco
Explicitly set no ELF flags for .rustc section

For a data section, the object crate will set the SHF_ALLOC by default, which is exactly what we don't want. Explicitly set sh_flags to zero to avoid this.

I checked with `objdump -h` that this produces the right flags for ELF.

Fixes #92013.
2021-12-19 17:38:35 +01:00
Matthias Krüger
fba0d04d30
Rollup merge of #91895 - pitaj:91867-monomorphize, r=Aaron1011
Remove `in_band_lifetimes` for `rustc_monomorphize`

#91867
2021-12-19 17:38:34 +01:00
Matthias Krüger
d576f7d42d
Rollup merge of #91878 - LegionMammal978:less-inband-infer, r=Aaron1011
Remove `in_band_lifetimes` from `rustc_infer`

See #91867 for more information.

This crate actually had a typo `'ctx` in one of its functions:
```diff
-pub fn same_type_modulo_infer(a: Ty<'tcx>, b: Ty<'ctx>) -> bool {
+pub fn same_type_modulo_infer<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
```
Also, I wasn't entirely sure about the lifetimes in `suggest_new_region_bound`:
```diff
 pub fn suggest_new_region_bound(
-    tcx: TyCtxt<'tcx>,
+    tcx: TyCtxt<'_>,
     err: &mut DiagnosticBuilder<'_>,
     fn_returns: Vec<&rustc_hir::Ty<'_>>,
```
Should all of those lifetimes really be distinct?
2021-12-19 17:38:33 +01:00
Matthias Krüger
c088e5092b
Rollup merge of #91791 - terrarier2111:fix-float-ice, r=nagisa
Fix an ICE when lowering a float with missing exponent magnitude

This fixes: https://github.com/rust-lang/rust/issues/91434
2021-12-19 17:38:33 +01:00
bors
41c3017c82 Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts")
 - #91984 (Remove `in_band_lifetimes` from `rustc_middle`)
 - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets)
 - #92042 (Enable `#[thread_local]` for all windows-msvc targets)
 - #92071 (Update example code for Vec::splice to change the length)
 - #92077 (rustdoc: Remove unused `collapsed` field)
 - #92081 (rustdoc: Remove unnecessary `need_backline` function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-19 12:36:56 +00:00
threadexception
0003280b9b Fix an ICE when lowering a float with missing exponent magnitude
Co-authored-by: Simonas Kazlauskas <github@kazlauskas.me>
2021-12-19 11:52:33 +01:00
Matthias Krüger
4dbe966fdd
Rollup merge of #92042 - ChrisDenton:msvc-static-tls, r=nagisa
Enable `#[thread_local]` for all windows-msvc targets

As it stands, `#[thread_local]` is enabled haphazardly for msvc. It seems all 64-bit targets have it enabled, but not 32-bit targets unless they're also UWP targets (perhaps because UWP was added more recently?). So this PR simply enables it for 32-bit targets as well. I can't think of a reason not to and I've confirmed by running tests locally which pass.

See also #91659
2021-12-19 10:45:53 +01:00
Matthias Krüger
4d5ffc4870
Rollup merge of #91984 - Aaron1011:rustc-middle-lifetime, r=oli-obk
Remove `in_band_lifetimes` from `rustc_middle`

See #91867

This was mostly straightforward. In several places, I take advantage
of the fact that lifetimes are non-hygenic: a macro declares the
'tcx' lifetime, which is then used in types passed in as macro
arguments.
2021-12-19 10:45:51 +01:00
bors
a41a6925ba Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`
2021-12-19 09:31:37 +00:00
bors
d6cffe41b5 Auto merge of #89831 - Aaron1011:project-caching-speedup, r=jackh726
Re-introduce concept of projection cache 'completion'

Instead of clearing out the cache entirely, we store
the intermediate evaluation result into the cache entry.
This accomplishes several things:

* We avoid the performance hit associated with re-evaluating
  the sub-obligations
* We avoid causing issues with incremental compilation, since
  the final evaluation result is always the same
* We avoid affecting other uses of the same `InferCtxt` which
  might care about 'side effects' from processing the sub-obligations
  (e,g. region constraints). Only code that is specifically aware
   of the new 'complete' code is affected
2021-12-19 03:33:19 +00:00
bors
df2f45c1d3 Auto merge of #92090 - matthiaskrgr:rollup-pbyqddi, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91834 (Update browser-ui-test version and improve rustdoc-gui tests readability)
 - #91894 (Remove `in_band_lifetimes` from `rustc_incremental`)
 - #91932 (Add user seed to `-Z randomize-layout`)
 - #91956 (fix(rustc_lint): better detect when parens are necessary)
 - #92020 (Remove P: Unpin bound on impl Stream for Pin)
 - #92063 (docs: fix typo)
 - #92082 (rustdoc: Write doc-comments directly instead of using FromIterator)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-19 00:24:56 +00:00
Aaron Hill
40ef1d3223
Re-introduce concept of projection cache 'completion'
Instead of clearing out the cache entirely, we store
the intermediate evaluation result into the cache entry.
This accomplishes several things:

* We avoid the performance hit associated with re-evaluating
  the sub-obligations
* We avoid causing issues with incremental compilation, since
  the final evaluation result is always the same
* We avoid affecting other uses of the same `InferCtxt` which
  might care about 'side effects' from processing the sub-obligations
  (e,g. region constraints). Only code that is specifically aware
   of the new 'complete' code is affected
2021-12-18 19:07:14 -05:00
Matthias Krüger
48915315d2
Rollup merge of #91956 - notriddle:notriddle/unused-parens-range, r=nagisa
fix(rustc_lint): better detect when parens are necessary

Fixes #90807
2021-12-19 00:38:41 +01:00
Matthias Krüger
6b62bf3814
Rollup merge of #91932 - Kixiron:randomize-seed, r=nagisa
Add user seed to `-Z randomize-layout`

Allows users of -`Z randomize-layout` to provide `-Z layout-seed=<seed>` in order to further randomizing type layout randomization. Extension of [compiler-team/#457](https://github.com/rust-lang/compiler-team/issues/457), allows users to change struct layouts without changing code and hoping that item path hashes change, aiding in detecting layout errors
2021-12-19 00:38:41 +01:00
Matthias Krüger
80390871af
Rollup merge of #91894 - pitaj:91867-incremental, r=Aaron1011
Remove `in_band_lifetimes` from `rustc_incremental`

#91867
2021-12-19 00:38:40 +01:00
bors
daf2204aa4 Auto merge of #91837 - Kobzol:stable-hash-map-avoid-sort, r=the8472
Avoid sorting in hash map stable hashing

Suggested by `@the8472` [here](https://github.com/rust-lang/rust/pull/89404#issuecomment-991813333). I hope that I understood it right, I replaced the sort with modular multiplication, which should be commutative.

Can I ask for a perf. run? However, locally it didn't help at all. Creating the `StableHasher` all over again is probably slowing it down quite a lot. And using `FxHasher` is not straightforward, because the keys and values only implement `HashStable` (and probably they shouldn't be just hashed via `Hash` anyway for it to actually be stable).

Maybe the `StableHash` interface could be changed somehow to better suppor these scenarios where the hasher is short-lived. Or the `StableHasher` implementation could have variants with e.g. a shorter buffer for these scenarios.
2021-12-18 21:23:37 +00:00
bors
91a0600a5c Auto merge of #92065 - matthiaskrgr:rollup-qmpcsuj, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91566 (Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF)
 - #91926 (Remove `in_band_lifetimes` from `rustc_metadata`)
 - #91931 (Remove `in_band_lifetimes` from `rustc_codegen_llvm`)
 - #92024 (rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.)
 - #92037 (Use a const ParamEnv when in default_method_body_is_const)
 - #92047 (Set `RUST_BACKTRACE=0` when running location-detail tests)
 - #92050 (Add a space and 2 grave accents )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-18 18:08:51 +00:00
Nikita Popov
79d5309604 Explicitly set no ELF flags for .rustc section
For a data section, the object crate will set the SHF_ALLOC by
default, which is exactly what we don't want. Explicitly set
sh_flags to zero to avoid this.
2021-12-18 18:44:03 +01:00
bors
d3848cb659 Auto merge of #92064 - matthiaskrgr:rollup-tgj2pai, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91858 (pass -Wl,-z,origin to set DF_ORIGIN when using rpath)
 - #91923 (Remove `in_band_lifetimes` from `rustc_query_impl`)
 - #91925 (Remove `in_band_lifetimes` from `rustc_privacy`)
 - #91977 (Clean up search code and unify function returned values)
 - #92018 (Fix typo in "new region bound" suggestion)
 - #92022 (Eliminate duplicate codes of expected_found_bool)
 - #92032 (hir: Do not introduce dummy type names for `extern` blocks in def paths)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-18 15:01:32 +00:00
Matthias Krüger
cc043aa75f
Rollup merge of #92037 - fee1-dead:fix_env_dmbic, r=oli-obk
Use a const ParamEnv when in default_method_body_is_const

r? `@oli-obk`

This PR fixes the param_env function to return `constness: Const` correctly for trait methods marked with `#[default_method_body_is_const]`. The snippet below is erroneously accepted by the compiler and has been fixed by this change. ([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=12dc6681b2eeee5f604203d96259eeb4))

```rust
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]

trait Tr {}
impl Tr for () {}

const fn foo<T>() where T: ~const Tr {}

pub trait Foo {
    #[default_method_body_is_const]
    fn foo() {
        foo::<()>();
    }
}
```
2021-12-18 14:49:42 +01:00
Matthias Krüger
53a95ea289
Rollup merge of #92024 - pcwalton:per-codegen-unit-names, r=davidtwco
rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.

To avoid breaking split DWARF, we need to ensure that each codegen unit has a
unique `DW_AT_name`. This is because there's a remote chance that different
codegen units for the same module will have entirely identical DWARF entries
for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf
Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified
in section 7.32 "Type Signature Computation" to compute the DWO ID, which does
not include any fields that would distinguish compilation units. So we must
embed the codegen unit name into the `DW_AT_name`.

Closes #88521.
2021-12-18 14:49:41 +01:00
Matthias Krüger
ca3d129ee3
Rollup merge of #91931 - LegionMammal978:less-inband-codegen_llvm, r=davidtwco
Remove `in_band_lifetimes` from `rustc_codegen_llvm`

See #91867 for more information.

This one took a while. This crate has dozens of functions not associated with any type, and most of them were using in-band lifetimes for `'ll` and `'tcx`.
2021-12-18 14:49:40 +01:00
Matthias Krüger
9e720a8aae
Rollup merge of #91926 - SylvanB:remove_in_band_lifetimes_from_rustc_metadata, r=nagisa
Remove `in_band_lifetimes` from `rustc_metadata`

Another for #91867
2021-12-18 14:49:39 +01:00
Matthias Krüger
1c42199c8f
Rollup merge of #91566 - cbeuw:remap-dwo-name, r=davidtwco
Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF

`--remap-path-prefix` doesn't apply to paths to `.o` (in case of packed) or `.dwo` (in case of unpacked) files in `DW_AT_GNU_dwo_name`. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888
2021-12-18 14:49:38 +01:00
Matthias Krüger
5e8f934149
Rollup merge of #92032 - petrochenkov:extblockpath, r=oli-obk
hir: Do not introduce dummy type names for `extern` blocks in def paths

Use a separate nameless `DefPathData` variant instead.

Extracted from https://github.com/rust-lang/rust/pull/91795.
2021-12-18 11:28:07 +01:00
Matthias Krüger
a391d545cf
Rollup merge of #92022 - woodenarrow:br_expected_bool, r=estebank
Eliminate duplicate codes of expected_found_bool

The function expected_found_bool is the same as ExpectedFound::new. So use ExpectedFound::new to replace expected_found_bool to eliminate duplicate codes.

![image](https://user-images.githubusercontent.com/95843988/146486722-c910eccd-a36c-4dc5-8b36-214aab058e38.png)
2021-12-18 11:28:06 +01:00
Matthias Krüger
fedb525e11
Rollup merge of #92018 - estebank:missing-ticks, r=oli-obk
Fix typo in "new region bound" suggestion

The lifetime name shoud always appear in text surrounded by `.
2021-12-18 11:28:05 +01:00
Matthias Krüger
44ff0f75d9
Rollup merge of #91925 - LegionMammal978:less-inband-privacy, r=nagisa
Remove `in_band_lifetimes` from `rustc_privacy`

See #91867 for more information.
2021-12-18 11:28:03 +01:00
Matthias Krüger
df428917ef
Rollup merge of #91923 - LegionMammal978:less-inband-query_impl, r=michaelwoerister
Remove `in_band_lifetimes` from `rustc_query_impl`

See #91867 for more information.
2021-12-18 11:28:02 +01:00
Matthias Krüger
069ffec637
Rollup merge of #91858 - semarie:runpath, r=petrochenkov
pass -Wl,-z,origin to set DF_ORIGIN when using rpath

DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string.

Some implementations are just ignoring [DF_ORIGIN](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#df_flags) and do [substitution](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#substitution) for $ORIGIN if present (whatever DF_ORIGIN presence or not) like glibc. But some others mandate the present of DF_ORIGIN for the substitution (like OpenBSD).

Set the flag inconditionally if rpath is wanted.

One possible fallout is if the linker rejects `-z origin` option.
2021-12-18 11:28:01 +01:00
bors
d3f300477b Auto merge of #92062 - matthiaskrgr:rollup-en3p4sb, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91439 (Mark defaulted `PartialEq`/`PartialOrd` methods as const)
 - #91516 (Improve suggestion to change struct field to &mut)
 - #91896 (Remove `in_band_lifetimes` for `rustc_passes`)
 - #91909 (⬆️ rust-analyzer)
 - #91922 (Remove `in_band_lifetimes` from `rustc_mir_dataflow`)
 - #92025 (Revert "socket ancillary data implementation for dragonflybsd.")
 - #92030 (Update stdlib to the 2021 edition)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-18 10:20:24 +00:00
Matthias Krüger
d2f2f0b91e
Rollup merge of #91922 - LegionMammal978:less-inband-mir_dataflow, r=nagisa
Remove `in_band_lifetimes` from `rustc_mir_dataflow`

See #91867 for more information.
2021-12-18 10:26:38 +01:00
Matthias Krüger
eb3cc132d6
Rollup merge of #91896 - pitaj:91867-passes, r=michaelwoerister
Remove `in_band_lifetimes` for `rustc_passes`

#91867
2021-12-18 10:26:36 +01:00
Matthias Krüger
57d49f15c9
Rollup merge of #91516 - rukai:improve_mut_addition_help, r=estebank
Improve suggestion to change struct field to &mut

r? ``@estebank``

Now displays a proper underline style suggestion instead of including the code change inline with the message.
2021-12-18 10:26:36 +01:00
Vadim Petrochenkov
0d61852cc5 hir: Do not introduce dummy type names for extern blocks in def paths
Use a separate nameless `DefPathData` variant instead
2021-12-18 16:30:17 +08:00
Matthias Krüger
fd445ddf96
Rollup merge of #92016 - calebcartwright:expose-asm-args-parsing, r=Amanieu
builtin_macros: allow external consumers for AsmArgs parsing

As discussed in Zulip (https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/parsing.20of.20AsmArgs.20for.20inline.20assembly), we need a function entry point that rustfmt can leverage from a pre-expansion context to get a more structured representation of the asm args without having to duplicate/maintain the token stream parsing

r? ```@Amanieu``` and/or ```@joshtriplett```
2021-12-18 08:16:31 +01:00