Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #120709

Closed
wants to merge 39 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

clubby789 and others added 30 commits January 14, 2024 12:31
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
When encountering

```rust
fn f<T>(a: T, b: T) -> std::cmp::Ordering {
    a.cmp(&b) //~ ERROR E0599
}
```

output

```
error[E0599]: no method named `cmp` found for type parameter `T` in the current scope
  --> $DIR/method-on-unbounded-type-param.rs:2:7
   |
LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering {
   |      - method `cmp` not found for this type parameter
LL |     a.cmp(&b)
   |       ^^^ method cannot be called on `T` due to unsatisfied trait bounds
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix rust-lang#120186.
When a method not found on a type parameter could have been provided by any
of multiple traits, suggest each trait individually, instead of a single
suggestion to restrict the type parameter with *all* of them.

Before:

```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
  --> $DIR/method-on-unbounded-type-param.rs:5:10
   |
LL |     (&a).cmp(&b)
   |          ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `T: Ord`
           which is required by `&T: Ord`
           `&T: Iterator`
           which is required by `&mut &T: Iterator`
           `T: Iterator`
           which is required by `&mut T: Iterator`
help: consider restricting the type parameters to satisfy the trait bounds
   |
LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord {
   |                                           +++++++++++++++++++++++++
```

After:

```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
  --> $DIR/method-on-unbounded-type-param.rs:5:10
   |
LL |     (&a).cmp(&b)
   |          ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `T: Ord`
           which is required by `&T: Ord`
           `&T: Iterator`
           which is required by `&mut &T: Iterator`
           `T: Iterator`
           which is required by `&mut T: Iterator`
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix rust-lang#108428.
HIR visitor visits import paths once per resolution, so if some import has an empty resolution list, like in case of import list stems, its path stays unvisited.
…li-obk

unstably allow constants to refer to statics and read from immutable statics

I am not aware of any fundamental reason why we cannot allow constants to mention statics. What we really need is that constants do not *read from* statics that can change their value:
- This would break the principle that "constants behave as-if their expression was inlined everywhere and executed at runtime". This is enforced by halting const-eval interpretation when a read from a mutable global occurs.
- When building a valtree we want to be sure that the constant and everything it refers to is truly immutable. This is enforced by aborting valtree construction when a read from a mutable global occurs.

r? `@oli-obk` -- if you are okay with experimenting with this feature, I will create a tracking issue.
Based on and blocked on rust-lang#119044; only the last commit is new.
…e, r=compiler-errors

Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items

Fixes rust-lang#109596
Fixes rust-lang#119936
…rrors

hir: Make sure all `HirId`s have corresponding HIR `Node`s

And then remove `tcx.opt_hir_node(hir_id)` in favor of `tcx.hir_node(hir_id)`.
pattern_analysis: use a plain `Vec` in `DeconstructedPat`

The use of an arena-allocated slice in `DeconstructedPat` dates to when we needed the arena anyway for lifetime reasons. Now that we don't, I'm thinking that if `thir::Pat` can use plain old `Vec`s, maybe so can I.

r? `@ghost`
…param, r=nnethercote

Account for unbounded type param receiver in suggestions

When encountering

```rust
fn f<T>(a: T, b: T) -> std::cmp::Ordering {
    a.cmp(&b) //~ ERROR E0599
}
```

output

```
error[E0599]: no method named `cmp` found for type parameter `T` in the current scope
  --> $DIR/method-on-unbounded-type-param.rs:2:7
   |
LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering {
   |      - method `cmp` not found for this type parameter
LL |     a.cmp(&b)
   |       ^^^ method cannot be called on `T` due to unsatisfied trait bounds
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix rust-lang#120186.
…, r=petrochenkov

update indirect structural match lints to match RFC and to show up for dependencies

This is a large step towards implementing rust-lang/rfcs#3535.
We currently have five lints related to "the structural match situation":
- nontrivial_structural_match
- indirect_structural_match
- pointer_structural_match
- const_patterns_without_partial_eq
- illegal_floating_point_literal_pattern

This PR concerns the first 3 of them. (The 4th already is set up to show for dependencies, and the 5th is removed by rust-lang#116284.) nontrivial_structural_match is being removed as per the RFC; the other two are enabled to show up in dependencies.

Fixes rust-lang#73448 by removing the affected analysis.
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ```````````@Nilstrieb```````````
…, r=compiler-errors

Remove `ffi_returns_twice` feature

The [tracking issue](rust-lang#58314) and [RFC](rust-lang/rfcs#2633) have been closed for a couple of years.

There is also an attribute gate in R-A which should be removed if this lands.
Account for non-overlapping unmet trait bounds in suggestion

When a method not found on a type parameter could have been provided by any
of multiple traits, suggest each trait individually, instead of a single
suggestion to restrict the type parameter with *all* of them.

Before:

```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
  --> $DIR/method-on-unbounded-type-param.rs:5:10
   |
LL |     (&a).cmp(&b)
   |          ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `T: Ord`
           which is required by `&T: Ord`
           `&T: Iterator`
           which is required by `&mut &T: Iterator`
           `T: Iterator`
           which is required by `&mut T: Iterator`
help: consider restricting the type parameters to satisfy the trait bounds
   |
LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord {
   |                                           +++++++++++++++++++++++++
```

After:

```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
  --> $DIR/method-on-unbounded-type-param.rs:5:10
   |
LL |     (&a).cmp(&b)
   |          ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `T: Ord`
           which is required by `&T: Ord`
           `&T: Iterator`
           which is required by `&mut &T: Iterator`
           `T: Iterator`
           which is required by `&mut T: Iterator`
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix rust-lang#108428.

Follow up to rust-lang#120396, only last commit is relevant.
…for-nll, r=lcnr

Normalize type outlives obligations in NLL for new solver

Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems.

Also some cleanups from last PR:
1. Normalize obligations in a loop in lexical region resolution
2. Use `deeply_normalize_with_skipped_universes` in lexical resolution since we may have, e.g. `for<'a> Alias<'a>: 'b`.

r? lcnr
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Feb 6, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=10

@bors
Copy link
Contributor

bors commented Feb 6, 2024

📌 Commit d26cd5e has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2024
@bors
Copy link
Contributor

bors commented Feb 6, 2024

⌛ Testing commit d26cd5e with merge 60bc007...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#119614 (unstably allow constants to refer to statics and read from immutable statics)
 - rust-lang#119939 (Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items)
 - rust-lang#120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s)
 - rust-lang#120331 (pattern_analysis: use a plain `Vec` in `DeconstructedPat`)
 - rust-lang#120396 (Account for unbounded type param receiver in suggestions)
 - rust-lang#120423 (update indirect structural match lints to match RFC and to show up for dependencies)
 - rust-lang#120435 (Suggest name value cfg when only value is used for check-cfg)
 - rust-lang#120502 (Remove `ffi_returns_twice` feature)
 - rust-lang#120507 (Account for non-overlapping unmet trait bounds in suggestion)
 - rust-lang#120513 (Normalize type outlives obligations in NLL for new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/traits/next-solver/nested-obligations-with-bound-vars-gat.rs ... ok
test [ui] tests/ui/traits/next-solver/more-object-bound.rs ... ok
test [ui] tests/ui/traits/next-solver/normalize-type-outlives-in-param-env.rs ... ok
test [ui] tests/ui/traits/next-solver/object-soundness-requires-generalization.rs ... ignored, ignored always
test [ui] tests/ui/traits/next-solver/normalize-region-obligations.rs#hrtb ... ok
test [ui] tests/ui/traits/next-solver/normalize-region-obligations.rs#normalize_obligation ... ok
test [ui] tests/ui/traits/next-solver/normalize-path-for-method.rs ... ok
test [ui] tests/ui/traits/next-solver/normalize-param-env-3.rs ... ok
test [ui] tests/ui/traits/next-solver/normalize-rcvr-for-inherent.rs ... ok
---
- error[E0013]: constants cannot refer to statics
+ error[E0658]: referencing statics in constants is unstable
2   --> $DIR/type-check-4.rs:25:25
3    |
4 LL | global_asm!("{}", const S);
5    |                         ^
6    |
-    = help: consider extracting the value of the `static` to a `const`, and referring to that
+    = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+    = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+    = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+    = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+    = help: to fix this, the value can be extracted to a `const` and then used.
- error[E0013]: constants cannot refer to statics
+ error[E0658]: referencing statics in constants is unstable
10   --> $DIR/type-check-4.rs:28:35
11    |
11    |
12 LL | global_asm!("{}", const const_foo(S));
13    |                                   ^
14    |
-    = help: consider extracting the value of the `static` to a `const`, and referring to that
+    = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+    = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+    = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+    = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+    = help: to fix this, the value can be extracted to a `const` and then used.
- error[E0013]: constants cannot refer to statics
+ error[E0658]: referencing statics in constants is unstable
18   --> $DIR/type-check-4.rs:31:35
19    |
19    |
20 LL | global_asm!("{}", const const_bar(S));
21    |                                   ^
22    |
-    = help: consider extracting the value of the `static` to a `const`, and referring to that
+    = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+    = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+    = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+    = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+    = help: to fix this, the value can be extracted to a `const` and then used.
25 error: aborting due to 3 previous errors
26 

- For more information about this error, try `rustc --explain E0013`.
- For more information about this error, try `rustc --explain E0013`.
+ For more information about this error, try `rustc --explain E0658`.
28 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/asm/aarch64/type-check-4/type-check-4.stderr
To only update this specific test, also pass `--test-args asm/aarch64/type-check-4.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: RUSTC_ICE="0" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/asm/aarch64/type-check-4.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/asm/aarch64/type-check-4" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/asm/aarch64/type-check-4/auxiliary" "-C" "target-feature=+neon"
--- stderr -------------------------------
error[E0658]: referencing statics in constants is unstable
##[error]  --> /checkout/tests/ui/asm/aarch64/type-check-4.rs:25:25
   |
   |
LL | global_asm!("{}", const S);
   |
   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
   = help: to fix this, the value can be extracted to a `const` and then used.
error[E0658]: referencing statics in constants is unstable
##[error]  --> /checkout/tests/ui/asm/aarch64/type-check-4.rs:28:35
   |
   |
LL | global_asm!("{}", const const_foo(S));
   |
   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
   = help: to fix this, the value can be extracted to a `const` and then used.
error[E0658]: referencing statics in constants is unstable
##[error]  --> /checkout/tests/ui/asm/aarch64/type-check-4.rs:31:35
   |
   |
LL | global_asm!("{}", const const_bar(S));
   |
   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
   = help: to fix this, the value can be extracted to a `const` and then used.
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.
------------------------------------------

@bors
Copy link
Contributor

bors commented Feb 6, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 6, 2024
@matthiaskrgr matthiaskrgr deleted the rollup-n3yvykf branch March 16, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.