rust
rust copied to clipboard
Fix accidental type inference in array coercion
Fixes #136420.
If the expectation is a type variable, we should avoid resolving it to the first element's type.
We can create a free type variable instead which is only used in this CoerceMany.
check_expr_match where CoerceMany is also used does the same.
r? @petrochenkov
rustbot has assigned @petrochenkov. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
r? types
There're some similar errors, but I'm unsure whether it's okay to allow these code. The Rust Reference.
fn foo() {}
fn bar() {}
fn main() {
let block_var = 'a: { // Easy to fix, but not specified by the Rust Reference.
if false {
break 'a foo;
}
break 'a bar;
};
let loop_var = loop { // Easy to fix, but not specified by the Rust Reference.
if false {
break foo;
}
break bar;
};
let closure_var = || { // More complicated. But this should work according to the Rust Reference.
if false {
return foo;
}
return bar;
};
}
There're some similar errors, but I'm unsure whether it's okay to allow these code
Yea I think these all should work, too. Please fix the easy ones and add tests for all of them if we don't already have any
The job x86_64-gnu-llvm-19 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#19 exporting to docker image format
#19 sending tarball 20.2s done
#19 DONE 26.6s
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
diff of stderr:
5 | -- the expected `async` closure body
6 LL |
7 LL | let () = x();
- | ^^ --- this expression has type `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
+ | ^^ --- this expression has type `{static main::{closure#0}::{closure#0}<?19t> upvar_tys=?18t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
9 | |
10 | expected `async` closure body, found `()`
11 |
- = note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
+ = note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?19t> upvar_tys=?18t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
13 found unit type `()`
14
15 error: aborting due to 1 previous error
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args async-await/async-closures/def-path.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/async-closures/def-path.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/def-path" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021" "-Zverbose-internals"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/async-await/async-closures/def-path.rs:7:9
|
LL | let x = async || {};
| -- the expected `async` closure body
LL | //~^ NOTE the expected `async` closure body
LL | let () = x();
| ^^ --- this expression has type `{static main::{closure#0}::{closure#0}<?19t> upvar_tys=?18t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
| |
| expected `async` closure body, found `()`
|
= note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?19t> upvar_tys=?18t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
found unit type `()`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
---
+ --> $DIR/issue-78720.rs:4:5
27 |
- LL | fn server() -> impl {
- | ^^^^ cannot infer type
+ LL | ().map2(|| "")
+ | ^^^^^^^^^^^^^^ cannot infer type
30
31 error[E0308]: mismatched types
32 --> $DIR/issue-78720.rs:8:39
Note: some mismatched output was normalized before being compared
- --> /checkout/tests/ui/closures/issue-78720.rs:4:5
+ --> $DIR/issue-78720.rs:4:5
+ LL | ().map2(|| "")
+ | ^^^^^^^^^^^^^^ cannot infer type
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args closures/issue-78720.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/closures/issue-78720.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/closures/issue-78720" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: at least one trait must be specified
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:1:16
|
---
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | _func: Fn,
| +
help: you might be missing a type parameter
|
LL | struct Map2<Segment2, F> {
| +++
error[E0282]: type annotations needed
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:4:5
|
LL | ().map2(|| "")
| ^^^^^^^^^^^^^^ cannot infer type
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:8:39
|
LL | fn map2<F>(self, f: F) -> Map2<F> {}
| ^^ expected `Map2<F>`, found `()`
|
= note: expected struct `Map2<F>`
found unit type `()`
error[E0277]: the size for values of type `Self` cannot be known at compilation time
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:8:16
|
LL | fn map2<F>(self, f: F) -> Map2<F> {}
| ^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
LL | fn map2<F>(self, f: F) -> Map2<F> where Self: Sized {}
| +++++++++++++++++
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | fn map2<F>(&self, f: F) -> Map2<F> {}
| +
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0277, E0282, E0308, E0412.
---
---- [ui] tests/ui/coroutine/type-mismatch-signature-deduction.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/coroutine/type-mismatch-signature-deduction/type-mismatch-signature-deduction.stderr"
diff of stderr:
21 error[E0271]: type mismatch resolving `<{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7} as Coroutine>::Return == i32`
22 --> $DIR/type-mismatch-signature-deduction.rs:5:13
23 |
- LL | fn foo() -> impl Coroutine<Return = i32> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
+ LL | fn foo() -> impl Coroutine<Return = i32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
+ ...
+ LL | / || {
+ LL | | if false {
+ LL | | return Ok(6);
+ ... |
+ LL | | 5
+ LL | | }
+ | |_____- return type was inferred to be `{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
26 |
27 = note: expected type `i32`
28 found enum `Result<{integer}, _>`
Note: some mismatched output was normalized before being compared
- LL | | 5 //~ ERROR mismatched types [E0308]
- | |_____- return type was inferred to be `{coroutine@/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
+ LL | fn foo() -> impl Coroutine<Return = i32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
+ ...
+ LL | / || {
+ LL | | if false {
+ LL | | return Ok(6);
+ ... |
+ LL | | 5
+ LL | | }
+ | |_____- return type was inferred to be `{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args coroutine/type-mismatch-signature-deduction.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/coroutine/type-mismatch-signature-deduction" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:15:9
|
LL | 5 //~ ERROR mismatched types [E0308]
| ^ expected `Result<{integer}, _>`, found integer
|
= note: expected enum `Result<{integer}, _>`
found type `{integer}`
note: return type inferred to be `Result<{integer}, _>` here
--> /checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:10:20
|
LL | return Ok(6);
| ^^^^^
help: try wrapping the expression in a variant of `Result`
|
LL | Ok(5) //~ ERROR mismatched types [E0308]
| +++ +
LL | Err(5) //~ ERROR mismatched types [E0308]
| ++++ +
error[E0271]: type mismatch resolving `<{coroutine@/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:8:5: 8:7} as Coroutine>::Return == i32`
##[error] --> /checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:5:13
|
LL | fn foo() -> impl Coroutine<Return = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
...
LL | / || {
LL | | if false {
LL | | return Ok(6);
... |
LL | | 5 //~ ERROR mismatched types [E0308]
LL | | }
| |_____- return type was inferred to be `{coroutine@/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
|
= note: expected type `i32`
found enum `Result<{integer}, _>`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
---
To only update this specific test, also pass `--test-args drop/lint-tail-expr-drop-order-borrowck.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/drop/lint-tail-expr-drop-order-borrowck" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error: relative drop order changing in Rust 2024
##[error] --> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:9:15
|
LL | let _ = { String::new().as_str() }.len();
| ^^^^^^^^^^^^^ --- borrow later used by call
| |
| this temporary value will be dropped at the end of the block
|
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: the lint level is defined here
--> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:6:9
|
LL | #![deny(tail_expr_drop_order)] //~ NOTE: the lint level is defined here
| ^^^^^^^^^^^^^^^^^^^^
error: relative drop order changing in Rust 2024
##[error] --> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:19:16
|
LL | f(unsafe { String::new().as_str() }.len());
| ^^^^^^^^^^^^^ --- borrow later used by call
| |
| this temporary value will be dropped at the end of the block
|
= warning: this changes meaning in Rust 2024
---
error: relative drop order changing in Rust 2024
##[error] --> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:43:9
|
LL | g({ &f() });
| - ^^^^ this temporary value will be dropped at the end of the block
| |
| borrow later used by call
|
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
---
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722/issue-78722.stderr"
diff of stderr:
13 |
14 LL | fn concrete_use() -> F {
15 | ^ expected `u8`, found `()`
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722.rs:11:13: 11:18}` here
16
17 error: aborting due to 2 previous errors
18
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR to be a future that resolves to `u8`, but it resolves to `()`
- | -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722.rs:11:13: 11:18}` here
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722.rs:11:13: 11:18}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args impl-trait/issues/issue-78722.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/issues/issue-78722.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error[E0658]: `async` blocks are not allowed in constants
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722.rs:13:20
|
LL | let f: F = async { 1 };
| ^^^^^^^^^^^
|
= note: see issue #85368 <https://github.com/rust-lang/rust/issues/85368> for more information
= help: add `#![feature(const_async_blocks)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0271]: expected `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722.rs:11:13: 11:18}` to be a future that resolves to `u8`, but it resolves to `()`
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722.rs:9:30
|
LL | fn concrete_use() -> F {
| ^ expected `u8`, found `()`
LL | //~^ ERROR to be a future that resolves to `u8`, but it resolves to `()`
LL | async {}
| -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722.rs:11:13: 11:18}` here
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0658.
For more information about an error, try `rustc --explain E0271`.
---
1 error[E0277]: `{integer}` is not a future
2 --> $DIR/issue-83919.rs:21:26
3 |
- LL | fn get_fut(&self) -> Self::Fut {
- | ^^^^^^^^^ `{integer}` is not a future
+ LL | fn get_fut(&self) -> Self::Fut {
+ | ^^^^^^^^^ `{integer}` is not a future
+ LL |
+ LL | / async move {
+ LL | | 42
+ ... |
+ LL | | }
+ | |_________- return type was inferred to be `{async block@$DIR/issue-83919.rs:23:9: 23:19}` here
6 |
7 = help: the trait `Future` is not implemented for `{integer}`
8
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR `{integer}` is not a future
- | |_________- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-83919.rs:23:9: 23:19}` here
+ LL | fn get_fut(&self) -> Self::Fut {
+ | ^^^^^^^^^ `{integer}` is not a future
+ LL |
+ LL | / async move {
+ LL | | 42
+ ... |
+ LL | | }
+ | |_________- return type was inferred to be `{async block@$DIR/issue-83919.rs:23:9: 23:19}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args impl-trait/issues/issue-83919.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/issues/issue-83919.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-83919" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0277]: `{integer}` is not a future
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-83919.rs:21:26
|
LL | fn get_fut(&self) -> Self::Fut {
| ^^^^^^^^^ `{integer}` is not a future
LL | //~^ ERROR `{integer}` is not a future
LL | / async move {
LL | | 42
... |
LL | | }
| |_________- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-83919.rs:23:9: 23:19}` here
|
= help: the trait `Future` is not implemented for `{integer}`
error: aborting due to 1 previous error
---
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722-2/issue-78722-2.stderr"
diff of stderr:
17 |
18 LL | fn concrete_use() -> F {
19 | ^ expected `u8`, found `()`
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722-2.rs:14:13: 14:18}` here
20
21 error: aborting due to 2 previous errors
22
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR future that resolves to `u8`, but it resolves to `()`
- | -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:14:13: 14:18}` here
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722-2.rs:14:13: 14:18}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args impl-trait/issues/issue-78722-2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/issues/issue-78722-2.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:17:20
|
LL | type F = impl core::future::Future<Output = u8>;
| -------------------------------------- the expected future
...
LL | let f: F = async { 1 };
| - ^^^^^^^^^^^ expected future, found `async` block
| |
| expected due to this
|
= note: expected opaque type `F`
found `async` block `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:17:20: 17:25}`
error[E0271]: expected `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:14:13: 14:18}` to be a future that resolves to `u8`, but it resolves to `()`
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:12:30
|
LL | fn concrete_use() -> F {
| ^ expected `u8`, found `()`
LL | //~^ ERROR future that resolves to `u8`, but it resolves to `()`
LL | async {}
| -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:14:13: 14:18}` here
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
---
93 error[E0308]: mismatched types
- --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
+ --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:17:5
95 |
- LL | fn baz() -> impl std::fmt::Display {
- | ---------------------- expected `i32` because of return type
- ...
- LL | 1u32
- | ^^^^ expected `i32`, found `u32`
+ LL | fn baz() -> impl std::fmt::Display {
+ | ---------------------- expected `i32` because of return type
+ LL | / if false {
+ LL | | return 0i32;
+ LL | | } else {
+ LL | | 1u32
+ LL | | }
+ | |_____^ expected `i32`, found `u32`
101 |
102 help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
103 |
134 |
---
177 |
Note: some mismatched output was normalized before being compared
- --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:17:5
- LL | | 1u32 //~ ERROR mismatched types
- --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:33:5
- LL | | _ => 1u32, //~ ERROR mismatched types
- --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:48:5
+ --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:17:5
+ LL | fn baz() -> impl std::fmt::Display {
+ | ---------------------- expected `i32` because of return type
+ LL | / if false {
+ LL | | return 0i32;
+ LL | | } else {
+ LL | | 1u32
+ LL | | }
+ | |_____^ expected `i32`, found `u32`
+ --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:33:5
+ LL | fn bat() -> impl std::fmt::Display {
+ | ---------------------- expected `i32` because of return type
+ LL | / match 13 {
+ LL | | 0 => return 0i32,
---
To only update this specific test, also pass `--test-args impl-trait/point-to-type-err-cause-on-impl-trait-return.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0746]: return type cannot be a trait object without pointer indirection
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:66:13
|
LL | fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
LL - fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
LL + fn hat() -> impl std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
LL ~ fn hat() -> Box<dyn std::fmt::Display> { //~ ERROR return type cannot be a trait object without pointer indirection
LL | match 13 {
LL | 0 => {
LL ~ return Box::new(0i32);
LL | }
LL | _ => {
LL ~ Box::new(1u32)
|
error[E0746]: return type cannot be a trait object without pointer indirection
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:77:13
|
LL | fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
LL - fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
LL + fn pug() -> impl std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
LL ~ fn pug() -> Box<dyn std::fmt::Display> { //~ ERROR return type cannot be a trait object without pointer indirection
LL | match 13 {
LL ~ 0 => Box::new(0i32),
LL ~ 1 => Box::new(1u32),
LL ~ _ => Box::new(2u32),
|
error[E0746]: return type cannot be a trait object without pointer indirection
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:85:13
|
LL | fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
LL - fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
LL + fn man() -> impl std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
LL ~ fn man() -> Box<dyn std::fmt::Display> { //~ ERROR return type cannot be a trait object without pointer indirection
LL | if false {
LL ~ Box::new(0i32)
LL | } else {
LL ~ Box::new(1u32)
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:5:5
|
LL | fn foo() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
...
LL | 1u32 //~ ERROR mismatched types
| ^^^^ expected `i32`, found `u32`
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1u32 //~ ERROR mismatched types
LL + 1i32 //~ ERROR mismatched types
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:12:16
|
LL | fn bar() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
...
LL | return 1u32; //~ ERROR mismatched types
| ^^^^ expected `i32`, found `u32`
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - return 1u32; //~ ERROR mismatched types
LL + return 1i32; //~ ERROR mismatched types
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:17:5
|
LL | fn baz() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
LL | / if false {
LL | | return 0i32;
LL | | } else {
LL | | 1u32 //~ ERROR mismatched types
LL | | }
| |_____^ expected `i32`, found `u32`
|
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
|
---
LL | / if false {
LL | | 0i32
| | ---- expected because of this
LL | | } else {
LL | | 1u32 //~ ERROR `if` and `else` have incompatible types
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
|
help: you could change the return type to be a boxed trait object
|
LL - fn qux() -> impl std::fmt::Display {
LL + fn qux() -> Box<dyn std::fmt::Display> {
|
help: if you change the return type to expect trait objects, box the returned expressions
|
LL ~ Box::new(0i32)
LL | } else {
LL ~ Box::new(1u32) //~ ERROR `if` and `else` have incompatible types
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1u32 //~ ERROR `if` and `else` have incompatible types
LL + 1i32 //~ ERROR `if` and `else` have incompatible types
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:33:5
|
LL | fn bat() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
LL | / match 13 {
LL | | 0 => return 0i32,
LL | | _ => 1u32, //~ ERROR mismatched types
LL | | }
| |_____^ expected `i32`, found `u32`
|
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
|
LL | }.try_into().unwrap()
| ++++++++++++++++++++
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:40:5
|
LL | fn can() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
LL | / match 13 { //~ ERROR mismatched types
LL | | 0 => return 0i32,
LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____^ expected `i32`, found `u32`
|
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
|
---
|
LL | / match 13 {
LL | | 0 => 0i32,
| | ---- this is found to be of type `i32`
LL | | 1 => 1u32, //~ ERROR `match` arms have incompatible types
| | ^^^^ expected `i32`, found `u32`
LL | | _ => 2u32,
LL | | }
| |_____- `match` arms have incompatible types
|
help: you could change the return type to be a boxed trait object
|
LL - fn dog() -> impl std::fmt::Display {
LL + fn dog() -> Box<dyn std::fmt::Display> {
|
help: if you change the return type to expect trait objects, box the returned expressions
|
LL ~ 0 => Box::new(0i32),
LL ~ 1 => Box::new(1u32), //~ ERROR `match` arms have incompatible types
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1 => 1u32, //~ ERROR `match` arms have incompatible types
LL + 1 => 1i32, //~ ERROR `match` arms have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:97:9
|
LL | / if let Some(42) = Some(42) {
LL | | 0i32
| | ---- expected because of this
LL | | } else {
LL | | 1u32 //~ ERROR `if` and `else` have incompatible types
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
|
help: you could change the return type to be a boxed trait object
|
LL - fn apt() -> impl std::fmt::Display {
LL + fn apt() -> Box<dyn std::fmt::Display> {
|
help: if you change the return type to expect trait objects, box the returned expressions
|
LL ~ Box::new(0i32)
LL | } else {
LL ~ Box::new(1u32) //~ ERROR `if` and `else` have incompatible types
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1u32 //~ ERROR `if` and `else` have incompatible types
LL + 1i32 //~ ERROR `if` and `else` have incompatible types
|
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0308, E0746.
---
To only update this specific test, also pass `--test-args issues/issue-46471-1.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/issues/issue-46471-1.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/issues/issue-46471-1" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `z` does not live long enough
##[error] --> /checkout/tests/ui/issues/issue-46471-1.rs:4:9
|
---
---- [ui] tests/ui/never_type/fallback-closure-ret.rs#fallback stdout ----
error in revision `fallback`: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/never_type/fallback-closure-ret.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--cfg" "fallback" "--check-cfg" "cfg(test,FALSE,nofallback,fallback)" "--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/x86_64-unknown-linux-gnu/test/ui/never_type/fallback-closure-ret.fallback" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0277]: the trait bound `!: Bar` is not satisfied
##[error] --> /checkout/tests/ui/never_type/fallback-closure-ret.rs:24:5
|
LL | foo(|| panic!());
| ^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `!`
|
= help: the following other types implement trait `Bar`:
()
u32
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
= help: did you intend to use the type `()` here instead?
note: required by a bound in `foo`
--> /checkout/tests/ui/never_type/fallback-closure-ret.rs:19:11
|
LL | fn foo<R: Bar>(_: impl Fn() -> R) {}
| ^^^ required by this bound in `foo`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
------------------------------------------
---- [ui] tests/ui/nll/issue-52663-trait-object.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-52663-trait-object/issue-52663-trait-object.stderr"
diff of stderr:
6 LL | let tmp1 = &tmp0;
7 | ^^^^^ borrowed value does not live long enough
8 LL | Box::new(tmp1) as Box<dyn Foo + '_>
- | ----------------------------------- borrow later captured here by trait object
10 LL | };
11 | - `tmp0` dropped here while still borrowed
12
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args nll/issue-52663-trait-object.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/nll/issue-52663-trait-object.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/nll/issue-52663-trait-object" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `tmp0` does not live long enough
##[error] --> /checkout/tests/ui/nll/issue-52663-trait-object.rs:12:20
|
LL | let tmp0 = 3;
| ---- binding `tmp0` declared here
LL | let tmp1 = &tmp0;
| ^^^^^ borrowed value does not live long enough
LL | Box::new(tmp1) as Box<dyn Foo + '_>
LL | };
| - `tmp0` dropped here while still borrowed
error: aborting due to 1 previous error
---
---- [ui] tests/ui/span/regions-close-over-type-parameter-2.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/regions-close-over-type-parameter-2/regions-close-over-type-parameter-2.stderr"
diff of stderr:
6 LL | let tmp1 = &tmp0;
7 | ^^^^^ borrowed value does not live long enough
8 LL | repeater3(tmp1)
- | --------------- borrow later captured here by trait object
10 LL | };
11 | - `tmp0` dropped here while still borrowed
---
To only update this specific test, also pass `--test-args span/regions-close-over-type-parameter-2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/span/regions-close-over-type-parameter-2.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/span/regions-close-over-type-parameter-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `tmp0` does not live long enough
##[error] --> /checkout/tests/ui/span/regions-close-over-type-parameter-2.rs:23:20
|
LL | let tmp0 = 3;
| ---- binding `tmp0` declared here
LL | let tmp1 = &tmp0;
| ^^^^^ borrowed value does not live long enough
LL | repeater3(tmp1)
LL | };
| - `tmp0` dropped here while still borrowed
---
+ --> $DIR/different_defining_uses_never_type-2.rs:13:23
9 |
- LL | x
- | ^
+ LL | let x: Tait<'a> = ();
+ | ^^
12
13 error: aborting due to 1 previous error
14
Note: some mismatched output was normalized before being compared
- --> /checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs:13:23
+ --> $DIR/different_defining_uses_never_type-2.rs:13:23
+ LL | let x: Tait<'a> = ();
+ | ^^
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args type-alias-impl-trait/different_defining_uses_never_type-2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/different_defining_uses_never_type-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: concrete type differs from previous defining opaque type use
##[error] --> /checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs:9:31
|
LL | let y: Tait<'b> = 1i32;
| ^^^^ expected `()`, got `i32`
|
note: previous use here
--> /checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs:13:23
|
LL | let x: Tait<'a> = ();
---
---- [ui] tests/ui/type-alias-impl-trait/issue-94429.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/issue-94429/issue-94429.stderr"
diff of stderr:
1 error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:18:9: 18:16} as Coroutine>::Yield == ()`
2 --> $DIR/issue-94429.rs:15:26
3 |
- LL | fn run(&mut self) -> Self::Coro {
- | ^^^^^^^^^^ expected `()`, found integer
+ LL | fn run(&mut self) -> Self::Coro {
+ | ^^^^^^^^^^ expected `()`, found integer
+ ...
+ LL | / move || {
+ LL | | yield 1;
+ LL | | }
+ | |_________- return type was inferred to be `{coroutine@$DIR/issue-94429.rs:18:9: 18:16}` here
6
7 error: aborting due to 1 previous error
8
Note: some mismatched output was normalized before being compared
- | |_________- return type was inferred to be `{coroutine@/checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:18:9: 18:16}` here
+ LL | fn run(&mut self) -> Self::Coro {
+ | ^^^^^^^^^^ expected `()`, found integer
+ ...
+ LL | / move || {
+ LL | | yield 1;
+ LL | | }
+ | |_________- return type was inferred to be `{coroutine@$DIR/issue-94429.rs:18:9: 18:16}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args type-alias-impl-trait/issue-94429.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/type-alias-impl-trait/issue-94429.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/issue-94429" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0271]: type mismatch resolving `<{coroutine@/checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:18:9: 18:16} as Coroutine>::Yield == ()`
##[error] --> /checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:15:26
|
LL | fn run(&mut self) -> Self::Coro {
| ^^^^^^^^^^ expected `()`, found integer
...
LL | / move || {
LL | | yield 1;
LL | | }
| |_________- return type was inferred to be `{coroutine@/checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:18:9: 18:16}` here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.
------------------------------------------
---- [ui] tests/ui/weird-exprs.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/weird-exprs.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/weird-exprs/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0282]: type annotations needed
##[error] --> /checkout/tests/ui/weird-exprs.rs:246:22
|
The job x86_64-gnu-llvm-19 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#18 exporting to docker image format
#18 sending tarball 20.6s done
#18 DONE 27.3s
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
+ --> $DIR/issue-78720.rs:4:5
27 |
- LL | fn server() -> impl {
- | ^^^^ cannot infer type
+ LL | ().map2(|| "")
+ | ^^^^^^^^^^^^^^ cannot infer type
30
31 error[E0308]: mismatched types
32 --> $DIR/issue-78720.rs:8:39
Note: some mismatched output was normalized before being compared
- --> /checkout/tests/ui/closures/issue-78720.rs:4:5
+ --> $DIR/issue-78720.rs:4:5
+ LL | ().map2(|| "")
+ | ^^^^^^^^^^^^^^ cannot infer type
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args closures/issue-78720.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/closures/issue-78720.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/closures/issue-78720" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: at least one trait must be specified
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:1:16
|
---
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | _func: Fn,
| +
help: you might be missing a type parameter
|
LL | struct Map2<Segment2, F> {
| +++
error[E0282]: type annotations needed
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:4:5
|
LL | ().map2(|| "")
| ^^^^^^^^^^^^^^ cannot infer type
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:8:39
|
LL | fn map2<F>(self, f: F) -> Map2<F> {}
| ^^ expected `Map2<F>`, found `()`
|
= note: expected struct `Map2<F>`
found unit type `()`
error[E0277]: the size for values of type `Self` cannot be known at compilation time
##[error] --> /checkout/tests/ui/closures/issue-78720.rs:8:16
|
LL | fn map2<F>(self, f: F) -> Map2<F> {}
| ^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
LL | fn map2<F>(self, f: F) -> Map2<F> where Self: Sized {}
| +++++++++++++++++
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | fn map2<F>(&self, f: F) -> Map2<F> {}
| +
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0277, E0282, E0308, E0412.
---
---- [ui] tests/ui/coroutine/type-mismatch-signature-deduction.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/coroutine/type-mismatch-signature-deduction/type-mismatch-signature-deduction.stderr"
diff of stderr:
21 error[E0271]: type mismatch resolving `<{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7} as Coroutine>::Return == i32`
22 --> $DIR/type-mismatch-signature-deduction.rs:5:13
23 |
- LL | fn foo() -> impl Coroutine<Return = i32> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
+ LL | fn foo() -> impl Coroutine<Return = i32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
+ ...
+ LL | / || {
+ LL | | if false {
+ LL | | return Ok(6);
+ ... |
+ LL | | 5
+ LL | | }
+ | |_____- return type was inferred to be `{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
26 |
27 = note: expected type `i32`
28 found enum `Result<{integer}, _>`
Note: some mismatched output was normalized before being compared
- LL | | 5 //~ ERROR mismatched types [E0308]
- | |_____- return type was inferred to be `{coroutine@/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
+ LL | fn foo() -> impl Coroutine<Return = i32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
+ ...
+ LL | / || {
+ LL | | if false {
+ LL | | return Ok(6);
+ ... |
+ LL | | 5
+ LL | | }
+ | |_____- return type was inferred to be `{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args coroutine/type-mismatch-signature-deduction.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/coroutine/type-mismatch-signature-deduction" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:15:9
|
LL | 5 //~ ERROR mismatched types [E0308]
| ^ expected `Result<{integer}, _>`, found integer
|
= note: expected enum `Result<{integer}, _>`
found type `{integer}`
note: return type inferred to be `Result<{integer}, _>` here
--> /checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:10:20
|
LL | return Ok(6);
| ^^^^^
help: try wrapping the expression in a variant of `Result`
|
LL | Ok(5) //~ ERROR mismatched types [E0308]
| +++ +
LL | Err(5) //~ ERROR mismatched types [E0308]
| ++++ +
error[E0271]: type mismatch resolving `<{coroutine@/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:8:5: 8:7} as Coroutine>::Return == i32`
##[error] --> /checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:5:13
|
LL | fn foo() -> impl Coroutine<Return = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>`
...
LL | / || {
LL | | if false {
LL | | return Ok(6);
... |
LL | | 5 //~ ERROR mismatched types [E0308]
LL | | }
| |_____- return type was inferred to be `{coroutine@/checkout/tests/ui/coroutine/type-mismatch-signature-deduction.rs:8:5: 8:7}` here
|
= note: expected type `i32`
found enum `Result<{integer}, _>`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
---
To only update this specific test, also pass `--test-args drop/lint-tail-expr-drop-order-borrowck.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/drop/lint-tail-expr-drop-order-borrowck" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error: relative drop order changing in Rust 2024
##[error] --> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:9:15
|
LL | let _ = { String::new().as_str() }.len();
| ^^^^^^^^^^^^^ --- borrow later used by call
| |
| this temporary value will be dropped at the end of the block
|
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: the lint level is defined here
--> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:6:9
|
LL | #![deny(tail_expr_drop_order)] //~ NOTE: the lint level is defined here
| ^^^^^^^^^^^^^^^^^^^^
error: relative drop order changing in Rust 2024
##[error] --> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:19:16
|
LL | f(unsafe { String::new().as_str() }.len());
| ^^^^^^^^^^^^^ --- borrow later used by call
| |
| this temporary value will be dropped at the end of the block
|
= warning: this changes meaning in Rust 2024
---
error: relative drop order changing in Rust 2024
##[error] --> /checkout/tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs:43:9
|
LL | g({ &f() });
| - ^^^^ this temporary value will be dropped at the end of the block
| |
| borrow later used by call
|
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
---
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722/issue-78722.stderr"
diff of stderr:
13 |
14 LL | fn concrete_use() -> F {
15 | ^ expected `u8`, found `()`
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722.rs:11:13: 11:18}` here
16
17 error: aborting due to 2 previous errors
18
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR to be a future that resolves to `u8`, but it resolves to `()`
- | -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722.rs:11:13: 11:18}` here
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722.rs:11:13: 11:18}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args impl-trait/issues/issue-78722.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/issues/issue-78722.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error[E0658]: `async` blocks are not allowed in constants
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722.rs:13:20
|
LL | let f: F = async { 1 };
| ^^^^^^^^^^^
|
= note: see issue #85368 <https://github.com/rust-lang/rust/issues/85368> for more information
= help: add `#![feature(const_async_blocks)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0271]: expected `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722.rs:11:13: 11:18}` to be a future that resolves to `u8`, but it resolves to `()`
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722.rs:9:30
|
LL | fn concrete_use() -> F {
| ^ expected `u8`, found `()`
LL | //~^ ERROR to be a future that resolves to `u8`, but it resolves to `()`
LL | async {}
| -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722.rs:11:13: 11:18}` here
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0658.
For more information about an error, try `rustc --explain E0271`.
---
1 error[E0277]: `{integer}` is not a future
2 --> $DIR/issue-83919.rs:21:26
3 |
- LL | fn get_fut(&self) -> Self::Fut {
- | ^^^^^^^^^ `{integer}` is not a future
+ LL | fn get_fut(&self) -> Self::Fut {
+ | ^^^^^^^^^ `{integer}` is not a future
+ LL |
+ LL | / async move {
+ LL | | 42
+ ... |
+ LL | | }
+ | |_________- return type was inferred to be `{async block@$DIR/issue-83919.rs:23:9: 23:19}` here
6 |
7 = help: the trait `Future` is not implemented for `{integer}`
8
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR `{integer}` is not a future
- | |_________- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-83919.rs:23:9: 23:19}` here
+ LL | fn get_fut(&self) -> Self::Fut {
+ | ^^^^^^^^^ `{integer}` is not a future
+ LL |
+ LL | / async move {
+ LL | | 42
+ ... |
+ LL | | }
+ | |_________- return type was inferred to be `{async block@$DIR/issue-83919.rs:23:9: 23:19}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args impl-trait/issues/issue-83919.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/issues/issue-83919.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-83919" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0277]: `{integer}` is not a future
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-83919.rs:21:26
|
LL | fn get_fut(&self) -> Self::Fut {
| ^^^^^^^^^ `{integer}` is not a future
LL | //~^ ERROR `{integer}` is not a future
LL | / async move {
LL | | 42
... |
LL | | }
| |_________- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-83919.rs:23:9: 23:19}` here
|
= help: the trait `Future` is not implemented for `{integer}`
error: aborting due to 1 previous error
---
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722-2/issue-78722-2.stderr"
diff of stderr:
17 |
18 LL | fn concrete_use() -> F {
19 | ^ expected `u8`, found `()`
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722-2.rs:14:13: 14:18}` here
20
21 error: aborting due to 2 previous errors
22
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR future that resolves to `u8`, but it resolves to `()`
- | -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:14:13: 14:18}` here
+ LL |
+ LL | async {}
+ | -------- return type was inferred to be `{async block@$DIR/issue-78722-2.rs:14:13: 14:18}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args impl-trait/issues/issue-78722-2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/issues/issue-78722-2.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/issues/issue-78722-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:17:20
|
LL | type F = impl core::future::Future<Output = u8>;
| -------------------------------------- the expected future
...
LL | let f: F = async { 1 };
| - ^^^^^^^^^^^ expected future, found `async` block
| |
| expected due to this
|
= note: expected opaque type `F`
found `async` block `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:17:20: 17:25}`
error[E0271]: expected `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:14:13: 14:18}` to be a future that resolves to `u8`, but it resolves to `()`
##[error] --> /checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:12:30
|
LL | fn concrete_use() -> F {
| ^ expected `u8`, found `()`
LL | //~^ ERROR future that resolves to `u8`, but it resolves to `()`
LL | async {}
| -------- return type was inferred to be `{async block@/checkout/tests/ui/impl-trait/issues/issue-78722-2.rs:14:13: 14:18}` here
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
---
93 error[E0308]: mismatched types
- --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
+ --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:17:5
95 |
- LL | fn baz() -> impl std::fmt::Display {
- | ---------------------- expected `i32` because of return type
- ...
- LL | 1u32
- | ^^^^ expected `i32`, found `u32`
+ LL | fn baz() -> impl std::fmt::Display {
+ | ---------------------- expected `i32` because of return type
+ LL | / if false {
+ LL | | return 0i32;
+ LL | | } else {
+ LL | | 1u32
+ LL | | }
+ | |_____^ expected `i32`, found `u32`
101 |
102 help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
103 |
134 |
---
177 |
Note: some mismatched output was normalized before being compared
- --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:17:5
- LL | | 1u32 //~ ERROR mismatched types
- --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:33:5
- LL | | _ => 1u32, //~ ERROR mismatched types
- --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:48:5
+ --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:17:5
+ LL | fn baz() -> impl std::fmt::Display {
+ | ---------------------- expected `i32` because of return type
+ LL | / if false {
+ LL | | return 0i32;
+ LL | | } else {
+ LL | | 1u32
+ LL | | }
+ | |_____^ expected `i32`, found `u32`
+ --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:33:5
+ LL | fn bat() -> impl std::fmt::Display {
+ | ---------------------- expected `i32` because of return type
+ LL | / match 13 {
+ LL | | 0 => return 0i32,
---
To only update this specific test, also pass `--test-args impl-trait/point-to-type-err-cause-on-impl-trait-return.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0746]: return type cannot be a trait object without pointer indirection
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:66:13
|
LL | fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
LL - fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
LL + fn hat() -> impl std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
LL ~ fn hat() -> Box<dyn std::fmt::Display> { //~ ERROR return type cannot be a trait object without pointer indirection
LL | match 13 {
LL | 0 => {
LL ~ return Box::new(0i32);
LL | }
LL | _ => {
LL ~ Box::new(1u32)
|
error[E0746]: return type cannot be a trait object without pointer indirection
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:77:13
|
LL | fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
LL - fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
LL + fn pug() -> impl std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
LL ~ fn pug() -> Box<dyn std::fmt::Display> { //~ ERROR return type cannot be a trait object without pointer indirection
LL | match 13 {
LL ~ 0 => Box::new(0i32),
LL ~ 1 => Box::new(1u32),
LL ~ _ => Box::new(2u32),
|
error[E0746]: return type cannot be a trait object without pointer indirection
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:85:13
|
LL | fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
LL - fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
LL + fn man() -> impl std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
LL ~ fn man() -> Box<dyn std::fmt::Display> { //~ ERROR return type cannot be a trait object without pointer indirection
LL | if false {
LL ~ Box::new(0i32)
LL | } else {
LL ~ Box::new(1u32)
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:5:5
|
LL | fn foo() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
...
LL | 1u32 //~ ERROR mismatched types
| ^^^^ expected `i32`, found `u32`
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1u32 //~ ERROR mismatched types
LL + 1i32 //~ ERROR mismatched types
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:12:16
|
LL | fn bar() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
...
LL | return 1u32; //~ ERROR mismatched types
| ^^^^ expected `i32`, found `u32`
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - return 1u32; //~ ERROR mismatched types
LL + return 1i32; //~ ERROR mismatched types
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:17:5
|
LL | fn baz() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
LL | / if false {
LL | | return 0i32;
LL | | } else {
LL | | 1u32 //~ ERROR mismatched types
LL | | }
| |_____^ expected `i32`, found `u32`
|
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
|
---
LL | / if false {
LL | | 0i32
| | ---- expected because of this
LL | | } else {
LL | | 1u32 //~ ERROR `if` and `else` have incompatible types
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
|
help: you could change the return type to be a boxed trait object
|
LL - fn qux() -> impl std::fmt::Display {
LL + fn qux() -> Box<dyn std::fmt::Display> {
|
help: if you change the return type to expect trait objects, box the returned expressions
|
LL ~ Box::new(0i32)
LL | } else {
LL ~ Box::new(1u32) //~ ERROR `if` and `else` have incompatible types
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1u32 //~ ERROR `if` and `else` have incompatible types
LL + 1i32 //~ ERROR `if` and `else` have incompatible types
|
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:33:5
|
LL | fn bat() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
LL | / match 13 {
LL | | 0 => return 0i32,
LL | | _ => 1u32, //~ ERROR mismatched types
LL | | }
| |_____^ expected `i32`, found `u32`
|
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
|
LL | }.try_into().unwrap()
| ++++++++++++++++++++
error[E0308]: mismatched types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:40:5
|
LL | fn can() -> impl std::fmt::Display {
| ---------------------- expected `i32` because of return type
LL | / match 13 { //~ ERROR mismatched types
LL | | 0 => return 0i32,
LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____^ expected `i32`, found `u32`
|
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
|
---
|
LL | / match 13 {
LL | | 0 => 0i32,
| | ---- this is found to be of type `i32`
LL | | 1 => 1u32, //~ ERROR `match` arms have incompatible types
| | ^^^^ expected `i32`, found `u32`
LL | | _ => 2u32,
LL | | }
| |_____- `match` arms have incompatible types
|
help: you could change the return type to be a boxed trait object
|
LL - fn dog() -> impl std::fmt::Display {
LL + fn dog() -> Box<dyn std::fmt::Display> {
|
help: if you change the return type to expect trait objects, box the returned expressions
|
LL ~ 0 => Box::new(0i32),
LL ~ 1 => Box::new(1u32), //~ ERROR `match` arms have incompatible types
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1 => 1u32, //~ ERROR `match` arms have incompatible types
LL + 1 => 1i32, //~ ERROR `match` arms have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
##[error] --> /checkout/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs:97:9
|
LL | / if let Some(42) = Some(42) {
LL | | 0i32
| | ---- expected because of this
LL | | } else {
LL | | 1u32 //~ ERROR `if` and `else` have incompatible types
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
|
help: you could change the return type to be a boxed trait object
|
LL - fn apt() -> impl std::fmt::Display {
LL + fn apt() -> Box<dyn std::fmt::Display> {
|
help: if you change the return type to expect trait objects, box the returned expressions
|
LL ~ Box::new(0i32)
LL | } else {
LL ~ Box::new(1u32) //~ ERROR `if` and `else` have incompatible types
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL - 1u32 //~ ERROR `if` and `else` have incompatible types
LL + 1i32 //~ ERROR `if` and `else` have incompatible types
|
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0308, E0746.
---
To only update this specific test, also pass `--test-args issues/issue-46471-1.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/issues/issue-46471-1.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/issues/issue-46471-1" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `z` does not live long enough
##[error] --> /checkout/tests/ui/issues/issue-46471-1.rs:4:9
|
---
---- [ui] tests/ui/never_type/fallback-closure-ret.rs#fallback stdout ----
error in revision `fallback`: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/never_type/fallback-closure-ret.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--cfg" "fallback" "--check-cfg" "cfg(test,FALSE,nofallback,fallback)" "--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/x86_64-unknown-linux-gnu/test/ui/never_type/fallback-closure-ret.fallback" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0277]: the trait bound `!: Bar` is not satisfied
##[error] --> /checkout/tests/ui/never_type/fallback-closure-ret.rs:24:5
|
LL | foo(|| panic!());
| ^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `!`
|
= help: the following other types implement trait `Bar`:
()
u32
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
= help: did you intend to use the type `()` here instead?
note: required by a bound in `foo`
--> /checkout/tests/ui/never_type/fallback-closure-ret.rs:19:11
|
LL | fn foo<R: Bar>(_: impl Fn() -> R) {}
| ^^^ required by this bound in `foo`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
------------------------------------------
---- [ui] tests/ui/nll/issue-52663-trait-object.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-52663-trait-object/issue-52663-trait-object.stderr"
diff of stderr:
6 LL | let tmp1 = &tmp0;
7 | ^^^^^ borrowed value does not live long enough
8 LL | Box::new(tmp1) as Box<dyn Foo + '_>
- | ----------------------------------- borrow later captured here by trait object
10 LL | };
11 | - `tmp0` dropped here while still borrowed
12
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args nll/issue-52663-trait-object.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/nll/issue-52663-trait-object.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/nll/issue-52663-trait-object" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `tmp0` does not live long enough
##[error] --> /checkout/tests/ui/nll/issue-52663-trait-object.rs:12:20
|
LL | let tmp0 = 3;
| ---- binding `tmp0` declared here
LL | let tmp1 = &tmp0;
| ^^^^^ borrowed value does not live long enough
LL | Box::new(tmp1) as Box<dyn Foo + '_>
LL | };
| - `tmp0` dropped here while still borrowed
error: aborting due to 1 previous error
---
---- [ui] tests/ui/span/regions-close-over-type-parameter-2.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/regions-close-over-type-parameter-2/regions-close-over-type-parameter-2.stderr"
diff of stderr:
6 LL | let tmp1 = &tmp0;
7 | ^^^^^ borrowed value does not live long enough
8 LL | repeater3(tmp1)
- | --------------- borrow later captured here by trait object
10 LL | };
11 | - `tmp0` dropped here while still borrowed
---
To only update this specific test, also pass `--test-args span/regions-close-over-type-parameter-2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/span/regions-close-over-type-parameter-2.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/span/regions-close-over-type-parameter-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `tmp0` does not live long enough
##[error] --> /checkout/tests/ui/span/regions-close-over-type-parameter-2.rs:23:20
|
LL | let tmp0 = 3;
| ---- binding `tmp0` declared here
LL | let tmp1 = &tmp0;
| ^^^^^ borrowed value does not live long enough
LL | repeater3(tmp1)
LL | };
| - `tmp0` dropped here while still borrowed
---
+ --> $DIR/different_defining_uses_never_type-2.rs:13:23
9 |
- LL | x
- | ^
+ LL | let x: Tait<'a> = ();
+ | ^^
12
13 error: aborting due to 1 previous error
14
Note: some mismatched output was normalized before being compared
- --> /checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs:13:23
+ --> $DIR/different_defining_uses_never_type-2.rs:13:23
+ LL | let x: Tait<'a> = ();
+ | ^^
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args type-alias-impl-trait/different_defining_uses_never_type-2.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/different_defining_uses_never_type-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: concrete type differs from previous defining opaque type use
##[error] --> /checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs:9:31
|
LL | let y: Tait<'b> = 1i32;
| ^^^^ expected `()`, got `i32`
|
note: previous use here
--> /checkout/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs:13:23
|
LL | let x: Tait<'a> = ();
---
---- [ui] tests/ui/type-alias-impl-trait/issue-94429.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/issue-94429/issue-94429.stderr"
diff of stderr:
1 error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:18:9: 18:16} as Coroutine>::Yield == ()`
2 --> $DIR/issue-94429.rs:15:26
3 |
- LL | fn run(&mut self) -> Self::Coro {
- | ^^^^^^^^^^ expected `()`, found integer
+ LL | fn run(&mut self) -> Self::Coro {
+ | ^^^^^^^^^^ expected `()`, found integer
+ ...
+ LL | / move || {
+ LL | | yield 1;
+ LL | | }
+ | |_________- return type was inferred to be `{coroutine@$DIR/issue-94429.rs:18:9: 18:16}` here
6
7 error: aborting due to 1 previous error
8
Note: some mismatched output was normalized before being compared
- | |_________- return type was inferred to be `{coroutine@/checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:18:9: 18:16}` here
+ LL | fn run(&mut self) -> Self::Coro {
+ | ^^^^^^^^^^ expected `()`, found integer
+ ...
+ LL | / move || {
+ LL | | yield 1;
+ LL | | }
+ | |_________- return type was inferred to be `{coroutine@$DIR/issue-94429.rs:18:9: 18:16}` here
The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args type-alias-impl-trait/issue-94429.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/type-alias-impl-trait/issue-94429.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/issue-94429" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0271]: type mismatch resolving `<{coroutine@/checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:18:9: 18:16} as Coroutine>::Yield == ()`
##[error] --> /checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:15:26
|
LL | fn run(&mut self) -> Self::Coro {
| ^^^^^^^^^^ expected `()`, found integer
...
LL | / move || {
LL | | yield 1;
LL | | }
| |_________- return type was inferred to be `{coroutine@/checkout/tests/ui/type-alias-impl-trait/issue-94429.rs:18:9: 18:16}` here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.
------------------------------------------
---- [ui] tests/ui/weird-exprs.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/weird-exprs.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" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/weird-exprs/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0282]: type annotations needed
##[error] --> /checkout/tests/ui/weird-exprs.rs:246:22
|
Turns out the ‘easy’ cases aren’t so easy after all. I can't fix the inference regressions for now, but I might revisit them later once I understand type inference better.
@rustbot ready
I am not going to get to this in the next 10 days. I'll need to review the general state of inference here and write a T-types FCP text
:umbrella: The latest upstream changes (presumably #141716) made this pull request unmergeable. Please resolve the merge conflicts.
Array expressions normally lub their element expressions' types to ensure that things like [5, 5_u8] work and don't result in type mismatches. When invoking a generic function fn foo<T>(_: [T; N]) with an array expression, we end up with an infer var for the element type of the array in the signature. So when typecking the first array element we compare its type with the infer var and thus subsequently require all other elements to be the same type.
This PR changes that to instead fall back to "not knowing" that the argument type is array of infer var, but just having an infer var for the entire argument. Thus we typeck the array expression normally, lubbing the element expressions, and then in the end comparing the array expression's type with the array of infer var type.
Things like
fn foo() {}
fn bar() {}
fn f<T>(_: [T; 2]) {}
f([foo, bar]);
and
struct Foo;
struct Bar;
trait Trait {}
impl Trait for Foo {}
impl Trait for Bar {}
fn f<T>(_: [T; 2]) {}
f([&Foo, &Bar as &dyn Trait]);
@rfcbot merge
Team member @oli-obk has proposed to merge this. The next step is review by the rest of the tagged team members:
- [ ] @BoxyUwU
- [x] @compiler-errors
- [x] @jackh726
- [x] @lcnr
- [ ] @nikomatsakis
- [x] @oli-obk
- [x] @spastorino
Concerns:
- ~~try going all the way, no expectation~~ resolved by https://github.com/rust-lang/rust/pull/140283#issuecomment-3223681505
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
should we crater this too?
@bors2 try
:lock: Merge conflict
This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.
How do I rebase?
Assuming self is your fork and upstream is this repository,
you can resolve the conflict following these steps:
git checkout fn-pointer-coercion(switch to your branch)git fetch upstream master(retrieve the latest master)git rebase upstream/master -p(rebase on top of it)- Follow the on-screen instruction to resolve conflicts (check
git statusif you got lost). git push self fn-pointer-coercion --force-with-lease(update this PR)
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.
Please avoid the "Resolve conflicts" button on GitHub.
It uses git merge instead of git rebase which makes the PR commit history more difficult to read.
Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is
handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.
As a more general fix and something which should fix pretty much all cases where these sorts of coercions go wrong, could we instead hcange
CoerceMany::maketo fold the expected type and replace all infer vars with fresh new ones? Now, this also breaks some code, notably this weakensdeduce_closure_signature. However, given that closures in such matches aren't supported anyways once they are in more than one branch, this feels like a more general and more desirable fix
I tried this at first, but it resulted in too many errors. I think one reason is that constraints on the old inference variables are missing when we create fresh ones.
I tried this at first, but it resulted in too many errors.
Can you share an example snippet which failed? I would assume that we still constrain the original variable when we actually equate the returned type in the parent.
This is how I fold the type vars in CoerceMany.
Failed ui tests (Some diagnostics changes are excluded)
- tests/ui/drop/lint-tail-expr-drop-order-borrowck.rs
- tests/ui/coroutine/type-mismatch-error.rs
- tests/ui/closures/issue-78720.rs
- tests/ui/coroutine/type-mismatch-signature-deduction.rs
- tests/ui/coercion/coerce-unify.rs
- tests/ui/expr/if/if-else-type-mismatch.rs
- tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs#next
- tests/ui/lazy-type-alias-impl-trait/branches3.rs
- tests/ui/never_type/fallback-closure-ret.rs#fallback
- tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
- tests/ui/type-alias-impl-trait/closures_in_branches.rs
- tests/ui/suggestions/if-then-neeing-semi.rs
- tests/ui/suggestions/return-bindings.rs
- tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs#next
- tests/ui/weird-exprs.rs
Pick one example, coerce-unify.rs.
pub fn main() {
let s = String::from("bar");
let _ = [("a", Default::default()), (Default::default(), "b"), (&s, &s)];
}
Its compilation error:
error[E0308]: mismatched types
--> coerce-unify.rs:3:68
|
3 | let _ = [("a", Default::default()), (Default::default(), "b"), (&s, &s)];
| ^^^^^^^^ expected `(&str, &str)`, found `(&String, &String)`
|
= note: expected tuple `(&str, &str)`
found tuple `(&String, &String)`
Let's call the expectation type var in check_expr_array arguments ?external.
Before the change, ?external obtains additional constraints as it's used in the first two tuples' coercions so that when typecking the third tuple, ?external is known to be (&str, &str) and the &String -> &str coercion is done in check_expr_tuple. Then the (&str, &str) -> (&str, &str) in CoerceMany is easy.
After the change, ?external is not affected by the coercions and remains unknown. So the &String -> &str coercion doesn't happen during typecking the third tuple and now we have (&String, &String) -> (&str, &str) in CoerceMany which it doens't handle.
this is surprising to me :thinking: while the expected type in check_expr_array starts out as an infer var, shouldn't we replace it with a new one at the start of coercion which then also gets constrained to (&str, &str) before we get to the last branch.
Is the issue here that in the pushed == 0 case u map the expected_ty but don't actually replace self.expected_ty, so accessing that field again uses the old infer vars again?
Ah no, the issue is that you're updating the expected_ty too late, you need the same "fudged" type as the expected type of the coercion and as the coerce_to here https://github.com/rust-lang/rust/blob/40daf23eeb711dadf140b2536e67e3ff4c999196/compiler/rustc_hir_typeck/src/expr.rs#L1794-L1797
Ah, you're right. I should do the replacement right before CoerceMany construction to avoid unnecessary intermediate type vars and use the new expected_ty as expectation to guide type inference.
This change make some failed tests compile again. Let me look into the rest.
@rustbot author
Reminder, once the PR becomes ready for a review, use @rustbot ready.
By now, I think using type variable to guide elements' type inference is an accident. Although the following works, it's quite brittle.
pub fn main() {
let s = String::from("bar");
let _ = [("a", Default::default()), (Default::default(), "b"), (&s, &s)]; // compiles.
}
Since the type variable is always unified with the first expr's type, it can be a wrong expectation for the remaining expressions.
fn foo() {}
fn bar() {}
fn main() {
let _ = [foo, if false { bar } else { foo }]; // type mismatch when trying to coerce `bar` into `foo`.
}
On the contrary, if doesn't guide inference but gets typecking right.
pub fn main() {
let s = String::from("bar");
let _ = if false { // `if` uses `NoExpectation` for typecking when the expected_ty is a type variable.
("a", Default::default())
} else if false {
(Default::default(), "b")
} else {
(&s, &s) // incompatible types: expected `(_, &str)`, found `(&String, &String)`
};
}
fn foo() {}
fn bar() {}
fn main() {
let _ = if false { // compiles.
foo
} else {
if false {
bar
} else {
foo
}
};
}
As for mentioned tuple coercion support,
fn foo() {}
fn bar() {}
fn mk<T>() -> T { todo!() }
fn main() {
let mut x = (mk(),);
x = match false {
true => (foo,),
false => (bar,),
}
}
it's a non-trivial task. Tuples can be nested arbitrarily. As we try to refine the LUB type at each new coercion site, we need to apply adjustments to each field of previous expressions recursively. This seems to complicate coercion a lot.
hmm, I don't feel like I've got a good grasp of the way this works rn (and it's definitely not in cache for me rn)
I do think treating array expressions teh same as if and match is better than the status quo however and I think I agree with you after thinking about it for a while, I am not yet totally confident that there does not exist a nice and more powerful alternative here.
@rfcbot fcp reviewed
Filed a separate issue #145048 to track the nested coercion bug.
@rustbot ready
ah wait, can you actually try to perfectly match the if/match behavior :thinking: it feels weird to weaken inference without going all the way here.
We can crater and look at the actual regressions in the wild
@rfcbot concern try going all the way, no expectation
@bors try
:hourglass: Trying commit a7b44b91e22eb532e15e9a3b0bfaf717ce244e14 with merge 025d58aecdbd770ed5ba6b801e3077393321cdb5…
To cancel the try build, run the command @bors try cancel.
The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)
Click to see the possible cause of the failure (guessed by this bot)
Compiling rustc_lint v0.0.0 (/checkout/compiler/rustc_lint)
error[E0308]: mismatched types
--> compiler/rustc_metadata/src/locator.rs:435:17
|
435 | (dylib_prefix, dylib_suffix, CrateFlavor::Dylib),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(&str, &str, CrateFlavor)`, found `(&String, &Cow<'_, str>, CrateFlavor)`
|
= note: expected tuple `(&str, &str, CrateFlavor)`
found tuple `(&std::string::String, &Cow<'_, str>, CrateFlavor)`
For more information about this error, try `rustc --explain E0308`.
[RUSTC-TIMING] rustc_metadata test:false 4.406
error: could not compile `rustc_metadata` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...