Commit Graph

18191 Commits

Author SHA1 Message Date
BlackHoleFox
d2a3784780 Fix x86_64-apple-tvos target to use the correct target_abi 2022-10-23 15:46:43 -05:00
BlackHoleFox
79eedef984 Fix x86_64-apple-ios target to use the correct target_abi 2022-10-23 15:44:58 -05:00
bors
1ca6777c01 Auto merge of #101403 - bjorn3:dylib_lto, r=Mark-Simulacrum
Enable LTO for rustc_driver.so

Alternative to https://github.com/rust-lang/rust/pull/97154

This enables LTO'ing dylibs behind a feature flag and uses this feature for compiling rustc_driver.so.
2022-10-23 15:00:31 +00:00
Jakub Beránek
c5c86806c8
Introduce dedicated -Zdylib-lto flag for enabling LTO on dylibs 2022-10-23 13:48:03 +02:00
bjorn3
32238ce1e2
Allow LTO for dylibs 2022-10-23 13:43:07 +02:00
bjorn3
f7f17bf220
Add missing export for the oom strategy symbol 2022-10-23 13:43:07 +02:00
bors
9be2f35a4c Auto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #101293 (Recover when unclosed char literal is parsed as a lifetime in some positions)
 - #101908 (Suggest let for assignment, and some code refactor)
 - #103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`)
 - #103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis)
 - #103249 (resolve: Revert "Set effective visibilities for imports more precisely")
 - #103305 (Move some tests to more reasonable places)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-23 11:33:18 +00:00
Dylan DPC
0b3e018137
Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obk
resolve: Revert "Set effective visibilities for imports more precisely"

In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components.

Fixes https://github.com/rust-lang/rust/issues/102352
r? `@oli-obk`
2022-10-23 15:20:18 +05:30
Dylan DPC
8440b09d17
Rollup merge of #103226 - compiler-errors:delay-if-need-infer, r=lcnr
Check `needs_infer` before `needs_drop` during HIR generator analysis

This is kinda a revival of #103036, but with the understanding that after fallback, a generator-interior type will only have `needs_infer` true if there's an error that prevented int or float variable fallback to occur (modulo region variables, which are erased).

Therefore the best choice here is to delay a bug and skip the `needs_drop` call altogether.

r? `@lcnr` feel free to reassign though
2022-10-23 15:20:17 +05:30
Dylan DPC
e426874788
Rollup merge of #103192 - petrochenkov:noalltraits, r=jyn514
rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`

Another step to https://github.com/rust-lang/rust/pull/94857.
2022-10-23 15:20:17 +05:30
Dylan DPC
518d5ebc81
Rollup merge of #101908 - chenyukang:fix-101880, r=estebank
Suggest let for assignment, and some code refactor

Fixes #101880
2022-10-23 15:20:16 +05:30
Dylan DPC
e029c1fd43
Rollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebank
Recover when unclosed char literal is parsed as a lifetime in some positions

Fixes #101278
2022-10-23 15:20:16 +05:30
bors
e64f1110c0 Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors
Flatten diagnostic slug modules

This makes it easier to grep for the slugs in the code.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it.

This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know.

r? `@davidtwco`
2022-10-23 09:06:39 +00:00
Nilstrieb
c65ebae221
Migrate all diagnostics 2022-10-23 10:09:44 +02:00
Nilstrieb
2459569776
Generate fluent message constant in a flat module for all crates
This will make it easier to grep for fluent message names.
2022-10-23 10:09:44 +02:00
bors
faab68eb29 Auto merge of #103426 - matthiaskrgr:rollup-n6dqdy8, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103123 (Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder` )
 - #103328 (Do not suggest trivially false const predicates)
 - #103354 (Escape string literals when fixing overlong char literal)
 - #103355 (Handle return-position `impl Trait` in traits properly in `register_hidden_type`)
 - #103368 (Delay ambiguity span bug in normalize query iff not rustdoc)
 - #103388 (rustdoc: remove unused CSS class `.result-description`)
 - #103399 (Change `unknown_lint` applicability to `MaybeIncorrect`)
 - #103401 (Use functions for headings rustdoc GUI test)
 - #103412 (Fix typo in docs of `String::leak`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-23 06:20:24 +00:00
Matthias Krüger
6be917a748
Rollup merge of #103399 - smoelius:unknown-lint-maybe-incorrect, r=fee1-dead
Change `unknown_lint` applicability to `MaybeIncorrect`

This small PR changes the applicability of `unknown_lint` to `MaybeIncorrect`, because the suggested lint might not be the correct one.

Here is one example where the current applicability causes a problem. Clippy has a set of internal lints guarded by a feature called `internal`. If the feature is not enabled, then the internal lints are "unknown." In that case, running `cargo clippy --fix ...` on `clippy_utils` causes lines such as the followig
26c96e3416/src/tools/clippy/clippy_utils/src/paths.rs (L51-L52)
to be changed to
```rust
 #[expect(clippy::invalid_regex)] // internal lints do not know about all external crates
 pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"];
```
which is not correct.
2022-10-23 08:14:33 +02:00
Matthias Krüger
72f75d18b1
Rollup merge of #103368 - compiler-errors:normalization-ambiguity-bug, r=oli-obk
Delay ambiguity span bug in normalize query iff not rustdoc

Oli and I decided that the compiler debt of adding another usage of `tcx.sess.opts.actually_rustdoc` is fine, because we don't really want to add more complexity to the normalize query, and moving rustdoc to use fulfill normalization (`fully_normalize`, i.e. not use the normalize query) is unnecessary overhead given that it's skipping binders and stuff.

r? oli-obk

Fixes #102827
Fixes #103181
2022-10-23 08:14:32 +02:00
Matthias Krüger
ff689a1404
Rollup merge of #103355 - compiler-errors:rpitit-default-check, r=oli-obk
Handle return-position `impl Trait` in traits properly in `register_hidden_type`

The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque.

Coincidentally fixes #102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type").

Fixes #103352

r? ```@oli-obk```
2022-10-23 08:14:31 +02:00
Matthias Krüger
b656f5e9a6
Rollup merge of #103354 - clubby789:escape-string-literals, r=compiler-errors
Escape string literals when fixing overlong char literal

Fixes #103323

````@rustbot```` label +A-diagnostics +A-suggestion-diagnostics
2022-10-23 08:14:31 +02:00
Matthias Krüger
1a077420f8
Rollup merge of #103328 - compiler-errors:trivial-false-const-sugg, r=jackh726
Do not suggest trivially false const predicates

Pass through constness to `predicate_can_apply` and don't suggest other impls if it's satisfied but not const.

Fixes #103267
2022-10-23 08:14:30 +02:00
Matthias Krüger
5290d5e321
Rollup merge of #103123 - compiler-errors:early-binder-iter, r=cjgillot
Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder`

Makes working with bounds lists a bit easier, which I seem to do a lot.

Specifically, means that we don't need to do `.transpose_iter().map(|(pred, _)| *pred)` every time we want to iterate through an `EarlyBinder<&'tcx [(Predicate, Span)]>` (and even then, still have to call `subst` later), which was a very awkward idiom imo.
2022-10-23 08:14:30 +02:00
bors
6c9c2d862d Auto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obk
Remove ParamEnv from uninhabited query
2022-10-23 03:39:43 +00:00
bors
6e95b6da88 Auto merge of #103240 - BelovDV:issue-102290, r=petrochenkov
Add architectures to fn create_object_file

Fixes #102290

r? `@petrochenkov`
2022-10-22 19:14:34 +00:00
Cameron Steffen
2928e9ef2c Introduce InhabitedPredicate 2022-10-22 13:20:06 -05:00
bors
289b2b8cf9 Auto merge of #103398 - Dylan-DPC:rollup-cj6w00o, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #102602 (Slightly tweak comments wrt `lint_overflowing_range_endpoint`)
 - #103190 (rustdoc: render bounds of cross-crate GAT params)
 - #103224 (Allow semicolon after closure within parentheses in macros)
 - #103280 ((#102929) Implement `String::leak` (attempt 2))
 - #103329 (Add a forgotten check for NonNull::new_unchecked's precondition)
 - #103346 (Adjust argument type for mutable with_metadata_of (#75091))
 - #103360 (Reduce false positives in msys2 detection)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-22 13:40:59 +00:00
Samuel Moelius
62b65b5ede Change unknown_lint applicability to MaybeIncorrect 2022-10-22 07:17:36 -04:00
Dylan DPC
ada50112ba
Rollup merge of #103224 - compiler-errors:semi-after-closure-in-macro, r=fee1-dead
Allow semicolon after closure within parentheses in macros

#88546 added some parsing logic that if we're parsing a closure, and we're within parentheses, and a semicolon follows, then we must be parsing something erroneous like: `f(|| a; b)`, so it replaces the closure body with an error expression. However, it's valid to parse those tokens if we're within a macro, as in #103222.

This is a bit unsatisfying fix. Is there a more robust way of checking that we're within a macro?

I would also be open to removing this "_It is likely that the closure body is a block but where the braces have been removed_" check altogether at the expense of more verbose errors, since it seems very suspicious in the first place...

Fixes #103222.
2022-10-22 16:28:08 +05:30
Dylan DPC
16c3b64794
Rollup merge of #102602 - WaffleLapkin:linty_action, r=estebank
Slightly tweak comments wrt `lint_overflowing_range_endpoint`

From the review: https://github.com/rust-lang/rust/pull/101986#discussion_r975610611

It _seemed_ that the lint was not emitted when the `if` check failed, but _actually_ this happens already in a special case and the lint is emitted outside of this function, if this function doesn't. I've cleared up the code/comments a bit, so it's more obvious :)

r? ```@estebank```
2022-10-22 16:28:07 +05:30
bors
f8c86c82bf Auto merge of #103231 - ecnelises:le_fix, r=lcnr
Remove byte swap of valtree hash on big endian

This addresses problem reported in #103183. The code was originally introduced in e14b34c386. (see https://github.com/rust-lang/rust/pull/96591)

On big-endian environment, this operation sequence actually put the other half from 128-bit result, thus we got different hash result on LE and BE.
2022-10-22 10:53:17 +00:00
bors
26c96e3416 Auto merge of #103227 - lcnr:bye-bye-unevaluated-const, r=oli-obk
stop using `ty::UnevaluatedConst` directly

best reviewed commit by commit.

simplifies #99798 because we now don't have to expand `ty::UnevaluatedConst` to `ty::Const`.
I also remember some other places where using `ty::UnevaluatedConst` directly was annoying and caused issues, though I don't quite remember what they were rn '^^

r? `@oli-obk` cc `@JulianKnodt`
2022-10-22 07:49:33 +00:00
Michael Goulet
3d7b1f0d18 Don't erroneously deny semicolons after closure expr within parentheses in a macro 2022-10-22 06:59:49 +00:00
Michael Goulet
0270b50eb0 Recover unclosed char literal being parsed as lifetime 2022-10-22 06:57:12 +00:00
Michael Goulet
aa8931c612 Introduce subst_iter and subst_iter_copied on EarlyBinder 2022-10-22 06:52:12 +00:00
Michael Goulet
134de38e4d nit: Inline may_need_drop 2022-10-22 06:50:00 +00:00
Michael Goulet
5b06898d21 Check needs_infer before needs_drop in HIR generator analysis 2022-10-22 06:50:00 +00:00
bors
3022afe3d1 Auto merge of #103196 - Nilstrieb:no-meta-query, r=cjgillot
Get rid of native_library projection queries

They don't seem particularly useful as I don't expect native libraries to change frequently.

Maybe they do provide significant value of keeping incremental compilation green though, I'm not sure.
2022-10-22 05:08:51 +00:00
bors
eecde5850c Auto merge of #103172 - pcwalton:deduced-param-attrs, r=oli-obk
Introduce deduced parameter attributes, and use them for deducing `readonly` on indirect immutable freeze by-value function parameters.

Introduce deduced parameter attributes, and use them for deducing `readonly` on
indirect immutable freeze by-value function parameters.

Right now, `rustc` only examines function signatures and the platform ABI when
determining the LLVM attributes to apply to parameters. This results in missed
optimizations, because there are some attributes that can be determined via
analysis of the MIR making up the function body. In particular, `readonly`
could be applied to most indirectly-passed by-value function arguments
(specifically, those that are freeze and are observed not to be mutated), but
it currently is not.

This patch introduces the machinery that allows `rustc` to determine those
attributes. It consists of a query, `deduced_param_attrs`, that, when
evaluated, analyzes the MIR of the function to determine supplementary
attributes. The results of this query for each function are written into the
crate metadata so that the deduced parameter attributes can be applied to
cross-crate functions. In this patch, we simply check the parameter for
mutations to determine whether the `readonly` attribute should be applied to
parameters that are indirect immutable freeze by-value.  More attributes could
conceivably be deduced in the future: `nocapture` and `noalias` come to mind.

Adding `readonly` to indirect function parameters where applicable enables some
potential optimizations in LLVM that are discussed in [issue 103103] and [PR
103070] around avoiding stack-to-stack memory copies that appear in functions
like `core::fmt::Write::write_fmt` and `core::panicking::assert_failed`. These
functions pass a large structure unchanged by value to a subfunction that also
doesn't mutate it. Since the structure in this case is passed as an indirect
parameter, it's a pointer from LLVM's perspective. As a result, the
intermediate copy of the structure that our codegen emits could be optimized
away by LLVM's MemCpyOptimizer if it knew that the pointer is `readonly
nocapture noalias` in both the caller and callee. We already pass `nocapture
noalias`, but we're missing `readonly`, as we can't determine whether a
by-value parameter is mutated by examining the signature in Rust. I didn't have
much success with having LLVM infer the `readonly` attribute, even with fat
LTO; it seems that deducing it at the MIR level is necessary.

No large benefits should be expected from this optimization *now*; LLVM needs
some changes (discussed in [PR 103070]) to more aggressively use the `noalias
nocapture readonly` combination in its alias analysis. I have some LLVM patches
for these optimizations and have had them looked over. With all the patches
applied locally, I enabled LLVM to remove all the `memcpy`s from the following
code:

```rust
fn main() {
    println!("Hello {}", 3);
}
```

which is a significant codegen improvement over the status quo. I expect that if this optimization kicks in in multiple places even for such a simple program, then it will apply to Rust code all over the place.

[issue 103103]: https://github.com/rust-lang/rust/issues/103103

[PR 103070]: https://github.com/rust-lang/rust/pull/103070
2022-10-22 02:28:05 +00:00
clubby789
ed40d46159 Properly escape quotes when suggesting switching between char/string literals 2022-10-22 02:37:15 +01:00
Matthias Krüger
ed430ca5fe
Rollup merge of #103351 - oli-obk:tilde_const_impls, r=fee1-dead
Require Drop impls to have the same constness on its bounds as the bounds on the struct have

r? ``@fee1-dead``
2022-10-22 00:14:02 +02:00
Matthias Krüger
7ee0aeacaf
Rollup merge of #103339 - Rageking8:fix-some-typos, r=fee1-dead
Fix some typos
2022-10-22 00:14:00 +02:00
Matthias Krüger
ebfdf735ac
Rollup merge of #102635 - lcnr:incoherent_auto_trait_objects, r=jackh726
make `order_dependent_trait_objects` show up in future-breakage reports

tried to change it to a hard error in #102474 but breaking the more than 1000 dependents of `traitobject` doesn't feel great 😅

This lint has existed since more than 3 years now and the way this is currently implemented is buggy and will break with #102472. imo we should upgrade it to also report for dependencies and maybe also backport this to beta. Then after maybe 2-3 stable versions I would like to finally convert this lint to a hard error.
2022-10-22 00:13:59 +02:00
Michael Goulet
9f6b9dd644 Delay ambiguity span bug in normalize query iff not rustdoc 2022-10-21 18:53:16 +00:00
bors
57e2c06a8d Auto merge of #101077 - sunshowers:signal-mask-inherit, r=sunshowers
Change process spawning to inherit the parent's signal mask by default

Previously, the signal mask was always reset when a child process is
started. This breaks tools like `nohup` which expect `SIGHUP` to be
blocked for all transitive processes.

With this change, the default behavior changes to inherit the signal mask.

This also changes the signal disposition for `SIGPIPE` to only be changed if the `#[unix_sigpipe]` attribute isn't set.
2022-10-21 18:09:03 +00:00
bors
ba9d01be67 Auto merge of #98450 - lqd:doc-metadata, r=lqd,GuillaumeGomez
Remove more attributes from metadata

A lot of the attributes that are currently stored in the metadata aren't used at all. The biggest metadata usage comes from the doc attributes currently but they are needed by rustdoc so we only removed the ones that cannot be used in downstream crates (doc comments on private items).

r? `@ghost`
2022-10-21 15:27:56 +00:00
Michael Goulet
419fde7a38 Handle RPITITs properly in register_hidden_type 2022-10-21 14:57:01 +00:00
Oli Scherer
d6cf8934db Require Drop impls to have the same constness on its bounds as the bounds on the struct have 2022-10-21 14:22:13 +00:00
Oli Scherer
349ba6bb51 Remove needless special cases and dead code 2022-10-21 14:21:44 +00:00
bors
657f246812 Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`)
 - #102922 (Filtering spans when emitting json)
 - #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use)
 - #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names)
 - #103260 (Fixup a few tests needing asm support)
 - #103321 (rustdoc: improve appearance of source page navigation bar)

Failed merges:

 - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-21 12:41:09 +00:00
Dylan DPC
3055eb9b26
Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead
Fixup a few tests needing asm support
2022-10-21 17:29:59 +05:30