Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1572,26 +1572,31 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
[ast::PathSegment { args: None, .. }],
[ast::GenericBound::Trait(poly_trait_ref)],
) = (&type_param_path.segments[..], &bounds[..])
&& let [ast::PathSegment { ident, args: None, id }] =
&poly_trait_ref.trait_ref.path.segments[..]
&& poly_trait_ref.modifiers == ast::TraitBoundModifiers::NONE
{
if let [ast::PathSegment { ident, args: None, .. }] =
&poly_trait_ref.trait_ref.path.segments[..]
{
if ident.span == span {
let Some(new_where_bound_predicate) =
mk_where_bound_predicate(path, poly_trait_ref, ty)
else {
return false;
};
err.span_suggestion_verbose(
*where_span,
format!("constrain the associated type to `{ident}`"),
where_bound_predicate_to_string(&new_where_bound_predicate),
Applicability::MaybeIncorrect,
);
if ident.span == span {
let Some(partial_res) = self.r.partial_res_map.get(&id) else {
return false;
};
if !matches!(partial_res.full_res(), Some(hir::def::Res::Def(..))) {
return false;
}
return true;

let Some(new_where_bound_predicate) =
mk_where_bound_predicate(path, poly_trait_ref, ty)
else {
return false;
};
err.span_suggestion_verbose(
*where_span,
format!("constrain the associated type to `{ident}`"),
where_bound_predicate_to_string(&new_where_bound_predicate),
Applicability::MaybeIncorrect,
);
}
return true;
}
}
false
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ impl f128 {
/// Returns the maximum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand All @@ -723,8 +723,8 @@ impl f128 {
/// Returns the minimum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand Down Expand Up @@ -769,7 +769,7 @@ impl f128 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand Down Expand Up @@ -802,7 +802,7 @@ impl f128 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ impl f16 {
/// Returns the maximum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand All @@ -715,8 +715,8 @@ impl f16 {
/// Returns the minimum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand Down Expand Up @@ -759,7 +759,7 @@ impl f16 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand Down Expand Up @@ -791,7 +791,7 @@ impl f16 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,8 @@ impl f32 {
/// Returns the maximum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand All @@ -921,8 +921,8 @@ impl f32 {
/// Returns the minimum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand Down Expand Up @@ -957,7 +957,7 @@ impl f32 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand All @@ -984,7 +984,7 @@ impl f32 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ impl f64 {
/// Returns the maximum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand All @@ -939,8 +939,8 @@ impl f64 {
/// Returns the minimum of the two numbers, ignoring NaN.
///
/// If one of the arguments is NaN, then the other argument is returned.
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
///
Expand Down Expand Up @@ -975,7 +975,7 @@ impl f64 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand All @@ -1002,7 +1002,7 @@ impl f64 {
///
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
/// Note that this follows the semantics specified in IEEE 754-2019.
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
///
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
Expand Down
4 changes: 1 addition & 3 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@
//
// Language features:
// tidy-alphabetical-start

// stabilization was reverted after it hit beta
#![feature(alloc_error_handler)]
#![feature(allocator_internals)]
#![feature(allow_internal_unsafe)]
Expand Down Expand Up @@ -421,7 +419,7 @@
#![default_lib_allocator]

// The Rust prelude
// The compiler expects the prelude definition to be defined before it's use statement.
// The compiler expects the prelude definition to be defined before its use statement.
pub mod prelude;

// Explicitly import the prelude. The compiler uses this same unstable attribute
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
2 changes: 1 addition & 1 deletion src/doc/reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::str::FromStr;
fn foo<T: FromStr>() -> T
where
<T as FromStr>::Err: Debug, //~ ERROR expected trait
{
"".parse().unwrap()
}

fn bar<T: FromStr>() -> T
where
<T as FromStr>::Err: some_unknown_name, //~ ERROR cannot find trait `some_unknown_name` in this scope
{
"".parse().unwrap()
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0404]: expected trait, found derive macro `Debug`
--> $DIR/assoc-type-maybe-trait-147356.rs:4:26
|
LL | <T as FromStr>::Err: Debug,
| ^^^^^ not a trait
|
help: consider importing this trait instead
|
LL + use std::fmt::Debug;
|

error[E0405]: cannot find trait `some_unknown_name` in this scope
--> $DIR/assoc-type-maybe-trait-147356.rs:11:26
|
LL | <T as FromStr>::Err: some_unknown_name,
| ^^^^^^^^^^^^^^^^^ not found in this scope

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0404, E0405.
For more information about an error, try `rustc --explain E0404`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ compile-flags: -Znext-solver
//@ check-pass
//@ edition:2021

pub async fn cleanse_old_array_async(_: &[u8; BUCKET_LEN]) {}

pub const BUCKET_LEN: usize = 0;

pub fn cleanse_old_array_async2() -> impl std::future::Future {
let x: [u8; 0 + 0] = [];
async move { let _ = x; }
}

fn main() {}
Loading