Commit Graph

212189 Commits

Author SHA1 Message Date
Yuki Okushi
aa0831092b
Rollup merge of #105207 - RalfJung:interpret-clobber-return, r=oli-obk
interpret: clobber return place when calling function

Makes sure the callee cannot observe the previous contents of the return place, and the caller cannot read any of the old return place contents even if the function unwinds.

I don't think we can test for this though, that would require some strange hand-written MIR.

r? `````@oli-obk`````
2022-12-06 12:48:50 +09:00
Yuki Okushi
532fe7b8e0
Rollup merge of #104967 - willcrichton:fix-scrape-examples, r=notriddle
Fix UI issues with Rustdoc scrape-examples feature.

A few regressions have been introduced into scrape-examples in the last few months. This commit fixes those regressions:
* Help file was being loaded from the wrong place (introduced in f9e1f6ffdf).
* CSS selector in JS has a typo (introduced in 14897180ae).
* Line numbers in scraped example code snippets are overflowing (not sure if this was ever fixed). Changing from flexbox to grid display fixed this issue.
2022-12-06 12:48:50 +09:00
bors
ed61c139c2 Auto merge of #105220 - oli-obk:feeding, r=cjgillot
feed resolver_for_lowering instead of storing it in a field

r? `@cjgillot`

opening this as

* a discussion for `no_hash` + `feedable` queries. I think we'll want those, but I don't quite understand why they are rejected beyond a double check of the stable hashes for situations where the query is fed but also read from incremental caches.
* and a discussion on removing all untracked fields from TyCtxt and setting it up so that they are fed queries instead
2022-12-06 03:47:41 +00:00
Michael Goulet
6dc2aa2675 Add GenericParamDef::to_error and InternalSubsts::extend_with_error 2022-12-06 01:53:01 +00:00
Gary Guo
c559cf62c2 Simplify attribute handling in rustc_ast_lowering
Given that attributes is stored in a separate BTreeMap, it's not necessary
to pass it in when constructing `hir::Expr`. We can just construct
`hir::Expr` and then call `self.lower_attrs` later if it needs attributes.

As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-06 01:05:17 +00:00
bors
226202d902 Auto merge of #105119 - JakobDegen:inline-experiments, r=cjgillot
Disable top down MIR inlining

The current MIR inliner has exponential behavior in some cases: <https://godbolt.org/z/7jnWah4fE>. The cause of this is top-down inlining, where we repeatedly do inlining like `call_a() => { call_b(); call_b(); }`. Each decision on its own seems to make sense, but the result is exponential.

Disabling top-down inlining fundamentally prevents this. Each call site in the original, unoptimized source code is now considered for inlining exactly one time, which means that the total growth in MIR size is limited to number of call sites * inlining threshold.

Top down inlining may be worth re-introducing at some point, but it needs to be accompanied with a principled way to prevent this kind of behavior.
2022-12-06 00:53:01 +00:00
Michael Goulet
d2a80c1571 Avoid noting cause code (which is usually misc, b/c codegen) for opaque type reveal overflow 2022-12-06 00:19:55 +00:00
Michael Goulet
e940f845be drive-by: Default param for ToPredicate 2022-12-06 00:19:55 +00:00
Boxy
c9bab74fb2 support Expr in is_const_evaluatable and compute 2022-12-05 23:17:55 +00:00
Peter Collingbourne
b4278b02a7 Reimplement weak! using Option. 2022-12-05 15:05:43 -08:00
Peter Collingbourne
f44a0153bc Support Option and similar enums as type of static variable with linkage attribute.
Compiler MCP:
https://github.com/rust-lang/compiler-team/issues/565
2022-12-05 15:05:43 -08:00
Peter Collingbourne
5873ebeef3 Move linkage type check to HIR analysis and fix semantics issues.
This ensures that the error is printed even for unused variables,
as well as unifying the handling between the LLVM and GCC backends.

This also fixes unusual behavior around exported Rust-defined variables
with linkage attributes. With the previous behavior, it appears to be
impossible to define such a variable such that it can actually be imported
and used by another crate. This is because on the importing side, the
variable is required to be a pointer, but on the exporting side, the
type checker rejects static variables of pointer type because they do
not implement `Sync`. Even if it were possible to import such a type, it
appears that code generation on the importing side would add an unexpected
additional level of pointer indirection, which would break type safety.

This highlighted that the semantics of linkage on Rust-defined variables
is different to linkage on foreign items. As such, we now model the
difference with two different codegen attributes: linkage for Rust-defined
variables, and import_linkage for foreign items.

This change gives semantics to the test
src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was
previously expected to fail to compile. Therefore, convert it into a
test that is expected to successfully compile.

The update to the GCC backend is speculative and untested.
2022-12-05 15:05:43 -08:00
Esteban Küber
e1649c442f Tweak "the following other types implement trait"
When *any* of the suggested impls is an exact match, *only* show the
exact matches. This is particularly relevant for integer types.

fix fmt
2022-12-05 14:59:30 -08:00
Will Crichton
f7a705929a Restore missing newline 2022-12-05 14:04:57 -08:00
bors
8e440b0376 Auto merge of #105328 - matthiaskrgr:rollup-qnfksmq, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104912 (PartialEq: PERs are homogeneous)
 - #104952 (Streamline the user experience for `x.py setup`)
 - #104953 (Ensure required submodules at the same time as updating existing submodules)
 - #105180 (Use proper HirId for async track_caller attribute check)
 - #105222 (std update libc version and freebsd image build dependencies)
 - #105223 (suggest parenthesis around ExprWithBlock BinOp ExprWithBlock)
 - #105230 (Skip recording resolution for duplicated generic params.)
 - #105301 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-05 21:46:58 +00:00
Will Crichton
d595884302 Move -Z maximal-hir-to-mir-coverage implementation to new maybe_new_source_scope method 2022-12-05 12:47:44 -08:00
Michael Howell
32765fbe10 rustdoc: simplify CSS selectors on top-doc and non-exhaustive toggles
This code uses a special `hideme` class anyway, so just style that.
2022-12-05 13:01:29 -07:00
Matthias Krüger
612e89a1fb
Rollup merge of #105301 - RalfJung:miri, r=oli-obk
update Miri

Let's ship the work-around for https://github.com/rust-lang/unsafe-code-guidelines/issues/381.
2022-12-05 20:43:45 +01:00
Matthias Krüger
4ebbb20dad
Rollup merge of #105230 - cjgillot:issue-104312, r=petrochenkov
Skip recording resolution for duplicated generic params.

Turns out the fix was simpler than I thought.

Fixes https://github.com/rust-lang/rust/issues/104312
2022-12-05 20:43:44 +01:00
Matthias Krüger
66a4cb5368
Rollup merge of #105223 - lukas-code:(ExprWithBlock), r=petrochenkov
suggest parenthesis around ExprWithBlock BinOp ExprWithBlock

fix https://github.com/rust-lang/rust/issues/105179
fix https://github.com/rust-lang/rust/issues/102171
2022-12-05 20:43:44 +01:00
Matthias Krüger
e84e8f4165
Rollup merge of #105222 - devnexen:fbsd_update_img, r=petrochenkov
std update libc version and freebsd image build dependencies
2022-12-05 20:43:43 +01:00
Matthias Krüger
78cf0b916a
Rollup merge of #105180 - nbdd0121:async_track_caller, r=compiler-errors
Use proper HirId for async track_caller attribute check

Fix #105134
2022-12-05 20:43:42 +01:00
Matthias Krüger
f4643f59cb
Rollup merge of #104953 - jyn514:fewer-submodule-updates, r=Mark-Simulacrum
Ensure required submodules at the same time as updating existing submodules

In practice, this would always happen at the same time, but putting them next to each other makes that more obvious and ensures it doesn't change in the future. It also avoids the difference affecting `cargo metadata` somehow.

This is based on https://github.com/rust-lang/rust/pull/104952 for convenience to avoid merge conflicts, but doesn't depend on that PR.
2022-12-05 20:43:42 +01:00
Matthias Krüger
4b6010cbb7
Rollup merge of #104952 - jyn514:setup, r=Mark-Simulacrum
Streamline the user experience for `x.py setup`

## Don't update submodules for x setup

Before, the submodule handling was very jank and would update *between two interactive prompts*:
```
; x setup
Building rustbuild
    Finished dev [unoptimized] target(s) in 0.05s
Welcome to the Rust project! What do you want to do with x.py?
a) library: Contribute to the standard library
Please choose one (a/b/c/d/e): a
Updating submodule library/backtrace
Submodule 'library/backtrace' (https://github.com/rust-lang/backtrace-rs.git) registered for path 'library/backtrace'
error: you asked `x.py` to setup a new config file, but one already exists at `config.toml`
Build completed unsuccessfully in 0:00:02
```

That's not a great user experience because you need to wait a long time between prompts.
It would be possible to move the submodule handling either before or after the prompt, but it seems
better to just not require submodules to be checked out at all, to minimize the time spend waiting
just to create a new configuration.

## Revamp the order setup executes

- Create `config.toml` last. It's the most likely to error, and used to stop later steps from executing
- Don't print an error message + exit if the git hook already exists; that's expected
2022-12-05 20:43:41 +01:00
Matthias Krüger
8ad447c479
Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum
PartialEq: PERs are homogeneous

PartialEq claims that it corresponds to a PER, but that is only a well-defined statement when `Rhs == Self`. There is no standard notion of PER on a relation between two different sets/types. So move this out of the first paragraph and clarify this.
2022-12-05 20:43:40 +01:00
Michael Goulet
a1fbc14372 Point at GAT where clause when unsatisfied 2022-12-05 19:11:31 +00:00
Michael Goulet
da929fa63c Make get_impl_future_output_ty work with AFIT 2022-12-05 17:34:42 +00:00
bors
e1d819583f Auto merge of #105176 - klensy:docker-smol, r=Mark-Simulacrum
CI: reduce docker image sizes

Reduces docker image sizes by using simple tips like: cleaning packet managers cache, squashing sequential installation steps into one.

For some images this gives ~40mb for apt-based images (not so much), but ~200mb(!) for centos one.
2022-12-05 17:26:19 +00:00
León Orell Valerian Liehr
d5cb5fb185
normalize inherent associated types after substitution 2022-12-05 18:02:47 +01:00
rustbot
a192284a94 Update books 2022-12-05 12:01:18 -05:00
Michael Howell
65072ee775 rustdoc: remove no-op mobile CSS .sidebar { margin: 0; padding: 0 }
This isn't overriding anything, because the sidebar never has a margin or
padding on it.
2022-12-05 09:15:43 -07:00
Michael Goulet
f4c76b193d Be more careful about unresolved exprs in suggestion 2022-12-05 08:15:30 -08:00
bors
552b63c161 Auto merge of #2715 - RalfJung:rustup, r=RalfJung
Rustup
2022-12-05 12:55:36 +00:00
Ralf Jung
7481ba7746 Merge from rustc 2022-12-05 13:52:53 +01:00
Ralf Jung
16a9fdf663 Preparing for merge from rustc 2022-12-05 13:51:41 +01:00
Oli Scherer
f693b7848e feed resolver_for_lowering instead of storing it in a field 2022-12-05 10:58:55 +00:00
Oli Scherer
125b729ddd Allow arbitrary keys in feeding API 2022-12-05 10:58:55 +00:00
Michael Woerister
56aacb245c StableOrd: Address review comments. 2022-12-05 10:45:31 +01:00
Nicholas Nethercote
8980d9a76d Remove {Early,Late}LintPassObjects.
`EarlyContextAndPass` wraps a single early lint pass. We aggregate
multiple passes into that single pass by using `EarlyLintPassObjects`.

This commit removes `EarlyLintPassObjects` by changing
`EarlyContextAndPass` into `EarlyContextAndPasses`. I.e. it just removes
a level of indirection. This makes the code simpler and slightly faster.

The commit does likewise for late lints.
2022-12-05 19:50:10 +11:00
bors
203c8765ea Auto merge of #105046 - scottmcm:vecdeque-vs-vec, r=Mark-Simulacrum
Send `VecDeque::from_iter` via `Vec::from_iter`

Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
2022-12-05 08:45:03 +00:00
Rageking8
58110572fb fix dupe word typos 2022-12-05 16:42:36 +08:00
Will Crichton
3bf7d88ef1 Add -Z maximal-hir-to-mir-coverage flag 2022-12-04 23:58:20 -08:00
bors
e72ea1dc37 Auto merge of #104824 - klensy:bump-some, r=Mark-Simulacrum
deps: update cpufeatures, swap difference to dissimilar

Updating cpufeatures v0.2.1 -> v0.2.5: https://github.com/RustCrypto/utils/blob/master/cpufeatures/CHANGELOG.md#025-2022-09-04, was yanked bc of miscompile (https://github.com/RustCrypto/utils/pull/800, https://github.com/rust-lang/rust/issues/101346)

Removing difference v2.0.0
     Adding dissimilar v1.0.4
   Updating expect-test v1.0.1 -> v1.4.0

difference unmaintened https://rustsec.org/advisories/RUSTSEC-2020-0095.html, so replaced with https://github.com/dtolnay/dissimilar (as dependency of `expect-test`)
2022-12-05 05:54:33 +00:00
Michael Goulet
19175e9b75 Synthesize generics for bad auto traits in dyn types 2022-12-05 05:45:12 +00:00
Gary Guo
34c377335b Add fixme note 2022-12-05 03:18:26 +00:00
bors
b9341bfdb1 Auto merge of #104920 - compiler-errors:avoid-infcx-build, r=jackh726
Avoid some `InferCtxt::build` calls

Either because we're inside of an `InferCtxt` already, or because we're not in a place where we'd ever see inference vars.

r? types
2022-12-05 02:51:06 +00:00
Michael Goulet
1c81540206 Unconditional check FRU expression, even if there are errors present 2022-12-05 00:42:40 +00:00
bors
d1449560e3 Auto merge of #105094 - Swatinem:generator-not-future, r=compiler-errors
Make sure async constructs do not `impl Generator`

Async lowering turns async functions and blocks into generators internally.
Though these special kinds of generators should not `impl Generator` themselves.
The other way around, normal generators should not `impl Future`.

This was discovered in https://github.com/rust-lang/rust/pull/105082#issuecomment-1332210907 and is a regression from https://github.com/rust-lang/rust/pull/104321.

r? `@compiler-errors`
2022-12-04 22:46:11 +00:00
Eduardo Sánchez Muñoz
2e51122647 Make integer-to-integer From impls #[inline(always)] 2022-12-04 22:55:18 +01:00
Michael Goulet
a68eae2f70 Avoid InferCtxt::build in generic_arg_mismatch_err 2022-12-04 20:54:30 +00:00