Skip to content

Commit d80c3fe

Browse files
committed
Auto merge of rust-lang#130876 - matthiaskrgr:rollup-ntrxdhe, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#130820 (Fix diagnostics for coroutines with () as input.) - rust-lang#130833 (Fix the misleading diagnostic for `let_underscore_drop` on type without `Drop` implementation) - rust-lang#130845 (Utf8Chunks: add link to Utf8Chunk) - rust-lang#130860 (Fix directives for lint-non-snake-case-crate) - rust-lang#130868 (Update FIXME comment in s390x_unknown_linux_*.rs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 76ed7a1 + e383444 commit d80c3fe

15 files changed

+83
-57
lines changed

Diff for: compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ lint_non_binding_let_multi_suggestion =
531531
consider immediately dropping the value
532532
533533
lint_non_binding_let_on_drop_type =
534-
non-binding let on a type that implements `Drop`
534+
non-binding let on a type that has a destructor
535535
536536
lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
537537
.label = this lock is not assigned to a binding and is immediately dropped

Diff for: compiler/rustc_lint/src/let_underscore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ declare_lint! {
5151
/// intent.
5252
pub LET_UNDERSCORE_DROP,
5353
Allow,
54-
"non-binding let on a type that implements `Drop`"
54+
"non-binding let on a type that has a destructor"
5555
}
5656

5757
declare_lint! {

Diff for: compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
66
base.endian = Endian::Big;
77
// z10 is the oldest CPU supported by LLVM
88
base.cpu = "z10".into();
9-
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
10-
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
11-
// also strip v128 from the data_layout below to match the older LLVM's expectation.
9+
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
10+
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
1211
base.features = "-vector".into();
1312
base.max_atomic_width = Some(128);
1413
base.min_global_align = Some(16);

Diff for: compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
66
base.endian = Endian::Big;
77
// z10 is the oldest CPU supported by LLVM
88
base.cpu = "z10".into();
9-
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
10-
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
11-
// also strip v128 from the data_layout below to match the older LLVM's expectation.
9+
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
10+
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
1211
base.features = "-vector".into();
1312
base.max_atomic_width = Some(128);
1413
base.min_global_align = Some(16);

Diff for: compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+35-37
Original file line numberDiff line numberDiff line change
@@ -2635,49 +2635,47 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
26352635
// This shouldn't be common unless manually implementing one of the
26362636
// traits manually, but don't make it more confusing when it does
26372637
// happen.
2638-
Ok(
2639-
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait()
2640-
&& not_tupled
2641-
{
2642-
self.report_and_explain_type_error(
2643-
TypeTrace::trait_refs(
2644-
&obligation.cause,
2645-
true,
2646-
expected_trait_ref,
2647-
found_trait_ref,
2648-
),
2649-
ty::error::TypeError::Mismatch,
2650-
)
2651-
} else if found.len() == expected.len() {
2652-
self.report_closure_arg_mismatch(
2653-
span,
2654-
found_span,
2655-
found_trait_ref,
2656-
expected_trait_ref,
2657-
obligation.cause.code(),
2658-
found_node,
2659-
obligation.param_env,
2660-
)
2661-
} else {
2662-
let (closure_span, closure_arg_span, found) = found_did
2663-
.and_then(|did| {
2664-
let node = self.tcx.hir().get_if_local(did)?;
2665-
let (found_span, closure_arg_span, found) =
2666-
self.get_fn_like_arguments(node)?;
2667-
Some((Some(found_span), closure_arg_span, found))
2668-
})
2669-
.unwrap_or((found_span, None, found));
2670-
2671-
self.report_arg_count_mismatch(
2638+
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait() && not_tupled
2639+
{
2640+
return Ok(self.report_and_explain_type_error(
2641+
TypeTrace::trait_refs(&obligation.cause, true, expected_trait_ref, found_trait_ref),
2642+
ty::error::TypeError::Mismatch,
2643+
));
2644+
}
2645+
if found.len() != expected.len() {
2646+
let (closure_span, closure_arg_span, found) = found_did
2647+
.and_then(|did| {
2648+
let node = self.tcx.hir().get_if_local(did)?;
2649+
let (found_span, closure_arg_span, found) = self.get_fn_like_arguments(node)?;
2650+
Some((Some(found_span), closure_arg_span, found))
2651+
})
2652+
.unwrap_or((found_span, None, found));
2653+
2654+
// If the coroutine take a single () as its argument,
2655+
// the trait argument would found the coroutine take 0 arguments,
2656+
// but get_fn_like_arguments would give 1 argument.
2657+
// This would result in "Expected to take 1 argument, but it takes 1 argument".
2658+
// Check again to avoid this.
2659+
if found.len() != expected.len() {
2660+
return Ok(self.report_arg_count_mismatch(
26722661
span,
26732662
closure_span,
26742663
expected,
26752664
found,
26762665
found_trait_ty.is_closure(),
26772666
closure_arg_span,
2678-
)
2679-
},
2680-
)
2667+
));
2668+
}
2669+
}
2670+
Ok(self.report_closure_arg_mismatch(
2671+
span,
2672+
found_span,
2673+
found_trait_ref,
2674+
expected_trait_ref,
2675+
obligation.cause.code(),
2676+
found_node,
2677+
obligation.param_env,
2678+
))
26812679
}
26822680

26832681
/// Given some node representing a fn-like thing in the HIR map,

Diff for: library/core/src/str/lossy.rs

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ impl [u8] {
88
/// Creates an iterator over the contiguous valid UTF-8 ranges of this
99
/// slice, and the non-UTF-8 fragments in between.
1010
///
11+
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
12+
///
1113
/// # Examples
1214
///
1315
/// This function formats arbitrary but mostly-UTF-8 bytes into Rust source
@@ -148,6 +150,8 @@ impl fmt::Debug for Debug<'_> {
148150
/// If you want a simple conversion from UTF-8 byte slices to string slices,
149151
/// [`from_utf8`] is easier to use.
150152
///
153+
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
154+
///
151155
/// [byteslice]: slice
152156
/// [`from_utf8`]: super::from_utf8
153157
///
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
2+
3+
use std::ops::Coroutine;
4+
5+
fn foo() -> impl Coroutine<u8> {
6+
//~^ ERROR type mismatch in coroutine arguments
7+
#[coroutine]
8+
|_: ()| {}
9+
}
10+
11+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0631]: type mismatch in coroutine arguments
2+
--> $DIR/arg-count-mismatch-on-unit-input.rs:5:13
3+
|
4+
LL | fn foo() -> impl Coroutine<u8> {
5+
| ^^^^^^^^^^^^^^^^^^ expected due to this
6+
...
7+
LL | |_: ()| {}
8+
| ------- found signature defined here
9+
|
10+
= note: expected coroutine signature `fn(u8) -> _`
11+
found coroutine signature `fn(()) -> _`
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0631`.

Diff for: tests/ui/lint/let_underscore/issue-119696-err-on-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#![deny(let_underscore_drop)]
44
fn main() {
5-
let _ = foo(); //~ ERROR non-binding let on a type that implements `Drop`
5+
let _ = foo(); //~ ERROR non-binding let on a type that has a destructor
66
}
77

88
async fn from_config(_: Config) {}

Diff for: tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: non-binding let on a type that implements `Drop`
1+
error: non-binding let on a type that has a destructor
22
--> $DIR/issue-119696-err-on-fn.rs:5:5
33
|
44
LL | let _ = foo();

Diff for: tests/ui/lint/let_underscore/issue-119697-extra-let.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ pub fn ice_cold(beverage: Tait) {
1212
// Must destructure at least one field of `Foo`
1313
let Foo { field } = beverage;
1414
// boom
15-
_ = field; //~ ERROR non-binding let on a type that implements `Drop`
15+
_ = field; //~ ERROR non-binding let on a type that has a destructor
1616

17-
let _ = field; //~ ERROR non-binding let on a type that implements `Drop`
17+
let _ = field; //~ ERROR non-binding let on a type that has a destructor
1818
}
1919

2020

Diff for: tests/ui/lint/let_underscore/issue-119697-extra-let.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: non-binding let on a type that implements `Drop`
1+
error: non-binding let on a type that has a destructor
22
--> $DIR/issue-119697-extra-let.rs:15:5
33
|
44
LL | _ = field;
@@ -18,7 +18,7 @@ help: consider immediately dropping the value
1818
LL | drop(field);
1919
| ~~~~~ +
2020

21-
error: non-binding let on a type that implements `Drop`
21+
error: non-binding let on a type that has a destructor
2222
--> $DIR/issue-119697-extra-let.rs:17:5
2323
|
2424
LL | let _ = field;

Diff for: tests/ui/lint/let_underscore/let_underscore_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl Drop for NontrivialDrop {
1010
}
1111

1212
fn main() {
13-
let _ = NontrivialDrop; //~WARNING non-binding let on a type that implements `Drop`
13+
let _ = NontrivialDrop; //~WARNING non-binding let on a type that has a destructor
1414

1515
let (_, _) = (NontrivialDrop, NontrivialDrop); // This should be ignored.
1616
}

Diff for: tests/ui/lint/let_underscore/let_underscore_drop.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: non-binding let on a type that implements `Drop`
1+
warning: non-binding let on a type that has a destructor
22
--> $DIR/let_underscore_drop.rs:13:5
33
|
44
LL | let _ = NontrivialDrop;

Diff for: tests/ui/lint/non-snake-case/lint-non-snake-case-crate.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
// But should fire on non-binary crates.
1212

13-
//@[cdylib_] ignore-musl (dylibs are not supported)
14-
//@[dylib_] ignore-musl (dylibs are not supported)
15-
//@[dylib_] ignore-wasm (dylib is not supported)
16-
//@[proc_macro_] ignore-wasm (dylib is not supported)
13+
//@[cdylib_] needs-dynamic-linking
14+
//@[dylib_] needs-dynamic-linking
15+
//@[proc_macro_] force-host
16+
//@[proc_macro_] no-prefer-dynamic
1717

1818
//@[cdylib_] compile-flags: --crate-type=cdylib
1919
//@[dylib_] compile-flags: --crate-type=dylib

0 commit comments

Comments
 (0)