Skip to content

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

estebank and others added 21 commits November 20, 2021 23:49
* Do not emit unnecessary E0308 after E0070
* Show fewer errors on `while let` missing `let`
* Hide redundant E0308 on `while let` missing `let`
* Point at binding definition when possible on invalid assignment
* do not point at closure twice
* do not suggest `if let` for literals in lhs
* account for parameter types
It was replaced several years ago by the stable option `-C
overflow-checks`. The goal was to delete the `-Z` flag once users had
migrated [1]. Now that it's been several years, it makes sense to delete
the old flag.

See also the discussion on Zulip [2].

[1]: rust-lang#33134 (comment)
[2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224
…-obk

Diagnostic tweaks

* On type mismatch caused by assignment, point at the source of the expectation
* Hide redundant errors
* Suggest `while let` when `let` is missing in some cases
Various fixes for const_trait_impl

A few problems I found while making `Iterator` easier to const-implement.

1. More generous `~const Drop` check.

We check for nested fields with caller bounds.

For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either:
 - Bounded (`A: ~const Drop`, `B: Copy`)
 - Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`)

2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates.

I think anyone can review this, so no r? this time.
…ait, r=estebank

Print associated types on opaque `impl Trait` types

This PR generalizes rust-lang#91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future.

before:
```
error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32`
```

after:
```
error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32`
```

---

Questions:
1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary?
2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later..
3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back?
4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that?

r? ```@estebank```
…li-obk

explain why CTFE/Miri perform truncation on shift offset

Closes rust-lang/miri#1920
…=wesleywiser

Remove `-Z force-overflow-checks`

It was replaced several years ago by the stable option `-C overflow-checks`.
The goal was to delete the `-Z` flag once users had migrated [1].
Now that it's been several years, it makes sense to delete the old flag.

See also the discussion on Zulip [2].

[1]: rust-lang#33134 (comment)
[2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224

r? ``@wesleywiser``
cc ``@RalfJung``
@rustbot rustbot added the rollup A PR which is a rollup label Nov 25, 2021
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Nov 25, 2021

📌 Commit 7257f66 has been approved by matthiaskrgr

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 25, 2021
@bors
Copy link
Collaborator

bors commented Nov 25, 2021

⌛ Testing commit 7257f66 with merge 425b605e754b54b0651c18d29ff877f443aef7d2...

@bors
Copy link
Collaborator

bors commented Nov 25, 2021

💔 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 Nov 25, 2021
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)

 error[E0658]: destructuring assignments are unstable
   --> $DIR/ice-6250.rs:12:25
    |
 LL |         Some(reference) = cache.data.get(key) {
    |         --------------- ^
    |         cannot assign to this expression
    |
    = note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
    = help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
    = help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
 
 error[E0601]: `main` function not found in crate `ice_6250`
   --> $DIR/ice-6250.rs:4:1
    |
 LL | / pub struct Cache {
 LL | |     data: Vec<i32>,
 LL | | }
 LL | |
 LL | |     }
 LL | | }
    | |_^ consider adding a `main` function to `$DIR/ice-6250.rs`
 
 
 error[E0308]: mismatched types
   --> $DIR/ice-6250.rs:12:14
    |
+LL |     for reference in vec![1, 2, 3] {
+...
+...
 LL |         Some(reference) = cache.data.get(key) {
    |              ^^^^^^^^^ expected integer, found `&i32`
 help: consider dereferencing the borrow
    |
    |
 LL |         Some(*reference) = cache.data.get(key) {
 
 error[E0308]: mismatched types
   --> $DIR/ice-6250.rs:12:9
    |
    |
 LL |         Some(reference) = cache.data.get(key) {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
 error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0308, E0601, E0658.
 For more information about an error, try `rustc --explain E0308`.
---
To only update this specific test, also pass `--test-args crashes/ice-6250.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "tests/ui/crashes/ice-6250.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/crashes/ice-6250.stage-id" "-A" "unused" "--emit=metadata" "-Dwarnings" "-Zui-testing" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--extern" "clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-432c9b3871214358.rlib" "--extern" "serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-b0d9270169d1e3a9.rlib" "--extern" "quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-0285a3716fdfa0ac.rlib" "--extern" "regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-738a932898af8104.rlib" "--extern" "syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-dead5f2b179ae6e1.rlib" "--extern" "derive_new=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libderive_new-bbe41a872bc8e443.so" "--extern" "itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-041fb6ac880e1ce0.rlib" "--extern" "serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-31d96b843c92ffee.so" "--extern" "if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-a436811527635382.rlib" "--edition=2021" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/crashes/ice-6250.stage-id.aux"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
{"message":"destructuring assignments are unstable","code":{"code":"E0658","explanation":"An unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E0658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using [rustup]).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n\n[rustup]: https://rust-lang.github.io/rustup/concepts/channels.html\n"},"level":"error","spans":[{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":231,"byte_end":246,"line_start":12,"line_end":12,"column_start":9,"column_end":24,"is_primary":false,"text":[{"text":"        Some(reference) = cache.data.get(key) {","highlight_start":9,"highlight_end":24}],"label":"cannot assign to this expression","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":247,"byte_end":248,"line_start":12,"line_end":12,"column_start":25,"column_end":26,"is_primary":true,"text":[{"text":"        Some(reference) = cache.data.get(key) {","highlight_start":25,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(destructuring_assignment)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: destructuring assignments are unstable\n  --> tests/ui/crashes/ice-6250.rs:12:25\n   |\nLL |         Some(reference) = cache.data.get(key) {\n   |         --------------- ^\n   |         |\n   |         cannot assign to this expression\n   |\n   = note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information\n   = help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable\n\n"}
{"message":"`main` function not found in crate `ice_6250`","code":{"code":"E0601","explanation":"No `main` function was found in a binary crate.\n\nTo fix this error, add a `main` function:\n\n```\nfn main() {\n    // Your program will start here.\n    println!(\"Hello world!\");\n}\n```\n\nIf you don't know the basics of Rust, you can look at the\n[Rust Book][rust-book] to get started.\n\n[rust-book]: https://doc.rust-lang.org/book/\n"},"level":"error","spans":[{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":69,"byte_end":317,"line_start":4,"line_end":16,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"pub struct Cache {","highlight_start":1,"highlight_end":19},{"text":"    data: Vec<i32>,","highlight_start":1,"highlight_end":20},{"text":"}","highlight_start":1,"highlight_end":2},{"text":"","highlight_start":1,"highlight_end":1},{"text":"pub fn list_data(cache: &Cache, key: usize) {","highlight_start":1,"highlight_end":46},{"text":"    for reference in vec![1, 2, 3] {","highlight_start":1,"highlight_end":37},{"text":"        if","highlight_start":1,"highlight_end":11},{"text":"        /* let */","highlight_start":1,"highlight_end":18},{"text":"        Some(reference) = cache.data.get(key) {","highlight_start":1,"highlight_end":48},{"text":"            unimplemented!()","highlight_start":1,"highlight_end":29},{"text":"        }","highlight_start":1,"highlight_end":10},{"text":"    }","highlight_start":1,"highlight_end":6},{"text":"}","highlight_start":1,"highlight_end":2}],"label":"consider adding a `main` function to `tests/ui/crashes/ice-6250.rs`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0601]: `main` function not found in crate `ice_6250`\n  --> tests/ui/crashes/ice-6250.rs:4:1\n   |\nLL | / pub struct Cache {\nLL | |     data: Vec<i32>,\nLL | | }\nLL | |\n...  |\nLL | |     }\nLL | | }\n   | |_^ consider adding a `main` function to `tests/ui/crashes/ice-6250.rs`\n\n"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.\n\nErroneous code examples:\n\n```compile_fail,E0308\nfn plus_one(x: i32) -> i32 {\n    x + 1\n}\n\nplus_one(\"Not a number\");\n//       ^^^^^^^^^^^^^^ expected `i32`, found `&str`\n\nif \"Not a bool\" {\n// ^^^^^^^^^^^^ expected `bool`, found `&str`\n}\n\nlet x: f32 = \"Not a float\";\n//     ---   ^^^^^^^^^^^^^ expected `f32`, found `&str`\n//     |\n//     expected due to this\n```\n\nThis error occurs when an expression was used in a place where the compiler\nexpected an expression of a different type. It can occur in several cases, the\nmost common being when calling a function and passing an argument which has a\ndifferent type than the matching type in the function declaration.\n"},"level":"error","spans":[{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":236,"byte_end":245,"line_start":12,"line_end":12,"column_start":14,"column_end":23,"is_primary":true,"text":[{"text":"        Some(reference) = cache.data.get(key) {","highlight_start":14,"highlight_end":23}],"label":"expected integer, found `&i32`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":165,"byte_end":174,"line_start":9,"line_end":9,"column_start":9,"column_end":18,"is_primary":false,"text":[{"text":"    for reference in vec![1, 2, 3] {","highlight_start":9,"highlight_end":18}],"label":"expected due to the type of this binding","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider dereferencing the borrow","code":null,"level":"help","spans":[{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":236,"byte_end":236,"line_start":12,"line_end":12,"column_start":14,"column_end":14,"is_primary":true,"text":[{"text":"        Some(reference) = cache.data.get(key) {","highlight_start":14,"highlight_end":14}],"label":null,"suggested_replacement":"*","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> tests/ui/crashes/ice-6250.rs:12:14\n   |\nLL |     for reference in vec![1, 2, 3] {\n   |         --------- expected due to the type of this binding\n...\nLL |         Some(reference) = cache.data.get(key) {\n   |              ^^^^^^^^^ expected integer, found `&i32`\n   |\nhelp: consider dereferencing the borrow\n   |\nLL |         Some(*reference) = cache.data.get(key) {\n   |              +\n\n"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.\n\nErroneous code examples:\n\n```compile_fail,E0308\nfn plus_one(x: i32) -> i32 {\n    x + 1\n}\n\nplus_one(\"Not a number\");\n//       ^^^^^^^^^^^^^^ expected `i32`, found `&str`\n\nif \"Not a bool\" {\n// ^^^^^^^^^^^^ expected `bool`, found `&str`\n}\n\nlet x: f32 = \"Not a float\";\n//     ---   ^^^^^^^^^^^^^ expected `f32`, found `&str`\n//     |\n//     expected due to this\n```\n\nThis error occurs when an expression was used in a place where the compiler\nexpected an expression of a different type. It can occur in several cases, the\nmost common being when calling a function and passing an argument which has a\ndifferent type than the matching type in the function declaration.\n"},"level":"error","spans":[{"file_name":"tests/ui/crashes/ice-6250.rs","byte_start":231,"byte_end":268,"line_start":12,"line_end":12,"column_start":9,"column_end":46,"is_primary":true,"text":[{"text":"        Some(reference) = cache.data.get(key) {","highlight_start":9,"highlight_end":46}],"label":"expected `bool`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types\n  --> tests/ui/crashes/ice-6250.rs:12:9\n   |\nLL |         Some(reference) = cache.data.get(key) {\n   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`\n\n"}
{"message":"Some errors have detailed explanations: E0308, E0601, E0658.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"Some errors have detailed explanations: E0308, E0601, E0658.\n"}
{"message":"For more information about an error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0308`.\n"}

------------------------------------------

@matthiaskrgr
Copy link
Member Author

Clippy tests failed in #85102

@matthiaskrgr matthiaskrgr deleted the rollup-kh4014n branch November 25, 2021 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants