Skip to content

Commit 3c5c558

Browse files
committed
Auto merge of #149441 - jhpratt:rollup-4hmqc0z, r=jhpratt
Rollup of 5 pull requests Successful merges: - #147362 (Avoid suggesting constrain the associated type with unknown type) - #149395 (float::minimum/maximum: say which exact IEEE operation this corresponds to) - #149396 (Remove outdated comment) - #149421 (Add a regression test for issue 129865) - #149424 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 467250d + e838b66 commit 3c5c558

File tree

12 files changed

+100
-46
lines changed

12 files changed

+100
-46
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,26 +1572,31 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
15721572
[ast::PathSegment { args: None, .. }],
15731573
[ast::GenericBound::Trait(poly_trait_ref)],
15741574
) = (&type_param_path.segments[..], &bounds[..])
1575+
&& let [ast::PathSegment { ident, args: None, id }] =
1576+
&poly_trait_ref.trait_ref.path.segments[..]
15751577
&& poly_trait_ref.modifiers == ast::TraitBoundModifiers::NONE
15761578
{
1577-
if let [ast::PathSegment { ident, args: None, .. }] =
1578-
&poly_trait_ref.trait_ref.path.segments[..]
1579-
{
1580-
if ident.span == span {
1581-
let Some(new_where_bound_predicate) =
1582-
mk_where_bound_predicate(path, poly_trait_ref, ty)
1583-
else {
1584-
return false;
1585-
};
1586-
err.span_suggestion_verbose(
1587-
*where_span,
1588-
format!("constrain the associated type to `{ident}`"),
1589-
where_bound_predicate_to_string(&new_where_bound_predicate),
1590-
Applicability::MaybeIncorrect,
1591-
);
1579+
if ident.span == span {
1580+
let Some(partial_res) = self.r.partial_res_map.get(&id) else {
1581+
return false;
1582+
};
1583+
if !matches!(partial_res.full_res(), Some(hir::def::Res::Def(..))) {
1584+
return false;
15921585
}
1593-
return true;
1586+
1587+
let Some(new_where_bound_predicate) =
1588+
mk_where_bound_predicate(path, poly_trait_ref, ty)
1589+
else {
1590+
return false;
1591+
};
1592+
err.span_suggestion_verbose(
1593+
*where_span,
1594+
format!("constrain the associated type to `{ident}`"),
1595+
where_bound_predicate_to_string(&new_where_bound_predicate),
1596+
Applicability::MaybeIncorrect,
1597+
);
15941598
}
1599+
return true;
15951600
}
15961601
}
15971602
false

library/core/src/num/f128.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ impl f128 {
695695
/// Returns the maximum of the two numbers, ignoring NaN.
696696
///
697697
/// If one of the arguments is NaN, then the other argument is returned.
698-
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
699-
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
698+
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
699+
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
700700
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
701701
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
702702
///
@@ -723,8 +723,8 @@ impl f128 {
723723
/// Returns the minimum of the two numbers, ignoring NaN.
724724
///
725725
/// If one of the arguments is NaN, then the other argument is returned.
726-
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
727-
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
726+
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
727+
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
728728
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
729729
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
730730
///
@@ -769,7 +769,7 @@ impl f128 {
769769
///
770770
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
771771
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
772-
/// Note that this follows the semantics specified in IEEE 754-2019.
772+
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
773773
///
774774
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
775775
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
@@ -802,7 +802,7 @@ impl f128 {
802802
///
803803
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
804804
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
805-
/// Note that this follows the semantics specified in IEEE 754-2019.
805+
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
806806
///
807807
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
808808
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.

library/core/src/num/f16.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ impl f16 {
688688
/// Returns the maximum of the two numbers, ignoring NaN.
689689
///
690690
/// If one of the arguments is NaN, then the other argument is returned.
691-
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
692-
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
691+
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
692+
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
693693
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
694694
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
695695
///
@@ -715,8 +715,8 @@ impl f16 {
715715
/// Returns the minimum of the two numbers, ignoring NaN.
716716
///
717717
/// If one of the arguments is NaN, then the other argument is returned.
718-
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
719-
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
718+
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
719+
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
720720
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
721721
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
722722
///
@@ -759,7 +759,7 @@ impl f16 {
759759
///
760760
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
761761
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
762-
/// Note that this follows the semantics specified in IEEE 754-2019.
762+
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
763763
///
764764
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
765765
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
@@ -791,7 +791,7 @@ impl f16 {
791791
///
792792
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
793793
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
794-
/// Note that this follows the semantics specified in IEEE 754-2019.
794+
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
795795
///
796796
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
797797
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.

library/core/src/num/f32.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,8 @@ impl f32 {
898898
/// Returns the maximum of the two numbers, ignoring NaN.
899899
///
900900
/// If one of the arguments is NaN, then the other argument is returned.
901-
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
902-
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
901+
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
902+
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
903903
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
904904
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
905905
///
@@ -921,8 +921,8 @@ impl f32 {
921921
/// Returns the minimum of the two numbers, ignoring NaN.
922922
///
923923
/// If one of the arguments is NaN, then the other argument is returned.
924-
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
925-
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
924+
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
925+
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
926926
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
927927
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
928928
///
@@ -957,7 +957,7 @@ impl f32 {
957957
///
958958
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
959959
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
960-
/// Note that this follows the semantics specified in IEEE 754-2019.
960+
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
961961
///
962962
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
963963
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
@@ -984,7 +984,7 @@ impl f32 {
984984
///
985985
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
986986
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
987-
/// Note that this follows the semantics specified in IEEE 754-2019.
987+
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
988988
///
989989
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
990990
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.

library/core/src/num/f64.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ impl f64 {
916916
/// Returns the maximum of the two numbers, ignoring NaN.
917917
///
918918
/// If one of the arguments is NaN, then the other argument is returned.
919-
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
920-
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
919+
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
920+
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
921921
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
922922
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
923923
///
@@ -939,8 +939,8 @@ impl f64 {
939939
/// Returns the minimum of the two numbers, ignoring NaN.
940940
///
941941
/// If one of the arguments is NaN, then the other argument is returned.
942-
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
943-
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
942+
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
943+
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
944944
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
945945
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
946946
///
@@ -975,7 +975,7 @@ impl f64 {
975975
///
976976
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
977977
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
978-
/// Note that this follows the semantics specified in IEEE 754-2019.
978+
/// Note that this follows the IEEE 754-2019 semantics for `maximum`.
979979
///
980980
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
981981
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.
@@ -1002,7 +1002,7 @@ impl f64 {
10021002
///
10031003
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
10041004
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
1005-
/// Note that this follows the semantics specified in IEEE 754-2019.
1005+
/// Note that this follows the IEEE 754-2019 semantics for `minimum`.
10061006
///
10071007
/// Also note that "propagation" of NaNs here doesn't necessarily mean that the bitpattern of a NaN
10081008
/// operand is conserved; see the [specification of NaN bit patterns](f32#nan-bit-patterns) for more info.

library/std/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@
265265
//
266266
// Language features:
267267
// tidy-alphabetical-start
268-
269-
// stabilization was reverted after it hit beta
270268
#![feature(alloc_error_handler)]
271269
#![feature(allocator_internals)]
272270
#![feature(allow_internal_unsafe)]
@@ -421,7 +419,7 @@
421419
#![default_lib_allocator]
422420

423421
// The Rust prelude
424-
// The compiler expects the prelude definition to be defined before it's use statement.
422+
// The compiler expects the prelude definition to be defined before its use statement.
425423
pub mod prelude;
426424

427425
// Explicitly import the prelude. The compiler uses this same unstable attribute
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use std::str::FromStr;
2+
fn foo<T: FromStr>() -> T
3+
where
4+
<T as FromStr>::Err: Debug, //~ ERROR expected trait
5+
{
6+
"".parse().unwrap()
7+
}
8+
9+
fn bar<T: FromStr>() -> T
10+
where
11+
<T as FromStr>::Err: some_unknown_name, //~ ERROR cannot find trait `some_unknown_name` in this scope
12+
{
13+
"".parse().unwrap()
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)