Commit Graph

224738 Commits

Author SHA1 Message Date
Maybe Waffle
fb0f74a8c9 Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
bors
70db836922 Auto merge of #111566 - clubby789:bootstrap-override-config, r=ozkanonur
Override config.toml options from command line

https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Running.20tests.20on.20precompiled.20rustc/near/357763280

cc `@jyn514`
2023-05-24 10:56:34 +00:00
bors
d69787f098 Auto merge of #111195 - GuillaumeGomez:fix-ice-intra-doc-link, r=petrochenkov
Prevent crash when a path is not resolved in intra-doc link

Fixes https://github.com/rust-lang/rust/issues/111189.

cc `@petrochenkov`
r? `@notriddle`
2023-05-24 07:49:53 +00:00
bors
82faf5ed60 Auto merge of #111895 - matthiaskrgr:rollup-9a6szng, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #111861 (Don't ICE on return-type notation when promoting trait preds to associated type bounds)
 - #111864 (Always require closure parameters to be `Sized`)
 - #111870 (Rename `traits_in_crate` query to `traits`)
 - #111880 (Don't ICE when computing PointerLike trait when region vars are in param-env)
 - #111887 (Add regression tests for pretty-printing inherent projections)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-24 05:07:22 +00:00
Matthias Krüger
d49d347f15
Rollup merge of #111887 - fmease:inh-proj-pp-tests, r=compiler-errors
Add regression tests for pretty-printing inherent projections

Tests for #111486.
Fixes #111879.

r? `@matthiaskrgr`
2023-05-24 06:05:39 +02:00
Matthias Krüger
8227c4fd6e
Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726
Don't ICE when computing PointerLike trait when region vars are in param-env

Fixes #111877
2023-05-24 06:05:39 +02:00
Matthias Krüger
783bea940b
Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, r=compiler-errors
Rename `traits_in_crate` query to `traits`

> NOTE: Not named just `traits` due to a naming conflict.

This can, in fact, be easily avoided.
2023-05-24 06:05:38 +02:00
Matthias Krüger
efea88ae08
Rollup merge of #111864 - Jules-Bertholet:sized-closures, r=compiler-errors
Always require closure parameters to be `Sized`

The `rust-call` ABI isn't compatible with `#![feature(unsized_fn_params)]`, so trying to use that feature with closures leads to an ICE (#67981). This turns that ICE into a type-check error.

`@rustbot` label A-closures F-unsized_fn_params
2023-05-24 06:05:38 +02:00
Matthias Krüger
224b6511b1
Rollup merge of #111861 - compiler-errors:rtn-in-super, r=jackh726
Don't ICE on return-type notation when promoting trait preds to associated type bounds

Fixes #111846
2023-05-24 06:05:37 +02:00
bors
9d826e01e8 Auto merge of #110936 - loongarch-rs:promote-tier2, r=Mark-Simulacrum
Promote loongarch64-unknown-linux-gnu to Tier 2 with host tools

This PR promotes `loongarch64-unknown-linux-gnu` to Tier 2 (with host tools).

MCP: https://github.com/rust-lang/compiler-team/issues/518
2023-05-24 02:29:47 +00:00
bors
edbd5c5a78 Auto merge of #111890 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in 09276c703a473ab33daaeb94917232e80eefd628..64fb38c97ac4d3a327fc9032c862dd28c8833b17
2023-05-16 21:43:35 +0000 to 2023-05-23 18:53:23 +0000
- Consider rust-version when selecting packages for cargo add (rust-lang/cargo#12078)
- fix(lints): Switch to -Zlints so stable projects can experiment (rust-lang/cargo#12168)
- Automatically inherit workspace fields when running cargo new/init (rust-lang/cargo#12069)
- ci: check if any version bump needed for member crates (rust-lang/cargo#12126)
- feat: `lints` feature (rust-lang/cargo#12148)
- fix: pass `-C debuginfo` after weakening if explicitly set (rust-lang/cargo#12165)
- Tweak build help to clarify role of --bin (rust-lang/cargo#12157)
- fix: Pass CI on nightly (rust-lang/cargo#12160)
- docs(source): doc comments for Source and its impls (rust-lang/cargo#12159)
- docs(source): doc comments for `Source` and friends (rust-lang/cargo#12153)

r? `@ghost`
2023-05-23 23:52:07 +00:00
León Orell Valerian Liehr
4a63b07d24
Add tests for pretty-printing inherent projections 2023-05-24 01:17:38 +02:00
Weihang Lo
17f41b2ed5
Update cargo 2023-05-23 23:20:16 +01:00
Maybe Waffle
cc1ec49a14 Rename traits_in_crate query to traits 2023-05-23 21:26:37 +00:00
bors
5ea3f0ae08 Auto merge of #111867 - RalfJung:miri, r=RalfJung
update Miri
2023-05-23 21:09:20 +00:00
bors
d5699874dc Auto merge of #111882 - matthiaskrgr:rollup-1xyv5mq, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #111427 ([rustdoc][JSON] Use exclusively externally tagged enums in the JSON representation)
 - #111486 (Pretty-print inherent projections correctly)
 - #111722 (Document stack-protector option)
 - #111761 (fix(resolve): not defined `extern crate shadow_name`)
 - #111845 (Update books)
 - #111851 (CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a))
 - #111871 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-23 18:13:36 +00:00
Matthias Krüger
f737ec40e6
Rollup merge of #111871 - GuillaumeGomez:migrate-gui-test-color-5, 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-05-23 19:53:43 +02:00
Matthias Krüger
20b6e5a1d8
Rollup merge of #111851 - rcvalle:rust-cfi-fix-111515, r=bjorn3
CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)

Fixes #111515 and complements #106547 by adding support for encoding early bound regions and also excluding projections when transforming trait objects' traits into their identities before emitting type checks.
2023-05-23 19:53:43 +02:00
Matthias Krüger
416ae3cbd0
Rollup merge of #111845 - rustbot:docs-update, r=ehuss
Update books

## rust-embedded/book

1 commits in d9eb4c3f75435b008881062ffa77bf0d1527b37d..f2aed2fe8e9f55508c86ba3aa4b6789b18a08a22
2023-05-12 12:26:37 UTC to 2023-05-12 12:26:37 UTC

- Add link to Comprehensive Rust 🦀 (rust-embedded/book#354)

## rust-lang/nomicon

2 commits in b5f7500fc40775096c2bbd204eae096612cf9047..b5f018fb5930cb733b0a8aaf2eed975d4771e74d
2023-05-19 18:10:25 UTC to 2023-05-14 20:22:16 UTC

- Expand unbounded lifetime example code and improve wording (rust-lang/nomicon#408)
- Update to 2021 edition (rust-lang/nomicon#410)

## rust-lang/reference

5 commits in 28dc0f3576b55f5e57c5d6e65cd68ba3161e9fd5..553d99b02a53b4133a40d5bd2e19958c67487c00
2023-05-22 10:50:07 UTC to 2023-05-10 01:54:07 UTC

- Update raw-dylib documentation for stabilization (rust-lang/reference#1345)
- fix a typo (rust-lang/reference#1359)
- fixed minor error in a comment that annotated output of a proc macro (rust-lang/reference#1358)
- Fix example code in `impl` docs (rust-lang/reference#1360)
- Add documentation for debugger_visualizer attribute (rust-lang/reference#1335)

## rust-lang/rustc-dev-guide

4 commits in 28dbeaf5c44bc7f5111ad412e99f2d7c5cec6c90..f1e637883fafeb83bdd5906ee7f467e4d35b7337
2023-05-18 02:44:05 UTC to 2023-05-11 09:59:23 UTC

- Add note about shell completion scripts (rust-lang/rustc-dev-guide#1686)
- filter out S-blocked issues in the "Getting Started" search (rust-lang/rustc-dev-guide#1687)
- Rename InstCombine to InstSimplify (rust-lang/rustc-dev-guide#1684)
- Use unpretty for debugging Hir (rust-lang/rustc-dev-guide#1685)
2023-05-23 19:53:42 +02:00
Matthias Krüger
37c9478b1a
Rollup merge of #111761 - bvanjoi:fix-109148, r=petrochenkov
fix(resolve): not defined `extern crate shadow_name`

Fixes https://github.com/rust-lang/rust/issues/109148

## Why does #109148 panic?

When resolving `use std::xx` it enters `visit_scopes` from `early_resolve_ident_in_lexical_scope`, and iters twice during the loop:

|iter| `scope` | `break_result` | result |
|-|-|-|-|
| 0 | `Module` pointed to root | binding pointed to `Undetermined`, so result is `None` | scope changed to `ExternPrelude` |
| 1 | `ExternPrelude` | binding pointed to `std` | - |

Then, the result of `maybe_resolve_path` is `Module(std)`, so `import.imported_module.set` is executed.

Finally, during the `finalize_import` of `use std::xx`, `resolve_path` returns `NonModule` because `Binding(Ident(std), Module(root)`'s binding points to `extern crate blah as std`, which causes the assertion to fail at `assert!(import.imported_module.get().is_none());`.

## Investigation

The question is why `#[a] extern crate blah as std` is not defined as a binding of `std::xxx`, which causes the iteration twice during `visit_scopes` when resolving `std::xxx`. Ideally, the value of `break_result.is_some()` should have been valid in the first iteration.

After debugging, I found that because `#[a] extern crate blah as std` had been dummied by `placeholder` during `collect_invocations`, so it had lost its attrs, span, etc..., so it will not be defined. However, `expand_invoc` added them back, then the next `build_reduced_graph`, `#[a] extern crate blah as std` would have been defined, so it makes the result of `resolved_path` unexpected, and the program panics.

## Try to solve

I think there has two-way to solve this issue:

- Expand invocations before the first `resolve_imports` during `fully_expand_fragment`. However, I do not think this is a good idea because it would mess up the current design.
- As my PR described: do not define to `extern crate blah as std` during the second `build_reduced_graph`, which is very easy and more reasonable.

r? `@petrochenkov`
2023-05-23 19:53:42 +02:00
Matthias Krüger
ee08dd8658
Rollup merge of #111722 - mrcnski:stack-protector-doc, r=rcvalle
Document stack-protector option

Only updated `exploit-mitigations.md` to reflect that the option exists. Removed the alternatives mentioned as they are not actually implemented yet.

As this is an unstable feature, should it be added to `unstable-book` also? [Example](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html). I didn't do that because I couldn't find the tracking issue for stack-protector. (There should be one to track stabilization of the feature, I think?)

cc `@rcvalle`
2023-05-23 19:53:41 +02:00
Matthias Krüger
221039b416
Rollup merge of #111486 - fmease:pp-inh-proj, r=petrochenkov
Pretty-print inherent projections correctly

Previously, we were trying to pretty-print inherent projections with `Printer::print_def_path` which is incorrect since
it expects the substitutions to be of a certain format (parents substs followed by own substs) which doesn't hold for
inherent projections (self type subst followed by own substs).
Now we print inherent projections manually.

Fixes #111390.
Fixes #111397.

Lacking tests! Is there a test suite / compiletest flags for the pretty-printer? In most if not all cases,
inherent projections are normalized away before they get the chance to appear in diagnostics.

If I were to create regression tests for linked issues, they would need to be `mir-opt` tests to exercise
`-Zdump-mir=all` (right?) which doesn't feel quite adequate to me.

`@rustbot` label F-inherent_associated_types
2023-05-23 19:53:41 +02:00
Matthias Krüger
d1e9910abf
Rollup merge of #111427 - LukeMathWalker:flatten, r=aDotInTheVoid
[rustdoc][JSON] Use exclusively externally tagged enums in the JSON representation

See [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.28De.29serialization.20speed.20of.20JSON.20docs) and [this issue](https://github.com/rust-lang/rust/issues/93667) for the relevant context.
2023-05-23 19:53:40 +02:00
Michael Goulet
3a2710cdb6 Don't ICE when computing PointerLike trait when region vars are in param-env 2023-05-23 17:23:30 +00:00
Jules Bertholet
5cd02eaece
Always require closure parameters to be Sized
The `rust-call` ABI isn't compatible with
`#![feature(unsized_fn_params)]`, so trying to use that feature with
closures leads to an ICE (#67981). This turns that ICE into a
type-check error.
2023-05-23 12:46:25 -04:00
Ramon de C Valle
9bbdfea23c CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)
Fixes #111515 and complements #106547 by adding support for encoding
early bound regions and also excluding projections when transforming
trait objects' traits into their identities before emitting type checks.
2023-05-23 16:44:03 +00:00
bors
52dd1cde59 Auto merge of #107294 - JamieCunliffe:neon-fp, r=Amanieu
Fix some issues with folded AArch64 features

In #91608 the `fp` feature was removed for AArch64 and folded into the `neon` feature, however disabling the `neon` feature doesn't actually disable the `fp` feature. If my understanding on that thread is correct it should do.

While doing this, I also noticed that disabling some features would disable features that it shouldn't. For instance enabling `sve` will enable `neon`, however, when disabling `sve` it would then also disable `neon`, I wouldn't expect disabling `sve` to also disable `neon`.

cc `@workingjubilee`
2023-05-23 15:30:37 +00:00
Guillaume Gomez
bcdfda1b6b Add regression test for #111189 2023-05-23 15:33:43 +02:00
Guillaume Gomez
234927e098 Ignore "non-real" type Res in rustdoc intra doc link resolution 2023-05-23 15:33:34 +02:00
Guillaume Gomez
24be25f134 Migrate GUI colors test to original CSS color format 2023-05-23 15:26:59 +02:00
bors
b08148f6a7 Auto merge of #111869 - Dylan-DPC:rollup-9pydw08, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #111461 (Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic)
 - #111579 (Also assume wrap-around discriminants in `as` MIR building)
 - #111704 (Remove return type sized check hack from hir typeck)
 - #111853 (Check opaques for mismatch during writeback)
 - #111854 (rustdoc: clean up `settings.css`)
 - #111860 (Don't ICE if method receiver fails to unify with `arbitrary_self_types`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-23 12:47:51 +00:00
Dylan DPC
c4f2a62182
Rollup merge of #111860 - compiler-errors:issue-111838, r=WaffleLapkin
Don't ICE if method receiver fails to unify with `arbitrary_self_types`

Consider:

```rust
struct Foo(u32);
impl Foo {
    fn get<R: Deref<Target=Self>>(self: R) -> u32 {
        self.0
    }
}

fn main() {
    let mut foo = Foo(1);
    foo.get::<&Foo>();
}
```

The problem here is that with `arbitrary_self_types`, we're allowed to have a method receiver that mentions generics from the method itself (`fn get<R: Deref<Target=Self>>(self: R)`). Since we don't actually take into account the user-written turbofish generics when doing method lookup (nor do we check that method predicates hold), method probing will happily infer `R = Foo` during the probe. When we later confirm the method, we do use the turbofish'd subst and instead now have that `R = &Foo`. This doesn't unify with the self type we chose during the probe, causing an ICE.

Getting this to work correctly will be difficult. Specifically, we'll need to actually pass in the turbofish generics for the method being probed for and check that the self type unifies considering those generics. This seems like a lot of work, and I'm not actually familiar with the restrictions originally called out for `#![feature(arbitrary_self_types)]`, but I think we should probably instead just deny having receivers that mention (type/const) generics that come from the method itself.

But I mostly just want to turn this ICE into an error, so I'll leave that up for later PRs.

Fixes #111838
2023-05-23 16:44:29 +05:30
Dylan DPC
32c73c23a4
Rollup merge of #111854 - notriddle:notriddle/settings-css-cleanup, r=GuillaumeGomez
rustdoc: clean up `settings.css`

An identical CSS rule was merged for settings-check, and an unneeded `position: relative` removed.
2023-05-23 16:44:28 +05:30
Dylan DPC
6583025c93
Rollup merge of #111853 - compiler-errors:opaque-check, r=oli-obk
Check opaques for mismatch during writeback

Revive #111705.

I realized that we don't need to put any substs in the writeback results since all of the hidden types have already been remapped. See the comment in `compiler/rustc_middle/src/ty/typeck_results.rs`, which should make that clear for other explorers of the codebase.

Additionally, we need to do some diagnostic stashing because the diagnostics we produce during HIR typeck is very poor and we should prefer the diagnostic that comes from MIR, if we have one.

r? `@oli-obk`
2023-05-23 16:44:28 +05:30
Dylan DPC
4b26b80dd5
Rollup merge of #111704 - compiler-errors:sized-return-cleanup, r=oli-obk
Remove return type sized check hack from hir typeck

Remove a bunch of special-cased suggestions when someone returns `-> dyn Trait` that checks for type equality, etc.

This was a pretty complex piece of code that also relied on a hack in hir typeck (see changes to `compiler/rustc_hir_typeck/src/check.rs`), and I'm not convinced that it's necessary to maintain, when all we really need to tell the user is that they should return `-> impl Trait` or `-> Box<dyn Trait>`, depending on their specific use-case.

This is necessary because we may need to move the "return type is sized" check from hir typeck to wfcheck, which does not have access to typeck results. This is a prerequisite for that, and I'm fairly confident that the diagnostics "regressions" here are not a big deal.
2023-05-23 16:44:27 +05:30
Dylan DPC
00185bec7c
Rollup merge of #111579 - scottmcm:enum-as-signed, r=oli-obk
Also assume wrap-around discriminants in `as` MIR building

Resolves this FIXME:

8d18c32b61/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs (L231)

r? `@oli-obk`
2023-05-23 16:44:27 +05:30
Dylan DPC
731c1a5592
Rollup merge of #111461 - oli-obk:crate_collision, r=petrochenkov
Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic

This was a refactoring mistake in https://github.com/rust-lang/rust/pull/109213

fixes #111284
2023-05-23 16:44:26 +05:30
WANG Rui
03b8e0341f Promote loongarch64-unknown-linux-gnu to Tier 2 with host tools
MCP: https://github.com/rust-lang/compiler-team/issues/518
2023-05-23 18:33:57 +08:00
bors
f3d597b31c Auto merge of #111807 - erikdesjardins:noalias, r=oli-obk
[rustc_ty_utils] Treat `drop_in_place`'s *mut argument like &mut when adding LLVM attributes

This resurrects PR #103614, which has sat idle for a while.

This could probably use a new perf run, since we're on a new LLVM version now.

r? `@oli-obk`
cc `@RalfJung`

---

LLVM can make use of the `noalias` parameter attribute on the parameter to `drop_in_place` in areas like argument promotion. Because the Rust compiler fully controls the code for `drop_in_place`, it can soundly deduce parameter attributes on it.

In #103957, Miri was changed to retag `drop_in_place`'s argument as if it was `&mut`, matching this change.
2023-05-23 10:12:46 +00:00
Ralf Jung
13e4766440 update lockfile 2023-05-23 12:10:18 +02:00
Oli Scherer
6d1a1cf354 Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic 2023-05-23 07:37:16 +00:00
bors
cda5becc27 Auto merge of #110519 - loongarch-rs:ci, r=Mark-Simulacrum
ci: Add support for dist-loongarch64-linux

We are preparing to promote loongarch64-unknown-linux-gnu to Tier 2, and one of the tasks is to add CI support. We are currently in the process of upgrading the dependencies for the build tools, and before this is completed, we would like to request comments. Thanks

#### Progress

- [x] Update linux-raw-sys to 0.3.2 (rust-lang/cargo#11998)
- [x] Update openssl-src to 111.25.3+1.1.1t (rust-lang/cargo#12005)
- [x] bootstrap: Update linux-raw-sys to 0.3.2 (rust-lang/rust#110516)
- [x] Update linux-raw-sys to 0.3.4 (rust-lang/rust#110518)
- [x] Update cargo (rust-lang/rust#110834)
- [x] linux_like: Add missing constants for loongarch64 (rust-lang/libc#3237)
- [x] Release 0.2.143 (rust-lang/libc#3236)
- [x] Update libc to 0.2.144 (rust-lang/cargo#12098)
- [x] Update cargo (rust-lang/rust#111456)

Tier 2 with host tools MCP: https://github.com/rust-lang/compiler-team/issues/518
2023-05-23 07:27:51 +00:00
bors
4b05125b5e Auto merge of #2900 - oli-obk:rustup, r=oli-obk
Rustup
2023-05-23 07:26:17 +00:00
Oli Scherer
90459e8173 Update to latest clippy 2023-05-23 07:25:16 +00:00
Oli Scherer
32e52e8fdd Merge from rustc 2023-05-23 06:56:31 +00:00
Oli Scherer
a43c5d8591 Preparing for merge from rustc 2023-05-23 06:56:21 +00:00
bohan
c41b2089c7 fix(resolve): not defined extern crate shadow_name 2023-05-23 13:14:34 +08:00
bors
4400d8fce7 Auto merge of #110204 - compiler-errors:new-solver-hir-typeck-hacks, r=lcnr
Deal with unnormalized projections when structurally resolving types with new solver

1. Normalize types in `structurally_resolved_type` when the new solver is enabled
2. Normalize built-in autoderef targets in `Autoderef` when the new solver is enabled
3. Normalize-erasing-regions in `resolve_type` in writeback

This is motivated by the UI test provided, which currently fails with:

```
error[E0609]: no field `x` on type `<usize as SliceIndex<[Foo]>>::Output`
 --> <source>:9:11
  |
9 |     xs[0].x = 1;
  |           ^
```

 I'm pretty happy with the approach in (1.) and (2.) and think we'll inevitably need something like this in the long-term, but (3.) seems like a hack to me. It's a *lot* of work to add tons of new calls to every user of these typeck results though (mir build, late lints, etc). Happy to discuss further.

r? `@lcnr`
2023-05-23 04:41:44 +00:00
Michael Goulet
e54bc1c5ff Don't ICE on RPITIT when promoting trait preds to associated type bounds 2023-05-23 03:43:09 +00:00
Michael Goulet
05c5caa500 Don't ICE if method receiver fails to unify with arbitrary_self_types 2023-05-23 03:23:52 +00:00