Skip to content

Rollup of 7 pull requests #94104

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 16 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

bjorn3 and others added 16 commits January 15, 2022 14:48
The produced library would get a main shim too which conflicts with the
main shim of the executable linking the library.

```
$ cat > main1.rs <<EOF
fn main() {}
pub fn bar() {}
EOF
$ cat > main2.rs <<EOF
extern crate main1;
fn main() {
    main1::bar();
}
EOF
$ rustc --crate-type bin --crate-type lib main1.rs
$ rustc -L. main2.rs
error: linking with `cc` failed: exit status: 1
[...]
  = note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main':
          main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here
          collect2: error: ld returned 1 exit status
```
useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
Suggest copying trait associated type bounds on lifetime error

Closes rust-lang#92033

Kind of the most simple suggestion to make - we don't try to be fancy. Turns out, it's still pretty useful (the couple existing tests that trigger this error end up fixed - for this error - upon applying the fix).

r? `@estebank`
cc `@nikomatsakis`
Deny mixing bin crate type with lib crate types

The produced library would get a main shim too which conflicts with the
main shim of the executable linking the library.

```
$ cat > main1.rs <<EOF
fn main() {}
pub fn bar() {}
EOF
$ cat > main2.rs <<EOF
extern crate main1;
fn main() {
    main1::bar();
}
EOF
$ rustc --crate-type bin --crate-type lib main1.rs
$ rustc -L. main2.rs
error: linking with `cc` failed: exit status: 1
[...]
  = note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main':
          main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here
          collect2: error: ld returned 1 exit status
```
…stebank

Add more info and suggestions to use of #[test] on invalid items

This pr changes the diagnostics for using `#[test]` on an item that can't be used as a test to explain that the attribute has no meaningful effect on non-functions and suggests the use of `#[cfg(test)]` for conditional compilation instead.

Example change:
```rs
#[test]
mod test {}
```
previously output
```
error: only functions may be used as tests
 --> src/lib.rs:2:1
  |
2 | mod test {}
  | ^^^^^^^^^^^
  ```
  now outputs
  ```
error: the `#[test]` attribute may only be used on a non-associated function
  --> $DIR/test-on-not-fn.rs:3:1
     |
LL | #[test]
     | ^^^^^^^
LL | mod test {}
     | ----------- expected a non-associated function, found a module
     |
     = note: the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions
help: replace with conditional compilation to make the item only exist when tests are being run
     |
LL | #[cfg(test)]
     | ~~~~~~~~~~~~
   ```
…ds, r=estebank

Do not ICE when inlining a function with un-satisfiable bounds

Fixes rust-lang#93008
This is kinda a hack... but it's the fix I thought had the least blast-radius.

We use `normalize_param_env_or_error` to verify that the predicates in the param env are self-consistent, since with RevealAll, a bad predicate like `<&'static () as Clone>` will be evaluated with an empty ParamEnv (since it references no generics), and we'll raise an error for it.
…ion-with-desugaring, r=estebank

Compatible variants suggestion with desugaring

This fixes rust-lang#90553 for `for` loops and other desugarings.

r? `@estebank`
Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`

Following amendments in rust-lang/rfcs#3208.

cc rust-lang#79024
cc `@yoshuawuyts` `@joshtriplett`
…2022, r=oli-obk

compiler: clippy::complexity fixes

useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Feb 17, 2022
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=10

@bors
Copy link
Collaborator

bors commented Feb 17, 2022

📌 Commit b32240f 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 Feb 17, 2022
@bors
Copy link
Collaborator

bors commented Feb 17, 2022

⌛ Testing commit b32240f with merge 04bdfe229820a0b0c1bdad6b8b373c3c73f508df...

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
.................................................................................................... 400/12645
.................................................................................................... 500/12645
...........................................i........................................................ 600/12645
.................................................................................................... 700/12645
..............i.iF.................................................................................i 800/12645
.................................................................................................... 1000/12645
.................................................................................................... 1100/12645
.................................................................................................... 1200/12645
............................i....................................................................... 1300/12645
---

6    |
7    = note:   expected enum `Result<(), i32>`
8            found unit type `()`
- help: try wrapping the expression in `Ok`
+ help: try adding an expression at the end of the block
10    |
- LL |     Ok(a().await)
-    |     +++         +
+ LL ~     a().await;
+ LL ~     Ok(())
13 
14 error: aborting due to previous error
15 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error/proper-span-for-type-error.stderr
diff of fixed:

5 async fn a() {}
6 
7 async fn foo() -> Result<(), i32> {
-     Ok(a().await) //~ ERROR mismatched types
+     a().await;
+     Ok(()) //~ ERROR mismatched types
10 
11 fn main() {}



The actual fixed differed from the expected fixed.
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Actual fixed saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error/proper-span-for-type-error.fixed
To only update this specific test, also pass `--test-args async-await/proper-span-for-type-error.rs`

error: 2 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/async-await/proper-span-for-type-error.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0308]: mismatched types
  --> /checkout/src/test/ui/async-await/proper-span-for-type-error.rs:8:5
   |
LL |     a().await //~ ERROR mismatched types
   |     ^^^^^^^^^ expected enum `Result`, found `()`
   = note:   expected enum `Result<(), i32>`
           found unit type `()`
help: try adding an expression at the end of the block
   |
   |
LL ~     a().await;
LL ~     Ok(()) //~ ERROR mismatched types

error: aborting due to previous error

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

@bors
Copy link
Collaborator

bors commented Feb 17, 2022

💔 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 17, 2022
@rust-log-analyzer
Copy link
Collaborator

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

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

6    |
7    = note:   expected enum `Result<(), i32>`
8            found unit type `()`
- help: try wrapping the expression in `Ok`
+ help: try adding an expression at the end of the block
10    |
- LL |     Ok(a().await)
-    |     +++         +
+ LL ~     a().await;
+ LL ~     Ok(())
13 
14 error: aborting due to previous error
15 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error/proper-span-for-type-error.stderr
diff of fixed:

5 async fn a() {}
6 
7 async fn foo() -> Result<(), i32> {
-     Ok(a().await) //~ ERROR mismatched types
+     a().await;
+     Ok(()) //~ ERROR mismatched types
10 
11 fn main() {}



The actual fixed differed from the expected fixed.
Actual fixed saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error/proper-span-for-type-error.fixed
To only update this specific test, also pass `--test-args async-await/proper-span-for-type-error.rs`

error: 2 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/async-await/proper-span-for-type-error.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/proper-span-for-type-error/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0308]: mismatched types
  --> /checkout/src/test/ui/async-await/proper-span-for-type-error.rs:8:5
   |
LL |     a().await //~ ERROR mismatched types
   |     ^^^^^^^^^ expected enum `Result`, found `()`
   = note:   expected enum `Result<(), i32>`
           found unit type `()`
help: try adding an expression at the end of the block
   |
   |
LL ~     a().await;
LL ~     Ok(()) //~ ERROR mismatched types

error: aborting due to previous error

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

@matthiaskrgr matthiaskrgr deleted the rollup-hr1zzvd branch March 11, 2022 15:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants