Commit Graph

22784 Commits

Author SHA1 Message Date
Camille GILLOT
bcb161def7 Wrap the whole LocalInfo in ClearCrossCrate. 2023-03-14 20:52:42 +01:00
bors
2e7034ebf7 Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, r=petrochenkov
Properly allow macro expanded `format_args` invocations to uses captures

Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly.

This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me).

Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string.

The "source literal" checks were not strict enough and caused ICEs in certain cases (see #106191). So I tightened it up in #106195 to really only work if it's a direct source literal.

This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`).

This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again.

Fixes #106191

[RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14 14:25:02 +00:00
Nilstrieb
427aceb9d4 Improve heuristics for format_args literal being suggestable
Sometimes, we want to create subspans and point at code in the literal
if possible. But this doesn't always make sense, sometimes the literal
may come from macro expanded code and isn't actually there in the
source. Then, we can't really make these suggestions.

This now makes sure that the literal is actually there as we see it so
that we will not run into ICEs on weird literal transformations.
2023-03-14 13:20:39 +00:00
Nilstrieb
729185338f Properly allow macro expanded format_args invocations to uses captures
Originally, this was kinda half-allowed. There were some primitive
checks in place that looked at the span to see whether the input was
likely a literal. These "source literal" checks are needed because the
spans created during `format_args` parsing only make sense when it is
indeed a literal that was written in the source code directly.

This is orthogonal to the restriction that the first argument must be a
"direct literal", not being exanpanded from macros. This restriction was
imposed by [RFC 2795] on the basis of being too confusing. But this was
only concerned with the argument of the invocation being a literal, not
whether it was a source literal (maybe in spirit it meant it being a
source literal, this is not clear to me).

Since the original check only really cared about source literals (which
is good enough to deny the `format_args!(concat!())` example), macros
expanding to `format_args` invocations were able to use implicit
captures if they spanned the string in a way that lead back to a source
string.

The "source literal" checks were not strict enough and caused ICEs in
certain cases (see # 106191 (the space is intended to avoid spammy
backreferences)). So I tightened it up in # 106195 to really only work
if it's a direct source literal.

This caused the `indoc` crate to break. `indoc` transformed the source
literal by removing whitespace, which made it not a "source literal"
anymore (which is required to fix the ICE). But since `indoc` spanned
the literal in ways that made the old check think that it's a literal,
it was able to use implicit captures (which is useful and nice for the
users of `indoc`).

This commit properly seperates the previously introduced concepts of
"source literal" and "direct literal" and therefore allows `indoc`
invocations, which don't create "source literals" to use implicit
captures again.

[RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14 13:16:52 +00:00
bors
669e751639 Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00
bors
0058748944 Auto merge of #109057 - compiler-errors:rpitit-info-again, r=spastorino
Don't `opt_rpitit_info` as a separate query

... another attempt to undo regressions

r? `@ghost`
2023-03-14 06:42:15 +00:00
bors
bd43458d4c Auto merge of #108992 - petrochenkov:qcstore2, r=cjgillot
resolve: Querify most cstore access methods (subset)

A subset of https://github.com/rust-lang/rust/pull/108346 that is not on a hot path in any way.
2023-03-14 03:38:42 +00:00
Matthias Krüger
30cd4b3a16
Rollup merge of #109088 - Nilstrieb:target-feature-on-statics-when, r=compiler-errors
Gracefully handle `#[target_feature]` on statics

The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds.

I was sadly not able to fully bless the test locally because I'm on an aarch64 machine but I hope some manual editing made it work 😅

Fix #109079
2023-03-13 21:55:39 +01:00
Matthias Krüger
9fc8de0caa
Rollup merge of #109058 - tmiasko:is-checkable, r=jackh726
Document BinOp::is_checkable
2023-03-13 21:55:37 +01:00
Nilstrieb
34be05e097 Gracefully handle #[target_feature] on statics
The was careful around not calling `fn_sig` on not-functions but well,
it wasn't careful enough. This commit makes it a little more careful and
also adds tests for a bunch more item kinds.
2023-03-13 19:05:06 +00:00
Michael Goulet
ce8dae5800 Don't opt_rpitit_info as a separate query 2023-03-13 17:02:47 +00:00
Michael Goulet
84d254ead0 Better names? 2023-03-13 16:34:16 +00:00
Michael Goulet
c32527fb92 Treat projections with infer as placeholder during fast reject in new solver 2023-03-13 16:34:16 +00:00
Vadim Petrochenkov
4a61922ef0 metadata/resolve: Minor refactoring to "tcx -> cstore" conversions 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
98cce81917 metadata: Remove some more untracked CStore methods 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
b3ee735993 resolve: Remove struct_field_names_untracked 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
2a716f3563 resolve: Centralize retrieval of items span and item name 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
c7f424b80a resolve: Remove fn_has_self_parameter_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
c05b7bd7d0 resolve: Remove struct_field_visibilities_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
901f1c9c62 resolve: Partially remove item_attrs_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
17127f3e78 resolve: Remove visibility_untracked 2023-03-13 17:31:54 +04:00
bors
f1b1ed7e18 Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31
Remove `box_syntax`

r? `@Nilstrieb`

This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected.
It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute.
As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new`

Closes #49733
2023-03-13 10:41:50 +00:00
bors
b05bb29008 Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obk
Strengthen state tracking in const-prop

Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization.

Behaviour changes:
- const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen.
- we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry.
- the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
2023-03-12 23:27:52 +00:00
bors
7b4f48927d Auto merge of #109056 - matthiaskrgr:rollup-9trny1z, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108651 (Forbid the use of `#[target_feature]` on `main`)
 - #109009 (rustdoc: use restricted Damerau-Levenshtein distance for search)
 - #109026 (Introduce `Rc::into_inner`, as a parallel to `Arc::into_inner`)
 - #109029 (Gate usages of `dyn*` and const closures in macros)
 - #109031 (Rename `config.toml.example` to `config.example.toml`)
 - #109032 (Use `TyCtxt::trait_solver_next` in some places)
 - #109047 (typo)
 - #109052 (Add eslint check for rustdoc-gui tester)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-12 20:21:26 +00:00
Matthias Krüger
fb4bb1679a
Rollup merge of #109047 - tshepang:type, r=lcnr
typo
2023-03-12 20:44:52 +01:00
Matthias Krüger
4305c1a89d
Rollup merge of #109032 - compiler-errors:shorter, r=BoxyUwU
Use `TyCtxt::trait_solver_next` in some places

Also flip order of if statements to avoid `!`
2023-03-12 20:44:52 +01:00
Matthias Krüger
98fea68470
Rollup merge of #109029 - compiler-errors:parse-gating, r=jackh726
Gate usages of `dyn*` and const closures in macros

We silently accepted `dyn*` and const closures in macros as long as they didn't expand to anything containing these experimental features, unlike other gated features such as `for<'a>` binders on closures, etc. Let's not do that, to make sure nobody begins relying on this.
2023-03-12 20:44:51 +01:00
Matthias Krüger
f41796e6b4
Rollup merge of #108651 - LeSeulArtichaut:108645-target-feature-on-main, r=Nilstrieb
Forbid the use of `#[target_feature]` on `main`

Fixes #108645.
2023-03-12 20:44:49 +01:00
bors
938afba899 Auto merge of #108845 - Zoxc:par-fix-2, r=cjgillot
Check that a query has not completed and is not executing before starting it

This fixes a race in the query system where we only checked if the query was currently executing, but not if it was already completed, causing queries to re-execute.

r? `@cjgillot`
2023-03-12 17:03:44 +00:00
bors
f41927f309 Auto merge of #108820 - cjgillot:ensure-on-disk, r=oli-obk
Ensure value is on the on-disk cache before returning from `ensure()`.

The current logic for `ensure()` a query just checks that the node is green in the dependency graph.
However, a lot of places use `ensure()` to prevent the query from being called later. This is the case before stealing a query result.

If the query is actually green but the value is not available in the on-disk cache, `ensure` would return, but a subsequent call to the full query would run the code, and attempt to read from a stolen value.

This PR conforms the query system to the usage by checking whether the queried value is loadable from disk before returning.

Sadly, I can't manage to craft a proper test...

Should fix all instances of "attempted to read from stolen value".
2023-03-12 14:00:28 +00:00
Léo Lanteri Thauvin
29b1789a75 Allow #[target_feature] on main and start for WASM 2023-03-12 14:57:38 +01:00
Léo Lanteri Thauvin
963305bda8 Forbid the use of #[target_feature] on start 2023-03-12 14:57:38 +01:00
Léo Lanteri Thauvin
db26693982 Forbid the use of #[target_feature] on main 2023-03-12 14:57:38 +01:00
clubby789
8b186dfdb7 Add recovery for use of removed box syntax 2023-03-12 13:26:37 +00:00
clubby789
0932452fa4 Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
clubby789
dd7df04e16 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
Tshepang Mbambo
421c34b2b0 typo 2023-03-12 11:56:56 +02:00
bors
24c0b81c1f Auto merge of #109043 - matthiaskrgr:rollup-genkz0e, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108726 (tidy: enforce comment blocks to have an even number of backticks)
 - #108797 (Allow binary files to go through the `FileLoader`)
 - #108841 (Add suggestion to diagnostic when user has array but trait wants slice. (rebased))
 - #108984 (bootstrap: document tidy)
 - #109013 (Give proper error message when tcx wasn't passed to decoder)
 - #109017 (remove duplicated calls to sort_string)
 - #109018 (Expand on the allocator comment in `rustc-main`)
 - #109028 (Add eslint checks for rustdoc-js tester)
 - #109034 (Commit some tests for the new solver + lazy norm)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-12 09:44:17 +00:00
Matthias Krüger
7ad471b09d
Rollup merge of #109018 - jyn514:global-allocator-comment, r=lqd
Expand on the allocator comment in `rustc-main`

Before, it said "global_allocator does nothing". Now it gives you suggestions for what to do if you want to change the global allocator (which is likely the main reason you'd be reading the comment).

cc https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/improving.20rustc.20memory.20usage
2023-03-12 08:13:28 +01:00
Matthias Krüger
c9a38c3c69
Rollup merge of #109017 - klensy:dupe, r=cjgillot
remove duplicated calls to sort_string

`with_forced_trimmed_paths!` was removed in 62ba3e70a1, and this lines became dups.
2023-03-12 08:13:28 +01:00
Matthias Krüger
738c4bf176
Rollup merge of #109013 - Nilstrieb:obscurity-is-not-a-necessity, r=fee1-dead
Give proper error message when tcx wasn't passed to decoder

I hit this yesterday and found it very confusing, even though the solution to the problem is very simple.
2023-03-12 08:13:27 +01:00
Matthias Krüger
67c9dbfe02
Rollup merge of #108841 - jackh726:issue-90528, r=compiler-errors
Add suggestion to diagnostic when user has array but trait wants slice. (rebased)

Rebase of #91314, except for change to multipart suggestion

Resolves #90528

r? ``@compiler-errors`` since you requested the multipart suggestion
2023-03-12 08:13:26 +01:00
Matthias Krüger
b16ed694f7
Rollup merge of #108797 - thomcc:sourcemap_include_binary_file, r=compiler-errors
Allow binary files to go through the `FileLoader`

I'd like for `include_bytes!` to go through the `FileLoader` in an out-of-tree `rustc_driver` wrapper, and I can't find a reason it's not already done. It seems like most folks providing a custom `FileLoader` would want this too, so I added it.

I can solve my problem in other ways if there's a strong reason not to do it, but it seems simple and harmless.
2023-03-12 08:13:26 +01:00
Matthias Krüger
9668ae5eb8
Rollup merge of #108726 - est31:backticks_matchmaking_tidy, r=Nilstrieb
tidy: enforce comment blocks to have an even number of backticks

After PR #108694, most unmatched backticks in `compiler/` comments have been eliminated. This PR adds a tidy lint to ensure no new unmatched backticks are added, and either addresses the lint in the remaining instances it found, or allows it.

Very often, backtick containing sections wrap around lines, for example:

```Rust
// This function takes a tuple `(Vec<String>,
// Box<[u8]>)` and transforms it into `Vec<u8>`.
```

The lint is implemented to work on top of blocks, counting each line with a `//` into a block, and counting if there are an odd or even number of backticks in the entire block, instead of looking at just a single line.
2023-03-12 08:13:25 +01:00
bors
150cb38147 Auto merge of #108794 - nnethercote:avoid-unnecessary-hashing, r=cjgillot
Avoid unnecessary hashing

I noticed some stable hashing being done in a non-incremental build. It turns out that some of this is necessary to compute the crate hash, but some of it is not. Removing the unnecessary hashing is a perf win.

r? `@cjgillot`
2023-03-12 06:48:30 +00:00
bors
501ad021b9 Auto merge of #108682 - est31:simplify_dirs, r=davidtwco
Simplify message paths

This makes it easier to open the messages file. Right now I have to first click on the `locales` dir to open it, and then on the `en-US.ftl` file. `Cargo.toml` and `build.rs` files are also in the top level, and I think there should not be more than one file, so a directory isn't really needed. The [chosen strategy for pontoon adoption](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/pontoon.20and.20next.20steps) is out of tree. Even if this descision is changed in the future, the `messages.ftl` approach is also compatible with non-english translations living in-tree, as long as the non-english translations don't live in the `compiler/rustc_foo/` directories but in different ones. That would also be helpful for grepability purposes.

The commit was the result of automated changes:

```
for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done

for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
```

r? `@davidtwco`
2023-03-12 03:51:21 +00:00
bors
9455a5591b Auto merge of #108700 - spastorino:new-rpitit-impl-side-2, r=compiler-errors
Make RPITITs simple cases work when using lower_impl_trait_in_trait_to_assoc_ty

r? `@compiler-errors`

It's probably best reviewed commit by commit.
2023-03-12 00:49:35 +00:00
Tomasz Miąsko
b16d6ccdcd Document BinOp::is_checkable 2023-03-12 00:00:00 +00:00
Camille GILLOT
e955ec0908 Use ensure_with_value in a few more places. 2023-03-11 22:42:13 +00:00
Camille GILLOT
382cc909d5 Make the check for cache opt-in. 2023-03-11 22:41:01 +00:00