Commit Graph

237489 Commits

Author SHA1 Message Date
Jubilee
975d042d4c
Rollup merge of #116534 - cjgillot:no-dep-tasks, r=davidtwco
Remove -Zdep-tasks.

This option is not useful any more, we can use `tracing` and `RUSTC_LOG` to debug the dep-graph.
2023-10-28 01:07:35 -07:00
bors
17659c71ba Auto merge of #117253 - antoyo:subtree-update_cg_gcc_2023-10-25, r=bjorn3,GuillaumeGomez
subtree update cg_gcc 2023/10/25
2023-10-28 04:57:15 +00:00
bors
20952db40d Auto merge of #117302 - weihanglo:update-cargo, r=weihanglo
Update cargo

8 commits in df3509237935f9418351b77803df7bc05c009b3d..708383d620e183a9ece69b8fe930c411d83dee27
2023-10-24 23:09:01 +0000 to 2023-10-27 21:09:26 +0000
- feat(doc): Print the generated docs links (rust-lang/cargo#12859)
- feat(toml): Allow version-less manifests (rust-lang/cargo#12786)
- Remove outdated option to `-Zcheck-cfg` warnings (rust-lang/cargo#12884)
- Remove duplicate binaries during install (rust-lang/cargo#12868)
- refactor(shell): Write at once rather than in fragments (rust-lang/cargo#12880)
- docs(ref): Link to docs.rs metadata table (rust-lang/cargo#12879)
- docs(contrib): Describe how to add a new package (rust-lang/cargo#12878)
- move up looking at index summary enum (rust-lang/cargo#12749)

r? ghost
2023-10-28 03:02:07 +00:00
Weihang Lo
167c0c1b67
Update cargo 2023-10-27 21:16:41 -04:00
bors
c6eb61a97f Auto merge of #117197 - Zalathar:demangler, r=onur-ozkan
Avoid unnecessary builds/rebuilds of `rust-demangler`

This is a combination of two loosely-related changes:

- Don't build `rust-demangler` as a dependency of `tests/run-make`, because after #112300 none of the remaining run-make tests actually use it. (If future run-make tests ever do need the demangler, it'll be easy to add it back.)
- For `tests/run-coverage`, build the demangler with the stage 0 compiler instead of the current-stage compiler. This avoids having to uselessly rebuild the demangler after modifying and rebuilding the compiler itself.
2023-10-28 01:04:35 +00:00
Mu001999
fe00cfef57 restore snapshot when parse_param_general 2023-10-28 08:53:51 +08:00
bors
6f349cdbfa Auto merge of #116471 - notriddle:notriddle/js-trait-alias, r=GuillaumeGomez
rustdoc: use JS to inline target type impl docs into alias

Preview docs:

- https://notriddle.com/rustdoc-html-demo-5/js-trait-alias/std/io/type.Result.html

- https://notriddle.com/rustdoc-html-demo-5/js-trait-alias-compiler/rustc_middle/ty/type.PolyTraitRef.html

This pull request also includes a bug fix for trait alias inlining across crates. This means more documentation is generated, and is why ripgrep runs slower (it's a thin wrapper on top of the `grep` crate, so 5% of its docs are now the Result type).

- Before, built with rustdoc 1.75.0-nightly (aa1a71e9e 2023-10-26), Result type alias method docs are missing: http://notriddle.com/rustdoc-html-demo-5/ripgrep-js-nightly/rg/type.Result.html
- After, built with this branch, all the methods on Result are shown: http://notriddle.com/rustdoc-html-demo-5/ripgrep-js-trait-alias/rg/type.Result.html

*Review note: This is mostly just reverting https://github.com/rust-lang/rust/pull/115201. The last commit has the new work in it.*

Fixes #115718

This is an attempt to balance three problems, each of which would
be violated by a simpler implementation:

- A type alias should show all the `impl` blocks for the target
  type, and vice versa, if they're applicable. If nothing was
  done, and rustdoc continues to match them up in HIR, this
  would not work.

- Copying the target type's docs into its aliases' HTML pages
  directly causes far too much redundant HTML text to be generated
  when a crate has large numbers of methods and large numbers
  of type aliases.

- Using JavaScript exclusively for type alias impl docs would
  be a functional regression, and could make some docs very hard
  to find for non-JS readers.

- Making sure that only applicable docs are show in the
  resulting page requires a type checkers. Do not reimplement
  the type checker in JavaScript.

So, to make it work, rustdoc stashes these type-alias-inlined docs
in a JSONP "database-lite". The file is generated in `write_shared.rs`,
included in a `<script>` tag added in `print_item.rs`, and `main.js`
takes care of patching the additional docs into the DOM.

The format of `trait.impl` and `type.impl` JS files are superficially
similar. Each line, except the JSONP wrapper itself, belongs to a crate,
and they are otherwise separate (rustdoc should be idempotent). The
"meat" of the file is HTML strings, so the frontend code is very simple.
Links are relative to the doc root, though, so the frontend needs to fix
that up, and inlined docs can reuse these files.

However, there are a few differences, caused by the sophisticated
features that type aliases have. Consider this crate graph:

```text
 ---------------------------------
 | crate A: struct Foo<T>        |
 |          type Bar = Foo<i32>  |
 |          impl X for Foo<i8>   |
 |          impl Y for Foo<i32>  |
 ---------------------------------
     |
 ----------------------------------
 | crate B: type Baz = A::Foo<i8> |
 |          type Xyy = A::Foo<i8> |
 |          impl Z for Xyy        |
 ----------------------------------
```

The type.impl/A/struct.Foo.js JS file has a structure kinda like this:

```js
JSONP({
"A": [["impl Y for Foo<i32>", "Y", "A::Bar"]],
"B": [["impl X for Foo<i8>", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]],
});
```

When the type.impl file is loaded, only the current crate's docs are
actually used. The main reason to bundle them together is that there's
enough duplication in them for DEFLATE to remove the redundancy.

The contents of a crate are a list of impl blocks, themselves
represented as lists. The first item in the sublist is the HTML block,
the second item is the name of the trait (which goes in the sidebar),
and all others are the names of type aliases that successfully match.

This way:

- There's no need to generate these files for types that have no aliases
  in the current crate. If a dependent crate makes a type alias, it'll
  take care of generating its own docs.
- There's no need to reimplement parts of the type checker in
  JavaScript. The Rust backend does the checking, and includes its
  results in the file.
- Docs defined directly on the type alias are dropped directly in the
  HTML by `render_assoc_items`, and are accessible without JavaScript.
  The JSONP file will not list impl items that are known to be part
  of the main HTML file already.

[JSONP]: https://en.wikipedia.org/wiki/JSONP
2023-10-27 23:08:24 +00:00
Zalathar
230dd5b8c7 coverage: Consistently remove unused counter IDs from expressions/mappings 2023-10-28 09:33:48 +11:00
Zalathar
975b98b816 coverage: Regression test for #17012 (bad counter IDs in mappings) 2023-10-28 09:27:06 +11:00
Nicholas Nethercote
5438004766 Change Cfg<T> to an FxIndexSet.
Despite what I claimed in an earlier commit, the ordering does matter to
some degree. Using `FxIndexSet` prevents changes to the error message
order in `tests/ui/check-cfg/mix.rs`.
2023-10-28 09:24:32 +11:00
Nicholas Nethercote
5e54997157 Clean up config mess.
`parse_cfgspecs` and `parse_check_cfg` run very early, before the main
interner is running. They each use a short-lived interner and convert
all interned symbols to strings in their output data structures. Once
the main interner starts up, these data structures get converted into
new data structures that are identical except with the strings converted
to symbols.

All is not obvious from the current code, which is a mess, particularly
with inconsistent naming that obscures the parallel string/symbol data
structures. This commit clean things up a lot.

- The existing `CheckCfg` type is generic, allowing both
  `CheckCfg<String>` and `CheckCfg<Symbol>` forms. This is really
  useful, but it defaults to `String`. The commit removes the default so
  we have to use `CheckCfg<String>` and `CheckCfg<Symbol>` explicitly,
  which makes things clearer.

- Introduces `Cfg`, which is generic over `String` and `Symbol`, similar
  to `CheckCfg`.

- Renames some things.
  - `parse_cfgspecs` -> `parse_cfg`
  - `CfgSpecs` -> `Cfg<String>`, plus it's used in more places, rather
    than the underlying `FxHashSet` type.
  - `CrateConfig` -> `Cfg<Symbol>`.
  - `CrateCheckConfig` -> `CheckCfg<Symbol>`

- Adds some comments explaining the string-to-symbol conversions.

- `to_crate_check_config`, which converts `CheckCfg<String>` to
  `CheckCfg<Symbol>`, is inlined and removed and combined with the
  overly-general `CheckCfg::map_data` to produce
  `CheckCfg::<String>::intern`.

- `build_configuration` now does the `Cfg<String>`-to-`Cfg<Symbol>`
  conversion, so callers don't need to, which removes the need for
  `to_crate_config`.

The diff for two of the fields in `Config` is a good example of the
improved clarity:
```
-    pub crate_cfg: FxHashSet<(String, Option<String>)>,
-    pub crate_check_cfg: CheckCfg,
+    pub crate_cfg: Cfg<String>,
+    pub crate_check_cfg: CheckCfg<String>,
```
Compare that with the diff for the corresponding fields in `ParseSess`,
and the relationship to `Config` is much clearer than before:
```
-    pub config: CrateConfig,
-    pub check_config: CrateCheckConfig,
+    pub config: Cfg<Symbol>,
+    pub check_config: CheckCfg<Symbol>,
```
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
75e415ba86 Optimize parse_cfgspecs.
In `parse_cfg`, we now construct a `FxHashSet<String>` directly instead of
constructing a `FxHashSet<Symbol>` and then immediately converting it to a
`FxHashSet<String>`(!)

(The type names made this behaviour non-obvious. The next commit will
make the type names clearer.)
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
32986d895f Change CrateConfig from FxIndexSet to FxHashSet.
Because its order doesn't matter. This is well demonstrated by
`to_crate_config`, which creates a `CrateConfig` from an `FxHashSet`.
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
2142d014ab Streamline rustc_interface tests.
In `test_edition_parsing`, change the
`build_session_options_and_crate_config` call to
`build_session_options`, because the config isn't used.

That leaves a single call site for
`build_session_options_and_crate_config`, so just inline and remove it.
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
3feec48d70 Fix a comment. 2023-10-28 09:03:51 +11:00
Nicholas Nethercote
98c469ce93 Remove an unneeded dependency. 2023-10-28 09:03:51 +11:00
bors
2f1bd0729b Auto merge of #117294 - matthiaskrgr:rollup-xylsec7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116834 (Remove `rustc_symbol_mangling/messages.ftl`.)
 - #117212 (Properly restore snapshot when failing to recover parsing ternary)
 - #117246 (Fix ICE: Restrict param constraint suggestion)
 - #117247 (NVPTX: Allow PassMode::Direct for ptx kernels for now)
 - #117270 (Hide internal methods from documentation)
 - #117281 (std::thread : add SAFETY comment)
 - #117287 (fix miri target information for Test step)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-27 21:11:52 +00:00
Antoni Boucher
f0aaf2ff11 Merge commit '09ce29d0591a21e1abae22eac4d41ffd32993af8' into subtree-update_cg_gcc_2023-10-25 2023-10-27 16:07:01 -04:00
antoyo
09ce29d059
Merge pull request #375 from GuillaumeGomez/fix-build-scripts
Make build scripts work with rust bootstrap
2023-10-27 16:06:12 -04:00
Milo
a65d99d087
Update type_err_ctxt_ext.rs
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2023-10-27 20:14:49 +01:00
bjorn3
aaa4e541ee Explicitly mark which targets to distribute cg_clif for in CI
This avoids needlessly building cg_clif for other targets and makes it
easier for the dist code to determine if it should distribute cg_clif as
component.
2023-10-27 18:56:46 +00:00
bors
59bb9505bc Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJung
Allow partially moved values in match

This PR attempts to unify the behaviour between `let _ = PLACE`, `let _: TY = PLACE;` and `match PLACE { _ => {} }`.
The logical conclusion is that the `match` version should not check for uninitialised places nor check that borrows are still live.

The `match PLACE {}` case is handled by keeping a `FakeRead` in the unreachable fallback case to verify that `PLACE` has a legal value.

Schematically, `match PLACE { arms }` in surface rust becomes in MIR:
```rust
PlaceMention(PLACE)
match PLACE {
  // Decision tree for the explicit arms
  arms,
  // An extra fallback arm
  _ => {
    FakeRead(ForMatchedPlace, PLACE);
    unreachable
  }
}
```

`match *borrow { _ => {} }` continues to check that `*borrow` is live, but does not read the value.
`match *borrow {}` both checks that `*borrow` is live, and fake-reads the value.

Continuation of ~https://github.com/rust-lang/rust/pull/102256~ ~https://github.com/rust-lang/rust/pull/104844~

Fixes https://github.com/rust-lang/rust/issues/99180 https://github.com/rust-lang/rust/issues/53114
2023-10-27 18:51:43 +00:00
Camille Gillot
24be43356e
Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-10-27 20:51:25 +02:00
Matthias Krüger
b9015dab9d
Rollup merge of #117287 - onur-ozkan:fix-miri-target-info, r=RalfJung
fix miri target information for Test step

self-explanatory

r? RalfJung
2023-10-27 19:46:10 +02:00
Matthias Krüger
f9d62a84f0
Rollup merge of #117281 - RalfJung:thread-safety, r=thomcc
std::thread : add SAFETY comment

I forgot to add this in https://github.com/rust-lang/rust/pull/117266.
2023-10-27 19:46:10 +02:00
Matthias Krüger
60b071fa8a
Rollup merge of #117270 - jhpratt:hide-print-internals, r=ChrisDenton
Hide internal methods from documentation

The two methods here are perma-unstable and only made public for technical reasons. There is no reason to show them in documentation.

`@rustbot` label +A-docs
2023-10-27 19:46:09 +02:00
Matthias Krüger
c3d56be6b6
Rollup merge of #117247 - kjetilkjeka:nvptx_direct_passmode_exception, r=workingjubilee,RalfJung
NVPTX: Allow PassMode::Direct for ptx kernels for now

Upgrading the nvptx toolchain to the newest nightly makes it hit the assert that links to https://github.com/rust-lang/rust/issues/115666

It seems like most targets get around this by using `PassMode::Indirect`. That is impossible for the kernel as it's not a normal call, but instead the arguments are copied from CPU to GPU and the passed pointer would be invalid when it reached the GPU.

I also made an experiment with `PassMode::Cast` but at least the most simple version of this broke the assembly API tests.

I added  fixing the pass mode in my unofficial tracking issue list (I do not have the necessary permissions to update to official one). https://github.com/rust-lang/rust/issues/38788#issuecomment-1079021853

Since the ptx_abi is currently unstable and have been working with `PassMode::Direct` for more than a year now, the steps above is hopefully sufficient to enable it as an exception until I can prioritize to fix it. I'm currently looking at steps to enable the CI for nvptx64 again and would prefer to finish that first.
2023-10-27 19:46:09 +02:00
Matthias Krüger
a77f743239
Rollup merge of #117246 - estebank:issue-117209, r=petrochenkov
Fix ICE: Restrict param constraint suggestion

When encountering an associated item with a type param that could be constrained, do not look at the parent item if the type param comes from the associated item.

Fix #117209, fix #89868.
2023-10-27 19:46:08 +02:00
Matthias Krüger
b2295375f8
Rollup merge of #117212 - clubby789:fix-ternary-recover, r=compiler-errors
Properly restore snapshot when failing to recover parsing ternary

If the recovery parsed an expression, then failed to eat a `:`, it would return `false` without restoring the snapshot. Fix this by always restoring the snapshot when returning `false`.

Draft for now because I'd like to try and improve this recovery further.

Fixes #117208
2023-10-27 19:46:07 +02:00
Matthias Krüger
df8852a934
Rollup merge of #116834 - nnethercote:rustc_symbol_mangling, r=davidtwco
Remove `rustc_symbol_mangling/messages.ftl`.

It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.

r? `@davidtwco`
2023-10-27 19:46:06 +02:00
Esteban Küber
6dbad23641 When encountering sealed traits, point types that implement it
```
error[E0277]: the trait bound `S: d::Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:53:20
   |
LL | impl c::Sealed for S {}
   |                    ^ the trait `d::Hidden` is not implemented for `S`
   |
note: required by a bound in `c::Sealed`
  --> $DIR/sealed-trait-local.rs:17:23
   |
LL |     pub trait Sealed: self::d::Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
   = help: the following types implement the trait:
            - c::X
            - c::Y
```

The last `help` is new.
2023-10-27 17:40:52 +00:00
Esteban Küber
7449478c2f Account for type param from other item in note_and_explain
Fix #89868.
2023-10-27 16:24:01 +00:00
Ralf Jung
2ef5897a89 fix failure to detect a too-big-type after adding padding 2023-10-27 18:07:53 +02:00
bors
10143e781b Auto merge of #117166 - oli-obk:mir_const_qualif_perf, r=petrochenkov
Only call `mir_const_qualif` if absolutely necessary

Pull the perf change out of https://github.com/rust-lang/rust/pull/113617

This should not have any impact on behaviour (if it does, we'll see an ICE)
2023-10-27 16:06:02 +00:00
Guillaume Gomez
eb10fa345e Fix build scripts 2023-10-27 17:53:44 +02:00
Oli Scherer
eb66d10cc3 Fuse gen blocks 2023-10-27 15:20:44 +00:00
onur-ozkan
b915fc86ca fix miri target information for Test step
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-27 18:20:19 +03:00
bors
9d6d5d4894 Auto merge of #116751 - Nadrieril:lint-overlap-per-column, r=davidtwco
Lint overlapping ranges as a separate pass

This reworks the [`overlapping_range_endpoints`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_lint_defs/builtin/static.OVERLAPPING_RANGE_ENDPOINTS.html) lint. My motivations are:

- It was annoying to have this lint entangled with the exhaustiveness algorithm, especially wrt librarification;
- This makes the lint behave consistently.

Here's the consistency story. Take the following matches:
```rust
match (0u8, true) {
    (0..=10, true) => {}
    (10..20, true) => {}
    (10..20, false) => {}
    _ => {}
}
match (true, 0u8) {
    (true, 0..=10) => {}
    (true, 10..20) => {}
    (false, 10..20) => {}
    _ => {}
}
```
There are two semantically consistent options: option 1 we lint all overlaps between the ranges, option 2 we only lint the overlaps that could actually occur (i.e. the ones with `true`). Option 1 is what this PR does. Option 2 is possible but would require the exhaustiveness algorithm to track more things for the sake of the lint. The status quo is that we're inconsistent between the two.

Option 1 generates more false postives, but I prefer it from a maintainer's perspective. I do think the difference is minimal; cases where the difference is observable seem rare.

This PR adds a separate pass, so this will have a perf impact. Let's see how bad, it looked ok locally.
2023-10-27 14:10:42 +00:00
Ralf Jung
ccb36a688d std:🧵 add SAFETY comment 2023-10-27 15:18:32 +02:00
Oli Scherer
b8bfd08999 Rename RibKind::ClosureOrAsync to reflect how it is actually used 2023-10-27 13:05:49 +00:00
Oli Scherer
bb90c4bf35 Use targetted diagnostic for borrow across yield error 2023-10-27 13:05:49 +00:00
Oli Scherer
6223744078 Prevent generators from being movable 2023-10-27 13:05:49 +00:00
Oli Scherer
4ac25faf9f Handle move generators 2023-10-27 13:05:48 +00:00
Oli Scherer
cece90c65f Feature gate coroutine yield usage 2023-10-27 13:05:48 +00:00
Oli Scherer
2e5b36741b Demonstrate issue with yield checks 2023-10-27 13:05:48 +00:00
Oli Scherer
638d2d6fc1 Feature gate gen blocks, even in 2024 edition 2023-10-27 13:05:48 +00:00
Oli Scherer
c892b28c02 Basic generators work 2023-10-27 13:05:48 +00:00
Oli Scherer
998a816106 Make gen blocks implement the Iterator trait 2023-10-27 13:05:48 +00:00
Oli Scherer
621494382d Add gen blocks to ast and do some broken ast lowering 2023-10-27 13:05:48 +00:00
bors
688892938e Auto merge of #116858 - estebank:issue-22488, r=petrochenkov
Suggest assoc fn `new` when trying to build tuple struct with private fields

Fix #22488.
2023-10-27 12:16:01 +00:00