Skip to content

Commit

Permalink
Auto merge of rust-lang#130876 - matthiaskrgr:rollup-ntrxdhe, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

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
  • Loading branch information
bors committed Sep 26, 2024
2 parents 76ed7a1 + e383444 commit d80c3fe
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 57 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ lint_non_binding_let_multi_suggestion =
consider immediately dropping the value
lint_non_binding_let_on_drop_type =
non-binding let on a type that implements `Drop`
non-binding let on a type that has a destructor
lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
.label = this lock is not assigned to a binding and is immediately dropped
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ declare_lint! {
/// intent.
pub LET_UNDERSCORE_DROP,
Allow,
"non-binding let on a type that implements `Drop`"
"non-binding let on a type that has a destructor"
}

declare_lint! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
// also strip v128 from the data_layout below to match the older LLVM's expectation.
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
base.features = "-vector".into();
base.max_atomic_width = Some(128);
base.min_global_align = Some(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
// also strip v128 from the data_layout below to match the older LLVM's expectation.
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
base.features = "-vector".into();
base.max_atomic_width = Some(128);
base.min_global_align = Some(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2635,49 +2635,47 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// This shouldn't be common unless manually implementing one of the
// traits manually, but don't make it more confusing when it does
// happen.
Ok(
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait()
&& not_tupled
{
self.report_and_explain_type_error(
TypeTrace::trait_refs(
&obligation.cause,
true,
expected_trait_ref,
found_trait_ref,
),
ty::error::TypeError::Mismatch,
)
} else if found.len() == expected.len() {
self.report_closure_arg_mismatch(
span,
found_span,
found_trait_ref,
expected_trait_ref,
obligation.cause.code(),
found_node,
obligation.param_env,
)
} else {
let (closure_span, closure_arg_span, found) = found_did
.and_then(|did| {
let node = self.tcx.hir().get_if_local(did)?;
let (found_span, closure_arg_span, found) =
self.get_fn_like_arguments(node)?;
Some((Some(found_span), closure_arg_span, found))
})
.unwrap_or((found_span, None, found));

self.report_arg_count_mismatch(
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait() && not_tupled
{
return Ok(self.report_and_explain_type_error(
TypeTrace::trait_refs(&obligation.cause, true, expected_trait_ref, found_trait_ref),
ty::error::TypeError::Mismatch,
));
}
if found.len() != expected.len() {
let (closure_span, closure_arg_span, found) = found_did
.and_then(|did| {
let node = self.tcx.hir().get_if_local(did)?;
let (found_span, closure_arg_span, found) = self.get_fn_like_arguments(node)?;
Some((Some(found_span), closure_arg_span, found))
})
.unwrap_or((found_span, None, found));

// If the coroutine take a single () as its argument,
// the trait argument would found the coroutine take 0 arguments,
// but get_fn_like_arguments would give 1 argument.
// This would result in "Expected to take 1 argument, but it takes 1 argument".
// Check again to avoid this.
if found.len() != expected.len() {
return Ok(self.report_arg_count_mismatch(
span,
closure_span,
expected,
found,
found_trait_ty.is_closure(),
closure_arg_span,
)
},
)
));
}
}
Ok(self.report_closure_arg_mismatch(
span,
found_span,
found_trait_ref,
expected_trait_ref,
obligation.cause.code(),
found_node,
obligation.param_env,
))
}

/// Given some node representing a fn-like thing in the HIR map,
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/str/lossy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ impl [u8] {
/// Creates an iterator over the contiguous valid UTF-8 ranges of this
/// slice, and the non-UTF-8 fragments in between.
///
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
///
/// # Examples
///
/// This function formats arbitrary but mostly-UTF-8 bytes into Rust source
Expand Down Expand Up @@ -148,6 +150,8 @@ impl fmt::Debug for Debug<'_> {
/// If you want a simple conversion from UTF-8 byte slices to string slices,
/// [`from_utf8`] is easier to use.
///
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
///
/// [byteslice]: slice
/// [`from_utf8`]: super::from_utf8
///
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/coroutine/arg-count-mismatch-on-unit-input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]

use std::ops::Coroutine;

fn foo() -> impl Coroutine<u8> {
//~^ ERROR type mismatch in coroutine arguments
#[coroutine]
|_: ()| {}
}

fn main() { }
15 changes: 15 additions & 0 deletions tests/ui/coroutine/arg-count-mismatch-on-unit-input.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0631]: type mismatch in coroutine arguments
--> $DIR/arg-count-mismatch-on-unit-input.rs:5:13
|
LL | fn foo() -> impl Coroutine<u8> {
| ^^^^^^^^^^^^^^^^^^ expected due to this
...
LL | |_: ()| {}
| ------- found signature defined here
|
= note: expected coroutine signature `fn(u8) -> _`
found coroutine signature `fn(()) -> _`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0631`.
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/issue-119696-err-on-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

async fn from_config(_: Config) {}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: non-binding let on a type that implements `Drop`
error: non-binding let on a type that has a destructor
--> $DIR/issue-119696-err-on-fn.rs:5:5
|
LL | let _ = foo();
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lint/let_underscore/issue-119697-extra-let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pub fn ice_cold(beverage: Tait) {
// Must destructure at least one field of `Foo`
let Foo { field } = beverage;
// boom
_ = field; //~ ERROR non-binding let on a type that implements `Drop`
_ = field; //~ ERROR non-binding let on a type that has a destructor

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


Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lint/let_underscore/issue-119697-extra-let.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: non-binding let on a type that implements `Drop`
error: non-binding let on a type that has a destructor
--> $DIR/issue-119697-extra-let.rs:15:5
|
LL | _ = field;
Expand All @@ -18,7 +18,7 @@ help: consider immediately dropping the value
LL | drop(field);
| ~~~~~ +

error: non-binding let on a type that implements `Drop`
error: non-binding let on a type that has a destructor
--> $DIR/issue-119697-extra-let.rs:17:5
|
LL | let _ = field;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/let_underscore_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Drop for NontrivialDrop {
}

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

let (_, _) = (NontrivialDrop, NontrivialDrop); // This should be ignored.
}
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/let_underscore_drop.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: non-binding let on a type that implements `Drop`
warning: non-binding let on a type that has a destructor
--> $DIR/let_underscore_drop.rs:13:5
|
LL | let _ = NontrivialDrop;
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/lint/non-snake-case/lint-non-snake-case-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

// But should fire on non-binary crates.

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

//@[cdylib_] compile-flags: --crate-type=cdylib
//@[dylib_] compile-flags: --crate-type=dylib
Expand Down

0 comments on commit d80c3fe

Please sign in to comment.