Commit Graph

222458 Commits

Author SHA1 Message Date
whtahy
314126257d add known-bug test for unsound issue 98117 2023-04-22 13:31:00 -04:00
whtahy
3c5de9a2e8 add known-bug test for unsound issue 85099 2023-04-22 00:51:49 -04:00
whtahy
be68c69e71 add known-bug test for unsound issue 84591 2023-04-22 00:47:07 -04:00
whtahy
cac62ab2dd add known-bug test for unsound issue 84533 2023-04-22 00:47:07 -04:00
whtahy
fbfb620de8 add known-bug test for unsound issue 84366 2023-04-22 00:47:07 -04:00
whtahy
232d685e61 add known-bug test for unsound issue 57893 2023-04-22 00:47:07 -04:00
whtahy
2fb20985a0 add known-bug test for unsound issue 49206 2023-04-22 00:47:07 -04:00
whtahy
adb5ded7a7 add known-bug test for unsound issue 25860 2023-04-22 00:47:07 -04:00
bors
80a2ec49a4 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
bors
0fd50f3e01 Auto merge of #110653 - weihanglo:update-cargo, r=weihanglo
Update cargo

14 commits in d0a4cbcee614fdb7ba66e860e603a00a644d71f8..de80432f04da61d98dcbbc1572598071718ccfd2
2023-04-16 17:42:50 +0000 to 2023-04-21 13:18:32 +0000
- Bump to 0.72.0; update changelog (rust-lang/cargo#12012)
- Remove `src/doc` from `exclude` list in Cargo.toml (rust-lang/cargo#12000)
- `--help` output use line wrap (rust-lang/cargo#12013)
- Fix semver checks for 1.69 (rust-lang/cargo#12011)
- Update contributor guide with new issue labels. (rust-lang/cargo#12003)
- Better error message when getting an empty dep table (rust-lang/cargo#11997)
- Fix broken links in contributor guide. (rust-lang/cargo#12002)
- Update linux-raw-sys to 0.3.2 (rust-lang/cargo#11998)
- chore: Use globs for workspace members (rust-lang/cargo#11996)
- fix: Allow win/mac credential managers to build on all platforms (rust-lang/cargo#11993)
- Add S-triage auto-label. (rust-lang/cargo#11995)
- ci: check if Cargo.lock is up-to-date (rust-lang/cargo#11994)
- Recompile on profile rustflags changes (rust-lang/cargo#11981)
- Clarify some 1.69 changelog entries. (rust-lang/cargo#11982)
2023-04-21 21:54:27 +00:00
bors
fec9adcdbc Auto merge of #110648 - Dylan-DPC:rollup-em3ovcq, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #110333 (rustc_metadata: Split `children` into multiple tables)
 - #110501 (rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence)
 - #110608 (Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`)
 - #110632 (Panic instead of truncating if the incremental on-disk cache is too big)
 - #110633 (More `mem::take` in `library`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-21 19:43:11 +00:00
Weihang Lo
2e2cee537d
Update cargo 2023-04-21 20:14:02 +01:00
bors
fa4cc63a6b Auto merge of #110107 - cjgillot:const-prop-lint-junk, r=oli-obk
Ensure mir_drops_elaborated_and_const_checked when requiring codegen.

mir_drops_elaborated_and_const_checked may emit errors while codegen has started, and the compiler would exit leaving object code files around.

Found by `@cuviper` in https://github.com/rust-lang/rust/issues/109731
2023-04-21 17:28:37 +00:00
Camille GILLOT
7e214bfc8a Do not rely on exact error code. 2023-04-21 16:14:44 +00:00
Camille GILLOT
9f7e256ae7 Bless miri. 2023-04-21 16:14:44 +00:00
Camille GILLOT
ed7e50e08b Ensure mir_drops_elaborated_and_const_checked when requiring codegen. 2023-04-21 16:14:43 +00:00
DrMeepster
99abe44135
rustfmt fmt 2023-04-21 08:59:30 -07:00
bors
4a03f14b09 Auto merge of #110569 - saethlin:mir-pass-cooperation, r=cjgillot
Deduplicate unreachable blocks, for real this time

In https://github.com/rust-lang/rust/pull/106428 (in particular 41eda69516) we noticed that inlining `unreachable_unchecked` can produce duplicate unreachable blocks. So we improved two MIR optimizations: `SimplifyCfg` was given a simplify to deduplicate unreachable blocks, then `InstCombine` was given a combiner to deduplicate switch targets that point at the same block. The problem is that change doesn't actually work.

Our current pass order is
```
SimplifyCfg (does nothing relevant to this situation)
Inline (produces multiple unreachable blocks)
InstCombine (doesn't do anything here, oops)
SimplifyCfg (produces the duplicate SwitchTargets that InstCombine is looking for)
```

So in here, I have factored out the specific function from `InstCombine` and placed it inside the simplify that produces the case it is looking for. This should ensure that it runs in the scenario it was designed for.

Fixes https://github.com/rust-lang/rust/issues/110551
r? `@cjgillot`
2023-04-21 15:08:02 +00:00
Dylan DPC
482e407a1f
Rollup merge of #110633 - scottmcm:more-take, r=thomcc
More `mem::take` in `library`

A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-21 20:35:29 +05:30
Dylan DPC
1d1453a2f6
Rollup merge of #110632 - saethlin:panic-if-dep-graph-too-big, r=lcnr
Panic instead of truncating if the incremental on-disk cache is too big

It seems _unlikely_ that anyone would hit this truncation, but if this `as` does actually truncate, that seems incredibly bad.
2023-04-21 20:35:29 +05:30
Dylan DPC
f971264fd7
Rollup merge of #110608 - a1phyr:specialize_io_methods, r=thomcc
Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`

This improves implementation of:
- `<&[u8]>::read_to_string`
- `VecDeque<u8>::read_to_end`
- `VecDeque<u8>::read_to_string`
- `VecDeque<u8>::write_vectored`
2023-04-21 20:35:28 +05:30
Dylan DPC
fbc905e16a
Rollup merge of #110501 - notriddle:notriddle/ice-110495, r=petrochenkov
rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence

Fixes #110495
2023-04-21 20:35:28 +05:30
Dylan DPC
ff4a5fbbe5
Rollup merge of #110333 - petrochenkov:notagain, r=compiler-errors
rustc_metadata: Split `children` into multiple tables

instead of merging everything into a single bag.

If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21 20:35:27 +05:30
bors
409661936f Auto merge of #110542 - petrochenkov:qcstore4, r=cjgillot
resolve: Remove `module_children_untracked`

One of the expensive spans in `ModChild` was removed in https://github.com/rust-lang/rust/pull/109772, so let's try again.
2023-04-21 12:57:31 +00:00
Vadim Petrochenkov
cbc6ccb191 rustc_metadata: Split children into multiple tables
instead of merging everything into a single bag.

If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21 14:38:59 +03:00
bors
1151ea6006 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov
Added byte position range for `proc_macro::Span`

Currently, the [`Debug`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#impl-Debug-for-Span) implementation for [`proc_macro::Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) calls the debug function implemented in the trait implementation of `server::Span` for the type `Rustc` in the `rustc-expand` crate.

The current implementation, of the referenced function, looks something like this:
```rust
fn debug(&mut self, span: Self::Span) -> String {
    if self.ecx.ecfg.span_debug {
        format!("{:?}", span)
    } else {
        format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
    }
}
```

It returns the byte position of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) as an interpolated string.

Because this is currently the only way to get a spans position in the file, I might lead someone, who is interested in this information, to parsing this interpolated string back into a range of bytes, which I think is a very non-rusty way.

The proposed `position()`, method implemented in this PR, gives the ability to directly get this info.
It returns a [`std::ops::Range`](https://doc.rust-lang.org/std/ops/struct.Range.html#) wrapping the lowest and highest byte of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#).

I put it behind the `proc_macro_span` feature flag because many of the other functions that have a similar footprint also are annotated with it, I don't actually know if this is right.

It would be great if somebody could take a look at this, thank you very much in advanced.
2023-04-21 10:47:27 +00:00
DrMeepster
a642563d49 major test improvements 2023-04-21 02:45:48 -07:00
DrMeepster
3206960ec6 minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster
f92294f76b bless 2023-04-21 02:14:03 -07:00
DrMeepster
2bcb018253 fmt 2023-04-21 02:14:03 -07:00
DrMeepster
631ea7cc15 use P<[Ident]> instead of Vec<Ident> 2023-04-21 02:14:03 -07:00
DrMeepster
b92c2f792c fix incorrect param env in dead code lint 2023-04-21 02:14:03 -07:00
DrMeepster
b95852b93c test improvements 2023-04-21 02:14:03 -07:00
DrMeepster
61f23e0003 intern offsetof fields 2023-04-21 02:14:03 -07:00
DrMeepster
511e457c4b offset_of 2023-04-21 02:14:02 -07:00
bors
1f5768bc67 Auto merge of #96840 - cjgillot:query-feed, r=oli-obk
Allow to feed a value in another query's cache and remove `WithOptConstParam`

I used it to remove `WithOptConstParam` queries, as an example.

The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`.

There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle.  The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`.

When replayed, we may the following cases:
- `typeck` is green, in that case `type_of` is green too, and all is right;
- `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash;
- `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`.

As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly.

There is an open question about loading from the on-disk cache.  If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour.

I specifically allowed to feed the value to `type_of` from inside a call to `type_of`.  In that case, the dep-graph will check that the fingerprints of both values match.

This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`.  The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`.  The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-21 08:04:58 +00:00
bors
b92a41c676 Auto merge of #110636 - matthiaskrgr:rollup-faa33c6, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110365 (ship tools with sysroot)
 - #110555 (Substitute missing trait items suggestion correctly)
 - #110578 (fix(error): normalize whitespace during msg_to_buffer)
 - #110597 (remove unused ftl messages)
 - #110611 (Add regression test for #46506)
 - #110618 (Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-21 05:54:13 +00:00
Matthias Krüger
77de5f0754
Rollup merge of #110618 - compiler-errors:eval-ctxt-tainted, r=BoxyUwU
Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after

Just some additional protection against missing probes or strange candidate assembly behavior in the new solver.

For background, we don't ever want to call `evaluate_added_goals_and_make_canonical_response` if a previous call to `try_evaluate_added_goals` has bailed with `NoSolution`, since our nested goals are left in an undefined state at that point. This most commonly suggests a missing `EvalCtxt::probe`, but could also signify some other shenanigans like dropping a `QueryResult` on the floor without properly `?`'ing it.

r? `@lcnr`
2023-04-21 06:44:31 +02:00
Matthias Krüger
ea01135f67
Rollup merge of #110611 - GuillaumeGomez:regression-test-pub-reexport-pub-reexport, r=notriddle
Add regression test for #46506

Fixes #46506.

This issue was fixed very likely alongside the others when we cleaned up the re-exports code.

r? `@notriddle`
2023-04-21 06:44:31 +02:00
Matthias Krüger
a8e239468b
Rollup merge of #110597 - lcnr:not-pin-via-negative-bound, r=compiler-errors
remove unused ftl messages

r? `@davidtwco`

does it make sense to check via tidy that there exist no ftl message names which are never mentioned in `compiler/**.rs`
2023-04-21 06:44:30 +02:00
Matthias Krüger
637d9ddc35
Rollup merge of #110578 - bvanjoi:fix-issue-110547, r=jackh726
fix(error): normalize whitespace during msg_to_buffer

close https://github.com/rust-lang/rust/issues/110547
2023-04-21 06:44:30 +02:00
Matthias Krüger
7d046551a7
Rollup merge of #110555 - compiler-errors:subst-missing-trait-items, r=cjgillot
Substitute missing trait items suggestion correctly

Properly substitute missing item suggestions, so that when they reference generics from their parent trait they actually have the right time for the impl.

Also, some other minor tweaks like using `/* Type */` to signify a GAT's type is actually missing, and fixing generic arg suggestions for GATs in general.
2023-04-21 06:44:29 +02:00
Matthias Krüger
f2321ecce5
Rollup merge of #110365 - ozkanonur:ship-tools-with-sysroot, r=jyn514
ship tools with sysroot

Provides tool binaries under the sysroot which can be used/tested with `cargo +custom-toolchain $tool`

Clippy and fmt works without any problem.

But can't say the same for miri:

```sh
  ~/devspace/.other/chunk-list  stable $ cargo +stage2 miri setup
Running `"rustup" "component" "add" "rust-src"` to install the `rust-src` component for the selected toolchain.
error: stage2 is a custom toolchain
fatal error: failed to install the `rust-src` component for the selected toolchain
```

it's looking for `$sysroot/lib/rustlib/src/rust/library` and that simply doesn't exists for `x build`.

cc `@jyn514` (I thought you might be interested on this, since you did few review iterations on previous PRs of adding tools to sysroot)

--

**Update**

Now we are able to use `miri` as well.

After running `x b miri cargo-miri --stage 2`, I am able to run `cargo +stage2 miri setup` which works as expected.

Resolves #110625
Resolves #97762
Resolves #81431
2023-04-21 06:44:29 +02:00
bors
77778e075d Auto merge of #110431 - jsoref:spelling-src-etc, r=Mark-Simulacrum
Spelling src etc

The various src/* items seem slightly disparate, so I'm doing src/* individually.

split from https://github.com/rust-lang/rust/pull/110392
2023-04-21 03:42:19 +00:00
Scott McMurray
8055bb87c5 More mem::take in library
A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-20 19:54:46 -07:00
bors
8d09b8e206 Auto merge of #110370 - c410-f3r:dqewdas, r=petrochenkov
Move test files

r? `@petrochenkov`
2023-04-21 01:26:57 +00:00
Ben Kimock
010deb5ba3 Panic instead of truncating if the dep graph is too big 2023-04-20 21:12:39 -04:00
Ben Kimock
8ec49ad19a Run combine_duplicate_switch_targets after the simplification that produces them 2023-04-20 20:40:01 -04:00
bohan
a2f275da51 fix(error): normalize whitespace during msg_to_buffer 2023-04-21 08:40:00 +08:00
bors
d19b64fb54 Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Enable flatten-format-args by default.

Part of https://github.com/rust-lang/rust/issues/99012.

This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824:

> This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:
>
> ```rust
> println!("Hello, {}!", "World");
> println!("Hello, World!");
> ```
>
> ```rust
> println!("[info] {}", format_args!("error"));
> println!("[info] error");
> ```
>
> ```rust
> println!("[{}] {}", status, format_args!("error: {}", msg));
> println!("[{}] error: {}", status, msg);
> ```
>
> ```rust
> println!("{} + {} = {}", 1, 2, 1 + 2);
> println!("1 + 2 = {}", 1 + 2);
> ```
>
> And so on.
>
> This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.
>
> It also means that `dbg!(x)` will have its file, line, and expression name inlined:
>
> ```rust
> eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
> eprintln!("[example.rs:1] x = {:#?}", x); // after
> ```
>
> Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.

This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str).

In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change:

```rust
assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged.
assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before!
```
2023-04-20 23:19:19 +00:00