Skip to content

Commit ac5ac47

Browse files
committed
Auto merge of rust-lang#115979 - GuillaumeGomez:rollup-06ujzgh, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#113383 (style-guide: Add section on bugs, and resolving bugs) - rust-lang#115499 (rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member) - rust-lang#115801 (Detect cycle errors hidden by opaques during monomorphization) - rust-lang#115947 (Custom code classes in docs warning) - rust-lang#115957 (fix mismatched symbols) - rust-lang#115958 (explain mysterious addition in float minimum/maximum) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 42f5828 + 1b86218 commit ac5ac47

21 files changed

+385
-147
lines changed

compiler/rustc_middle/src/ty/layout.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,10 @@ where
11181118
fn is_unit(this: TyAndLayout<'tcx>) -> bool {
11191119
matches!(this.ty.kind(), ty::Tuple(list) if list.len() == 0)
11201120
}
1121+
1122+
fn is_transparent(this: TyAndLayout<'tcx>) -> bool {
1123+
matches!(this.ty.kind(), ty::Adt(def, _) if def.repr().transparent())
1124+
}
11211125
}
11221126

11231127
/// Calculates whether a function's ABI can unwind or not.

compiler/rustc_target/src/abi/call/riscv.rs

+11
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ where
8989
}
9090
FieldsShape::Union(_) => {
9191
if !arg_layout.is_zst() {
92+
if arg_layout.is_transparent() {
93+
let non_1zst_elem = arg_layout.non_1zst_field(cx).expect("not exactly one non-1-ZST field in non-ZST repr(transparent) union").1;
94+
return should_use_fp_conv_helper(
95+
cx,
96+
&non_1zst_elem,
97+
xlen,
98+
flen,
99+
field1_kind,
100+
field2_kind,
101+
);
102+
}
92103
return Err(CannotUseFpConv);
93104
}
94105
}

compiler/rustc_target/src/abi/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub trait TyAbiInterface<'a, C>: Sized + std::fmt::Debug {
6666
fn is_never(this: TyAndLayout<'a, Self>) -> bool;
6767
fn is_tuple(this: TyAndLayout<'a, Self>) -> bool;
6868
fn is_unit(this: TyAndLayout<'a, Self>) -> bool;
69+
fn is_transparent(this: TyAndLayout<'a, Self>) -> bool;
6970
}
7071

7172
impl<'a, Ty> TyAndLayout<'a, Ty> {
@@ -136,6 +137,13 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
136137
Ty::is_unit(self)
137138
}
138139

140+
pub fn is_transparent<C>(self) -> bool
141+
where
142+
Ty: TyAbiInterface<'a, C>,
143+
{
144+
Ty::is_transparent(self)
145+
}
146+
139147
pub fn offset_of_subfield<C>(self, cx: &C, indices: impl Iterator<Item = usize>) -> Size
140148
where
141149
Ty: TyAbiInterface<'a, C>,

compiler/rustc_traits/src/normalize_projection_ty.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ use rustc_infer::infer::TyCtxtInferExt;
33
use rustc_middle::query::Providers;
44
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
55
use rustc_trait_selection::infer::InferCtxtBuilderExt;
6+
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
67
use rustc_trait_selection::traits::query::{
78
normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution,
89
};
9-
use rustc_trait_selection::traits::{self, ObligationCause, SelectionContext};
10+
use rustc_trait_selection::traits::{
11+
self, FulfillmentErrorCode, ObligationCause, SelectionContext,
12+
};
1013
use std::sync::atomic::Ordering;
1114

1215
pub(crate) fn provide(p: &mut Providers) {
@@ -40,6 +43,27 @@ fn normalize_projection_ty<'tcx>(
4043
&mut obligations,
4144
);
4245
ocx.register_obligations(obligations);
46+
// #112047: With projections and opaques, we are able to create opaques that
47+
// are recursive (given some substitution of the opaque's type variables).
48+
// In that case, we may only realize a cycle error when calling
49+
// `normalize_erasing_regions` in mono.
50+
if !ocx.infcx.next_trait_solver() {
51+
let errors = ocx.select_where_possible();
52+
if !errors.is_empty() {
53+
// Rustdoc may attempt to normalize type alias types which are not
54+
// well-formed. Rustdoc also normalizes types that are just not
55+
// well-formed, since we don't do as much HIR analysis (checking
56+
// that impl vars are constrained by the signature, for example).
57+
if !tcx.sess.opts.actually_rustdoc {
58+
for error in &errors {
59+
if let FulfillmentErrorCode::CodeCycle(cycle) = &error.code {
60+
ocx.infcx.err_ctxt().report_overflow_obligation_cycle(cycle);
61+
}
62+
}
63+
}
64+
return Err(NoSolution);
65+
}
66+
}
4367
// FIXME(associated_const_equality): All users of normalize_projection_ty expected
4468
// a type, but there is the possibility it could've been a const now. Maybe change
4569
// it to a Term later?

library/core/src/num/f32.rs

+1
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ impl f32 {
957957
} else if self == other {
958958
if self.is_sign_negative() && other.is_sign_positive() { self } else { other }
959959
} else {
960+
// At least one input is NaN. Use `+` to perform NaN propagation and quieting.
960961
self + other
961962
}
962963
}

library/core/src/num/f64.rs

+1
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ impl f64 {
968968
} else if self == other {
969969
if self.is_sign_negative() && other.is_sign_positive() { self } else { other }
970970
} else {
971+
// At least one input is NaN. Use `+` to perform NaN propagation and quieting.
971972
self + other
972973
}
973974
}

src/bootstrap/job.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub unsafe fn setup(build: &mut Build) {
134134
// If this failed, well at least we tried! An example of DuplicateHandle
135135
// failing in the past has been when the wrong python2 package spawned this
136136
// build system (e.g., the `python2` package in MSYS instead of
137-
// `mingw-w64-x86_64-python2`. Not sure why it failed, but the "failure
137+
// `mingw-w64-x86_64-python2`). Not sure why it failed, but the "failure
138138
// mode" here is that we only clean everything up when the build system
139139
// dies, not when the python parent does, so not too bad.
140140
if r.is_err() {

src/doc/style-guide/src/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ This should not be interpreted as forbidding developers from following a
3232
non-default style, or forbidding tools from adding any particular configuration
3333
options.
3434

35+
## Bugs
36+
37+
If the style guide differs from rustfmt, that may represent a bug in rustfmt,
38+
or a bug in the style guide; either way, please report it to the style team or
39+
the rustfmt team or both, for investigation and fix.
40+
41+
If implementing a new formatting tool based on the style guide and default Rust
42+
style, please test it on the corpus of existing Rust code, and avoid causing
43+
widespread breakage. The implementation and testing of such a tool may surface
44+
bugs in either the style guide or rustfmt, as well as bugs in the tool itself.
45+
46+
We typically resolve bugs in a fashion that avoids widespread breakage.
47+
3548
## Formatting conventions
3649

3750
### Indentation and line width

0 commit comments

Comments
 (0)