Commit Graph

231952 Commits

Author SHA1 Message Date
Ralf Jung
f887f5a9c6 std: add some missing repr(transparent) 2023-08-14 10:40:59 +02:00
bors
3071e0aef6 Auto merge of #114787 - compiler-errors:issue-114783, r=jackh726
Select obligations before processing wf obligation in `compare_method_predicate_entailment`

We need to select obligations before processing the WF obligation for the `IMPLIED_BOUNDS_ENTAILMENT` lint, since it skips over type variables.

Fixes #114783

r? `@jackh726`
2023-08-14 00:33:17 +00:00
bors
e81522aa0e Auto merge of #114742 - compiler-errors:opaques-are-not-injective, r=aliemjay
TAITs do not constrain generic params

Fixes #108425

Not sure if I should rework those two failing tests. I guess `tests/ui/type-alias-impl-trait/coherence.rs` could just have the type parameter removed from it? IDK what `tests/ui/type-alias-impl-trait/coherence_generalization.rs` is even testing, though.

r? `@aliemjay`
cc `@lcnr` `@oli-obk` (when he's back from 🌴)
2023-08-13 22:47:14 +00:00
Michael Goulet
b6b5a65ae6 Select obligations before processing wf obligation in compare_method_predicate_entailment 2023-08-13 22:22:15 +00:00
bors
1b198b3a19 Auto merge of #114786 - GuillaumeGomez:rollup-0cos5gn, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #94667 (Add `Iterator::map_windows`)
 - #114069 (Allow using external builds of the compiler-rt profile lib)
 - #114354 (coverage: Store BCB counter info externally, not directly in the BCB graph)
 - #114625 (CI: use smaller machines in PR runs)
 - #114777 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-13 20:22:36 +00:00
Guillaume Gomez
be6cda1eca
Rollup merge of #114777 - GuillaumeGomez:migrate-gui-test-color-32, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-08-13 21:00:46 +02:00
Guillaume Gomez
d868276443
Rollup merge of #114625 - klensy:ci-pr-workers, r=Mark-Simulacrum
CI: use smaller machines in PR runs

mingw-check job-linux-16c -> job-linux-4c
~job-linux-4c 20 min in auto job
~job-linux-16c 13 min in pr job
with current pr regressed to almost 21 min, it's ok.

mingw-check-tidy job-linux-16c -> job-linux-4c small enough, so reduce to minimal
~ job-linux-16c 3 min
with current pr regressed to almost 5 min, it's ok.

x86_64-gnu-tools job-linux-16c this is top job by time in PR, so don't touch it
~ job-linux-8c 1.30 hour in auto job
~ job-linux-16c 1 hour in pr job (affected by #114613, actual time ~ 30 min)

x86_64-gnu-llvm-15 job-linux-16c don't change too
~ job-linux-8c 1.30 hour in auto job
~ job-linux-16c 30 min in pr job

Noticed while working on https://github.com/rust-lang/rust/pull/114621, so current time affected by always rebuilded docker images (but pr images always rebuilded before too, so nvm)
2023-08-13 21:00:46 +02:00
Guillaume Gomez
2442c9b724
Rollup merge of #114354 - Zalathar:external-counters, r=jackh726
coverage: Store BCB counter info externally, not directly in the BCB graph

When deciding how to instrument the underlying MIR for coverage, the `InstrumentCoverage` pass builds a simplified “Basic Counter Block” graph, and then allocates coverage counters/expressions to various nodes/edges in the BCB graph as necessary. Those counters/expressions are then injected into the function's MIR.

The awkward thing here is that the code for doing this needs `&mut` access to the graph, in order to associate coverage info with individual nodes, even though it isn't making any structural changes to the graph itself. That makes it harder to understand and modify the instrumentation code.

In addition, the graph alone can't hold all the information that is needed. There ends up being an extra vector of “intermediate expressions” that needs to be passed around separately anyway.

---

This PR simplifies things by instead storing all of that temporary coverage information in a number of side-tables inside `CoverageCounters`.

This makes it easier to see all of the information produced by the make-counters step, and how it is used by the inject-into-mir step.

---

Looking at the combined changes is possible, but I recommend reviewing the commits individually, because the big changes are mostly independent of each other (despite being conceptually related).
2023-08-13 21:00:46 +02:00
Guillaume Gomez
99144c3f04
Rollup merge of #114069 - cuviper:profiler-path, r=Mark-Simulacrum
Allow using external builds of the compiler-rt profile lib

This changes the bootstrap config `target.*.profiler` from a plain bool
to also allow a string, which will be used as a path to the pre-built
profiling runtime for that target. Then `profiler_builtins/build.rs`
reads that in a `LLVM_PROFILER_RT_LIB` environment variable.
2023-08-13 21:00:45 +02:00
Guillaume Gomez
7f787e397c
Rollup merge of #94667 - frank-king:feature/iter_map_windows, r=Mark-Simulacrum
Add `Iterator::map_windows`

Tracking issue:  #87155.

This is inherited from the old PR  #82413.

Unlike #82413, this PR implements the `MapWindows` to be lazy: only when pulling from the outer iterator, `.next()` of the inner iterator will be called.

## Implementaion Steps
- [x] Implement `MapWindows` to keep the iterators' [*Laziness*](https://doc.rust-lang.org/std/iter/index.html#laziness) contract.
- [x] Fix the known bug of memory access error.
- [ ] Full specialization of iterator-related traits for `MapWindows`.
    - [x] `Iterator::size_hint`,
    - [x] ~`Iterator::count`~,
    - [x] `ExactSizeIterator` (when `I: ExactSizeIterator`),
    - [x] ~`TrustedLen` (when `I: TrustedLen`)~,
    - [x] `FusedIterator`,
    - [x] ~`Iterator::advance_by`~,
    - [x] ~`Iterator::nth`~,
    - [ ] ...
- [ ] More tests and docs.

## Unresolved Questions:
- [ ] Is there any more iterator-related traits should be specialized?
- [ ] Is the double-space buffer worth?
- [ ] Should there be `rmap_windows` or something else?
- [ ] Taking GAT for consideration, should the mapper function be `FnMut(&[I::Item; N]) -> R` or something like `FnMut(ArrayView<'_, I::Item, N>) -> R`? Where `ArrayView` is mentioned in https://github.com/rust-lang/generic-associated-types-initiative/issues/2.
    - It can save memory, only the same size as the array window is needed,
    - It is more efficient, which requires less data copies,
    - It is possibly compatible with the GATified version of `LendingIterator::windows`.
    - But it prevents the array pattern matching like `iter.map_windows(|_arr: [_; N]| ())`, unless we extend the array pattern to allow matching the `ArrayView`.
2023-08-13 21:00:44 +02:00
bors
ebbd7154a7 Auto merge of #114480 - ozkanonur:fix-stage0-compiler-llvm, r=Mark-Simulacrum
copy the correct version of LLVM into the stage0 sysroot

In some cases(see https://github.com/rust-lang/rust/issues/109314), when the stage0
compiler relies on more recent version of LLVM than the beta compiler, it may not
be able to locate the correct LLVM in the sysroot. This situation typically occurs
when we upgrade LLVM version while the beta compiler continues to use an older version.

Fixes #109314
2023-08-13 18:36:44 +00:00
bors
644e8068cb Auto merge of #113722 - bjorn3:allocator_shim_refactor, r=jackh726
Extract a create_wrapper_function for use in allocator shim writing

This deduplicates some logic and makes it easier to follow what wrappers are produced. In the future it may allow moving the code to determine which wrappers to create to cg_ssa.
2023-08-13 16:49:49 +00:00
bors
2b26bf5894 Auto merge of #114758 - fmease:fix-nice-re-err-ice-gci, r=cjgillot
Don't crash when reporting nice region errors for generic const items

Fixes #114714.
2023-08-13 14:30:49 +00:00
bors
570601f0aa Auto merge of #114757 - Urgau:transmute-with-invalid_reference_casting, r=est31
Also consider `mem::transmute` with the `invalid_reference_casting` lint

This PR extend the `invalid_reference_casting` lint with regard to the `std::mem::transmute` function.

```
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
  --> $DIR/reference_casting.rs:27:16
   |
LL |     let _num = &mut *std::mem::transmute::<_, *mut i32>(&num);
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

*I encourage anyone reviewing this PR to do so [without whitespaces](https://github.blog/2011-10-21-github-secrets/#whitespace).*
2023-08-13 12:46:00 +00:00
bors
5f3abbc52f Auto merge of #114723 - petrochenkov:noplugin2, r=davidtwco
rustc: Move `features` from `Session` to `GlobalCtxt`

Removes one more piece of mutable state.
Follow up to #114622.

The rule I used for passing feature in function signatures:
- if a crate already depends on `rustc_middle`, then `Session` is replaced with `TyCtxt`
- otherwise session and features are passed as a pair `sess: &Session, features: &Features`

The code in `rustc_lint` is ultimately used for implementing a trait from `rustc_expand`, so it also doesn't use tcx despite the dependency on `rustc_middle`.
2023-08-13 10:59:36 +00:00
Guillaume Gomez
245d35168b Migrate GUI colors test to original CSS color format 2023-08-13 11:40:23 +02:00
bors
1702d0fffc Auto merge of #114773 - weihanglo:update-cargo, r=weihanglo
Update cargo

21 commits in d78bbf4bde3c6b95caca7512f537c6f9721426ff..7e9de3f4ec3708f500bec142317895b96131e47c
2023-08-03 12:58:25 +0000 to 2023-08-13 00:47:32 +0000
- feat: remove `--keep-going` from `cargo test/bench` (rust-lang/cargo#12478)
- chore: window-sys should be a platform-specific dependency (rust-lang/cargo#12483)
- docs: make the env var source of rerun-if-env-changed clearer (rust-lang/cargo#12482)
- doc: note the backward compatible `.cargo/credential` file exists (rust-lang/cargo#12479)
- Fix elided lifetime in associated const (rust-lang/cargo#12475)
- prompt the use of `--nocapture` flag if `cargo test` process is terminated via a signal. (rust-lang/cargo#12463)
- cargo-credential: reset stdin & stdout to the Console (rust-lang/cargo#12469)
- Fix cargo remove incorrectly removing used patches (rust-lang/cargo#12454)
- chore(gh): Expand update window (rust-lang/cargo#12466)
- Fix panic when enabling http.debug for certain strings (rust-lang/cargo#12468)
- fix(cli): Make `--help` easier to browse (rust-lang/cargo#11905)
- fix: preserve jobserver file descriptors on rustc invocation to get `TargetInfo` (rust-lang/cargo#12447)
- refactor: migrate to `tracing` (rust-lang/cargo#12458)
- docs: add example for cargo-credential (rust-lang/cargo#12461)
- Bail out an error when using cargo:: in custom build script (rust-lang/cargo#12332)
- Fix printing multiple warning messages for unused fields in [registries] table (rust-lang/cargo#12439)
- Update windows dependencies (rust-lang/cargo#12453)
- Rustfmt a let-else statement (rust-lang/cargo#12451)
- Add allow(internal_features) (rust-lang/cargo#12450)
- Update pretty_env_logger to 0.5 (rust-lang/cargo#12445)
- Remove build metadata from libgit2-sys dependency (rust-lang/cargo#12444)

r? `@ghost`
2023-08-13 09:13:31 +00:00
bors
bd54536e12 Auto merge of #114732 - gurry:issue-114683, r=compiler-errors
Fix typo in suggest.rs where f32 was used instead of f64

Fixes #114683
2023-08-13 07:31:48 +00:00
Weihang Lo
ce9bdb1804
Update cargo 2023-08-13 07:09:33 +01:00
bors
7455aa5395 Auto merge of #114457 - lcnr:trait_ref_is_knowable-normalize, r=compiler-errors
normalize in `trait_ref_is_knowable` in new solver

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/51

Alternatively we could avoid normalizing the self type and do this at the end of the `assemble_candidates_via_self_ty` stack by splitting candidates into:
- applicable without normalizing self type
- applicable for aliases, even if they can be normalized
- applicable for stuff which cannot get normalized further

I don't think this would have any significant benefits and it also seems non-trivial to avoid normalizing only the self type in `trait_ref_is_knowable`.

r? `@compiler-errors`
2023-08-13 05:18:27 +00:00
bors
cb0c29978b Auto merge of #114755 - GuillaumeGomez:migrate-gui-test-color-31, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-08-13 03:32:46 +00:00
Zalathar
5ca30c4646 Store BCB counters externally, not directly in the BCB graph
Storing coverage counter information in `CoverageCounters` has a few advantages
over storing it directly inside BCB graph nodes:

- The graph doesn't need to be mutable when making the counters, making it
easier to see that the graph itself is not modified during this step.

- All of the counter data is clearly visible in one place.

- It becomes possible to use a representation that doesn't correspond 1:1 to
graph nodes, e.g. storing all the edge counters in a single hashmap instead of
several.
2023-08-13 12:18:06 +10:00
Zalathar
5302c9d451 Accumulate intermediate expressions into CoverageCounters
This avoids the need to pass around a separate vector to accumulate into, and
avoids the need to create a fake empty vector when failure occurs.
2023-08-13 12:18:06 +10:00
Zalathar
c74db79c3b Rename helper struct BcbCounters to MakeBcbCounters
This avoids confusion with data structures that actually hold BCB counter
information.
2023-08-13 12:18:06 +10:00
bors
49af618ef9 Auto merge of #114739 - lcnr:int-infer-impls, r=compiler-errors
remove builtin `Copy` and `Clone` impl for float and int infer

it's only change is whether `{integer}: Copy` is ambiguous, this has the following properties

- these goals get proven earlier, potentially resulting in slightly better perf
- it causes inconsistent behavior and ICE if there do not exist impls for all integers, causing issues when using `#[no_core]`
- it means `Clone` has user-facing differences from other traits from `core` with the new solver because it can potentially guide inference there
- it's just very sus™ to have a builtin impl which applies during type inference but not afterwards
2023-08-13 00:05:53 +00:00
bors
28eb857b95 Auto merge of #114763 - Kobzol:fix-ci-docker-caching, r=Mark-Simulacrum
CI: fix Docker layer caching

As reported by `@klensy` on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/docker.20images.20always.20rebuilded), Github Actions have recently updated their Docker version from 20.x to 23.x, which enabled the BuildKit build backend by default.

This broke our way of performing Docker layer caching on CI, which immediately made all non-PR CI builds (including try builds) ~1 hour longer (Docker caching didn't work on PR builds before, so it wasn't affected). The moment this started happening can be seen [here](https://github.com/rust-lang-ci/rust/actions?page=2&query=branch%3Aauto+is%3Asuccess).

The problem is with the following command:
```
docker history -q rust-ci | \
          grep -v missing | \
          xargs docker save | \
          gzip | \
          $upload
```
which returns the intermediate layers as `<missing>`, if BuildKit is enabled. This was investigated by `@klensy` in https://github.com/rust-lang/rust/pull/114621. Thanks for that!

I will continue experimenting with how we can enable the cache with BuildKit in https://github.com/rust-lang/rust/pull/114762, but for the time being, I think that we should just hotfix this.

This PR reverts the build backend back to the old one, which fixes the caching. However, we also have to bust the cache of all Dockerfiles, otherwise caching would only start kicking in for them the next time they are updated (or the next time GH updates their docker version). Because when the Docker version was updated the last time, the Dockerfiles were cached on S3 with basically an empty cache, and unless we bust it, even after reverting to the old build engine, the CI script would just download the empty cache and rebuild the Dockerfile from scratch, thus nullifying our fix.

r? `@Mark-Simulacrum`
2023-08-12 20:27:03 +00:00
lcnr
51762886f6 lower evaluate_goal stability check to warn 2023-08-12 20:37:53 +02:00
lcnr
9eeaf1fd13 normalize in trait_ref_is_knowable in new solver 2023-08-12 20:37:53 +02:00
bors
cbb48a5e93 Auto merge of #114756 - matthiaskrgr:rollup-4m7l4p6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #94455 (Partially stabilize `int_roundings`)
 - #114132 (Better Debug for Vars and VarsOs)
 - #114584 (E0277 nolonger points at phantom `.await`)
 - #114667 (Record binder for bare trait object in LifetimeCollectVisitor)
 - #114692 (downgrade `internal_features` to warn)
 - #114703 (Cover ParamConst in smir)
 - #114734 (Mark oli as "on vacation")

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-12 17:51:16 +00:00
Michael Goulet
5c95e7743b Fix tests
Co-authored-by: Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
2023-08-12 17:18:46 +00:00
Michael Goulet
d0c826cfc2 Opaques do not constrain generic params 2023-08-12 17:14:13 +00:00
Jakub Beránek
6ca13d051b
CI: fix Docker layer caching 2023-08-12 18:55:13 +02:00
bors
1e836d12d3 Auto merge of #114710 - Urgau:fix-expect-dead_code-114557, r=cjgillot
Respect `#[expect]` the same way `#[allow]` is with the `dead_code` lint

This PR makes the `#[expect]` attribute being respected in the same way the `#[allow]` attribute is with the `dead_code` lint.

The fix is much more involved than I would have liked (and it's not because I didn't tried!), because the implementation took advantage of the fact that firing a lint in a allow context is a nop (for the user, as the lint is suppressed) to not fire-it at all.

And will it's fine for `#[allow]`, it definitively isn't for `#[expect]`, as the presence and absence of the lint is significant. So a big part of the PR is just adding the context information of whenever an item is on the worklist because of an `[allow]`/`#[expect]` or not.

Fixes https://github.com/rust-lang/rust/issues/114557
2023-08-12 15:14:42 +00:00
León Orell Valerian Liehr
1a18158891
Don't crash when reporting nice region errors for generic const items 2023-08-12 15:34:28 +02:00
Urgau
b517dd5bc9 Also consider transmute with the invalid_reference_casting lint 2023-08-12 13:05:44 +02:00
Matthias Krüger
cf9081c0a1
Rollup merge of #114734 - oli-obk:vacation_time, r=oli-obk
Mark oli as "on vacation"
2023-08-12 12:06:37 +02:00
Matthias Krüger
1d0792bd80
Rollup merge of #114703 - ouz-a:smir_allocation, r=oli-obk
Cover ParamConst in smir

Others variants won't be useful for a while or ever(?), but we might need this one.

r? ````@oli-obk````
2023-08-12 12:06:37 +02:00
Matthias Krüger
70cd8d5f3f
Rollup merge of #114692 - lcnr:internal_features-warn, r=Nilstrieb
downgrade `internal_features` to warn

Not sure if this requires an FCP or whatever. By having the lint as deny I need to modify test cases when testing them outside of the test suite as the test suite implicitly allows the lint. This takes maybe 10 to 20 seconds per test, but given just how frequently I end up copying tests to different repos it's a significant annoyance.

r? `@Nilstrieb`
2023-08-12 12:06:36 +02:00
Matthias Krüger
a12c329b35
Rollup merge of #114667 - compiler-errors:issue-114664, r=davidtwco
Record binder for bare trait object in LifetimeCollectVisitor

The `LifetimeCollectVisitor` had a bug where it was not recording the binder of bate trait objects. This was uncovered in #114487, when I changed opaque type lowering to ICE if it encountered a captured fresh lifetime with no def-id to map back to: https://github.com/rust-lang/rust/pull/114487/files#diff-ad0c15bbde97a607d4758ec7eaf88248be5d6b8ae084dfc84127f81e3f7a9bb4R1585

Fixes #114664
2023-08-12 12:06:36 +02:00
Matthias Krüger
83756d97a8
Rollup merge of #114584 - darklyspaced:master, r=cjgillot
E0277 nolonger points at phantom `.await`

fixes #113203
2023-08-12 12:06:35 +02:00
Matthias Krüger
8a997b159c
Rollup merge of #114132 - tamird:better-env-debug-impls, r=Amanieu
Better Debug for Vars and VarsOs

Display actual vars instead of two dots.

The same was done for Args and ArgsOs in 275f9a04af.
2023-08-12 12:06:35 +02:00
Matthias Krüger
9aea966e4b
Rollup merge of #94455 - jhpratt:stabilize-int_roundings, r=joshtriplett
Partially stabilize `int_roundings`

This stabilizes the following:

```rust
impl uX {
    pub const fn div_ceil(self, rhs: Self) -> Self;
    pub const fn next_multiple_of(self, rhs: Self) -> Self;
    pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>;
}
```

This feature is tracked in #88581.
2023-08-12 12:06:35 +02:00
Guillaume Gomez
611c0ea21c Migrate GUI colors test to original CSS color format 2023-08-12 12:05:13 +02:00
bors
f1b854818d Auto merge of #109356 - jackh726:issue-108544, r=lcnr
Only check outlives goals on impl compared to trait

Fixes #108544

r? `@compiler-errors`
2023-08-12 10:02:45 +00:00
Jacob Pratt
62ca5aa8e4
Remove unnecessary feature gates 2023-08-12 00:21:04 -04:00
Jacob Pratt
7f08376964
Partially stabilize #![feature(int_roundings)] 2023-08-12 00:12:11 -04:00
Jack Huey
3028dc4ef7 Only check outlives goals on impl compared to trait 2023-08-11 21:09:17 -04:00
bors
b08dd92552 Auto merge of #114720 - scottmcm:better-sub, r=workingjubilee
Tell LLVM that the negation in `<*const T>::sub` cannot overflow

Today it's just `sub` <https://rust.godbolt.org/z/8EzEPnMr5>; with this PR it's `sub nsw`.
2023-08-11 23:40:33 +00:00
bors
a6f8aa5a09 Auto merge of #114735 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-08-11 20:02:14 +00:00
lcnr
bb76fde734 remove builtin impl for float and int infer 2023-08-11 19:08:11 +02:00