Commit Graph

9922 Commits

Author SHA1 Message Date
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
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
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
Matthias Krüger
816cda7e1b
Rollup merge of #91975 - cjgillot:noinline-generator, r=jackh726
Move generator check earlier in inlining.

Inlining into generator may create references to other generators. For instance, inlining `Pin::<&mut from_generator::GenFuture<[generator1]>>::new_unchecked` into `generator2`. This cross reference can then create cycles when computing inlining for `generator1`.

In order to avoid this kind of surprises, we forbid all inlining into generators, and rely on LLVM to do the right thing. The existing `remove-zst-query-cycle` already ICEs in inline-mir mode, so we use it as test.

Split from #91743.
2021-12-18 08:16:30 +01:00
Matthias Krüger
fcc59794a7
Rollup merge of #91928 - fee1-dead:constification1, r=oli-obk
Constify (most) `Option` methods

r? ``@oli-obk``
2021-12-18 08:16:29 +01:00
Matthias Krüger
64ce698f74
Rollup merge of #91910 - tmiasko:miri-extern-type, r=RalfJung
miri: lift restriction on extern types being the only field in a struct

Fixes #91827.

r? ````@RalfJung````
2021-12-18 08:16:28 +01:00
Matthias Krüger
24b75e7113
Rollup merge of #91818 - camelid:unused-result-type, r=jackh726
Show the unused type for `unused_results` lint

I think it's helpful to know what type was unused when looking at these
warnings. The type will likely determine whether the result *should* be
used, or whether it should just be ignored.

Including the type also matches the behavior of the `must_use` lint:
unused `SomeType` that must be used.
2021-12-18 08:16:27 +01:00
Matthias Krüger
7a626cf7ce
Rollup merge of #89090 - cjgillot:bare-dyn, r=jackh726
Lint bare traits in AstConv.

Removing the lint from lowering allows to:
- make lowering querification easier;
- have the lint implementation in only one place.

r? `@estebank`
2021-12-18 08:16:26 +01:00
Matthias Krüger
54e7946d0f
Rollup merge of #87901 - poliorcetics:pub-pub-pub, r=jackh726
Fix suggestion of additional `pub` when using `pub pub fn ...`

Fix #87694.

Marked as draft to start with because I want to explore doing the same fix for `const const fn` and other repeated-but-valid keywords.

`@rustbot` label A-diagnostics D-invalid-suggestion T-compiler
2021-12-18 08:16:25 +01:00
Lucas Kent
e57307560e get_mut_span_in_struct_field uses span.between 2021-12-18 13:00:08 +11:00
bors
dde825db46 Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisa
Implement let-else type annotations natively

Tracking issue: #87335

Fixes #89688, fixes #89807, edit: fixes  #89960 as well

As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved.

This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically:

* `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~
* It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that.

* ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~
* ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~
    * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~

Some other misc notes:

* ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~
* in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
2021-12-17 22:12:34 +00:00
Michael Howell
f4a0321c03 fix(rustc_lint): mark the parens around (1..loop {}) as unused 2021-12-17 14:12:31 -07:00
Deadbeef
2f555dec4a
Add a temporary hack before env fix lands in bootstrap 2021-12-17 20:46:48 +08:00
Deadbeef
a1f91aa410
Use a const ParamEnv when in default_method_body_is_const 2021-12-17 20:42:48 +08:00
Sébastien Marie
c3da28eade 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 and do substitution for $ORIGIN if present (whatever DF_ORIGIN pr

Set the flag inconditionally if rpath is wanted.
2021-12-17 11:27:14 +00:00
Patrick Walton
c41fd760db 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-16 20:40:04 -08:00
lzh
a995462f9a Eliminate duplicate codes of expected_found_bool 2021-12-17 11:17:43 +08:00
Esteban Kuber
0b8bbac3ff Fix typo in "new region bound" suggestion
The lifetime name shoud always appear in text surrounded by `.
2021-12-17 02:33:25 +00:00
Lucas Kent
97bf7b934e Improve suggestion to change struct field to &mut 2021-12-17 13:20:40 +11:00
bors
9b45f04414 Auto merge of #91672 - b-naber:merge-normalize-erasing-regions-queries, r=jackh726
Implement normalize_erasing_regions queries in terms of 'try' version

Attempt to lessen performance regression caused by https://github.com/rust-lang/rust/pull/91255

r? `@jackh726`
2021-12-17 02:03:10 +00:00
Caleb Cartwright
78a8e0092f builtin_macros: allow external consumers for AsmArgs parsing 2021-12-16 18:40:38 -06:00
LegionMammal978
4937a55dfb Remove in_band_lifetimes from rustc_codegen_llvm
See #91867 for more information.
2021-12-16 14:43:32 -05:00
LegionMammal978
fed881aafc Remove in_band_lifetimes from rustc_mir_dataflow
See #91867 for more information.
2021-12-16 14:29:43 -05:00
Matthias Krüger
a97384d94c
Rollup merge of #92001 - fee1-dead:dmbic-xcrate-fix, r=oli-obk
Fix default_method_body_is_const when used across crates

r? `@oli-obk`

unblocks #91439.
2021-12-16 17:23:13 +01:00
Matthias Krüger
7e5c0711e4
Rollup merge of #91879 - bugadani:in_band_borrowck, r=wesleywiser
Remove `in_band_lifetimes` from `rustc_borrowck`

See #91867 for more information.
2021-12-16 17:23:09 +01:00
Matthias Krüger
7407c4e37d
Rollup merge of #91172 - Ethiraric:ethiraric/fix90979, r=petrochenkov
Warn when a `#[test]`-like built-in attribute macro is present multiple times.

Fixes #90979.
2021-12-16 17:23:07 +01:00
Deadbeef
4bb65e1c79
Fix default_method_body_is_const when used across crates 2021-12-16 21:38:54 +08:00
Matthias Krüger
081493da7f
Rollup merge of #91904 - SylvanB:remove_in_band_lifetimes_rustc_trait_selection, r=petrochenkov
Remove `in_band_lifetimes` from `rustc_trait_selection`

Another one for #91867
2021-12-16 10:12:42 +01:00
Matthias Krüger
02a4e7cad8
Rollup merge of #91901 - SylvanB:remove_in_band_lifetimes_rustc_symbol_mangling, r=jackh726
Remove `in_band_lifetimes` from `rustc_symbol_mangling`

Helping out with  #91867
2021-12-16 10:12:42 +01:00