Skip to content

Commit 697ac29

Browse files
committed
Auto merge of #125499 - matthiaskrgr:rollup-84i5z5w, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #125455 (Make `clamp` inline) - #125477 (Run rustfmt on files that need it.) - #125481 (Fix the dead link in the bootstrap README) - #125482 (Notify kobzol after changes to `opt-dist`) - #125489 (Revert problematic opaque type change) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9e297bf + 1a165ec commit 697ac29

File tree

17 files changed

+185
-56
lines changed

17 files changed

+185
-56
lines changed

compiler/rustc_codegen_ssa/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, Debugger
2929
use rustc_middle::middle::exported_symbols;
3030
use rustc_middle::middle::exported_symbols::SymbolExportKind;
3131
use rustc_middle::middle::lang_items;
32-
use rustc_middle::mir::BinOp;
3332
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
33+
use rustc_middle::mir::BinOp;
3434
use rustc_middle::query::Providers;
3535
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
3636
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};

compiler/rustc_const_eval/src/const_eval/error.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ where
139139
ErrorHandled::TooGeneric(span)
140140
}
141141
err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar, span),
142-
err_inval!(Layout(LayoutError::ReferencesError(guar))) => ErrorHandled::Reported(
143-
ReportedErrorInfo::tainted_by_errors(guar),
144-
span,
145-
),
142+
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
143+
ErrorHandled::Reported(ReportedErrorInfo::tainted_by_errors(guar), span)
144+
}
146145
// Report remaining errors.
147146
_ => {
148147
let (our_span, frames) = get_span_and_frames();

compiler/rustc_incremental/src/persist/load.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ fn load_dep_graph(sess: &Session) -> LoadResult<(Arc<SerializedDepGraph>, WorkPr
116116

117117
if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
118118
// Decode the list of work_products
119-
let Ok(mut work_product_decoder) =
120-
MemDecoder::new(&work_products_data[..], start_pos)
119+
let Ok(mut work_product_decoder) = MemDecoder::new(&work_products_data[..], start_pos)
121120
else {
122121
sess.dcx().emit_warn(errors::CorruptFile { path: &work_products_path });
123122
return LoadResult::DataOutOfDate;

compiler/rustc_infer/src/infer/mod.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -957,27 +957,14 @@ impl<'tcx> InferCtxt<'tcx> {
957957
(&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => {
958958
return Err((a_vid, b_vid));
959959
}
960-
// We don't silently want to constrain hidden types here, so we assert that either one side is
961-
// an infer var, so it'll get constrained to whatever the other side is, or there are no opaque
962-
// types involved.
963-
// We don't expect this to actually get hit, but if it does, we now at least know how to write
964-
// a test for it.
965-
(_, ty::Infer(ty::TyVar(_))) => {}
966-
(ty::Infer(ty::TyVar(_)), _) => {}
967-
_ if r_a != r_b && (r_a, r_b).has_opaque_types() => {
968-
span_bug!(
969-
cause.span(),
970-
"opaque types got hidden types registered from within subtype predicate: {r_a:?} vs {r_b:?}"
971-
)
972-
}
973960
_ => {}
974961
}
975962

976963
self.enter_forall(predicate, |ty::SubtypePredicate { a_is_expected, a, b }| {
977964
if a_is_expected {
978-
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
965+
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::No, a, b))
979966
} else {
980-
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
967+
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::No, b, a))
981968
}
982969
})
983970
}

compiler/rustc_lint/src/for_loops_over_fallibles.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
6262
};
6363

6464
let (article, ty, var) = match adt.did() {
65-
did if cx.tcx.is_diagnostic_item(sym::Option, did) && ref_mutability.is_some() => ("a", "Option", "Some"),
65+
did if cx.tcx.is_diagnostic_item(sym::Option, did) && ref_mutability.is_some() => {
66+
("a", "Option", "Some")
67+
}
6668
did if cx.tcx.is_diagnostic_item(sym::Option, did) => ("an", "Option", "Some"),
6769
did if cx.tcx.is_diagnostic_item(sym::Result, did) => ("a", "Result", "Ok"),
6870
_ => return,

library/core/src/cmp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
898898
/// assert_eq!(2.clamp(-2, 1), 1);
899899
/// ```
900900
#[must_use]
901+
#[inline]
901902
#[stable(feature = "clamp", since = "1.50.0")]
902903
fn clamp(self, min: Self, max: Self) -> Self
903904
where

library/test/src/bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn fmt_thousands_sep(mut n: f64, sep: char) -> String {
9898
(0, true) => write!(output, "{:06.2}", n / base as f64).unwrap(),
9999
(0, false) => write!(output, "{:.2}", n / base as f64).unwrap(),
100100
(_, true) => write!(output, "{:03}", n as usize / base).unwrap(),
101-
_ => write!(output, "{}", n as usize / base).unwrap()
101+
_ => write!(output, "{}", n as usize / base).unwrap(),
102102
}
103103
if pow != 0 {
104104
output.push(sep);

src/bootstrap/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and some of the technical details of the build system.
66
Note that this README only covers internal information, not how to use the tool.
77
Please check [bootstrapping dev guide][bootstrapping-dev-guide] for further information.
88

9-
[bootstrapping-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html
9+
[bootstrapping-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/bootstrapping/intro.html
1010

1111
## Introduction
1212

src/bootstrap/src/core/builder/tests.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ fn check_cli<const N: usize>(paths: [&str; N]) {
6060
macro_rules! std {
6161
($host:ident => $target:ident, stage = $stage:literal) => {
6262
compile::Std::new(
63-
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
63+
Compiler {
64+
host: TargetSelection::from_user(concat!(
65+
stringify!($host),
66+
"-",
67+
stringify!($host)
68+
)),
69+
stage: $stage,
70+
},
6471
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
6572
)
6673
};
@@ -83,7 +90,14 @@ macro_rules! doc_std {
8390
macro_rules! rustc {
8491
($host:ident => $target:ident, stage = $stage:literal) => {
8592
compile::Rustc::new(
86-
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
93+
Compiler {
94+
host: TargetSelection::from_user(concat!(
95+
stringify!($host),
96+
"-",
97+
stringify!($host)
98+
)),
99+
stage: $stage,
100+
},
87101
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
88102
)
89103
};
@@ -141,10 +155,14 @@ fn check_missing_paths_for_x_test_tests() {
141155

142156
// Skip if not a test directory.
143157
if path.ends_with("tests/auxiliary") || !path.is_dir() {
144-
continue
158+
continue;
145159
}
146160

147-
assert!(tests_remap_paths.iter().any(|item| path.ends_with(*item)), "{} is missing in PATH_REMAP tests list.", path.display());
161+
assert!(
162+
tests_remap_paths.iter().any(|item| path.ends_with(*item)),
163+
"{} is missing in PATH_REMAP tests list.",
164+
path.display()
165+
);
148166
}
149167
}
150168

@@ -185,7 +203,8 @@ fn alias_and_path_for_library() {
185203
&[std!(A => A, stage = 0), std!(A => A, stage = 1)]
186204
);
187205

188-
let mut cache = run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
206+
let mut cache =
207+
run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
189208
assert_eq!(first(cache.all::<doc::Std>()), &[doc_std!(A => A, stage = 0)]);
190209
}
191210

src/bootstrap/src/core/sanity.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,15 @@ than building it.
199199
if !["A-A", "B-B", "C-C"].contains(&target_str.as_str()) {
200200
let mut has_target = false;
201201

202-
let missing_targets_hashset: HashSet<_> = STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
203-
let duplicated_targets: Vec<_> = stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
202+
let missing_targets_hashset: HashSet<_> =
203+
STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
204+
let duplicated_targets: Vec<_> =
205+
stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
204206

205207
if !duplicated_targets.is_empty() {
206-
println!("Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list.");
208+
println!(
209+
"Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list."
210+
);
207211
for duplicated_target in duplicated_targets {
208212
println!(" {duplicated_target}");
209213
}

src/tools/build_helper/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod ci;
22
pub mod git;
33
pub mod metrics;
4-
pub mod util;
54
pub mod stage0_parser;
5+
pub mod util;

tests/crashes/124891.rs

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//! This test checks that we allow subtyping predicates that contain opaque types.
2+
//! No hidden types are being constrained in the subtyping predicate, but type and
3+
//! lifetime variables get subtyped in the generic parameter list of the opaque.
4+
5+
use std::iter;
6+
7+
mod either {
8+
pub enum Either<L, R> {
9+
Left(L),
10+
Right(R),
11+
}
12+
13+
impl<L: Iterator, R: Iterator<Item = L::Item>> Iterator for Either<L, R> {
14+
type Item = L::Item;
15+
fn next(&mut self) -> Option<Self::Item> {
16+
todo!()
17+
}
18+
}
19+
pub use self::Either::{Left, Right};
20+
}
21+
22+
pub enum BabeConsensusLogRef<'a> {
23+
NextEpochData(BabeNextEpochRef<'a>),
24+
NextConfigData,
25+
}
26+
27+
impl<'a> BabeConsensusLogRef<'a> {
28+
pub fn scale_encoding(
29+
&self,
30+
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
31+
//~^ ERROR is not satisfied
32+
//~| ERROR is not satisfied
33+
//~| ERROR is not satisfied
34+
match self {
35+
BabeConsensusLogRef::NextEpochData(digest) => either::Left(either::Left(
36+
digest.scale_encoding().map(either::Left).map(either::Left),
37+
)),
38+
BabeConsensusLogRef::NextConfigData => either::Right(
39+
// The Opaque type from ``scale_encoding` gets used opaquely here, while the `R`
40+
// generic parameter of `Either` contains type variables that get subtyped and the
41+
// opaque type contains lifetime variables that get subtyped.
42+
iter::once(either::Right(either::Left([1])))
43+
.chain(std::iter::once([1]).map(either::Right).map(either::Right)),
44+
),
45+
}
46+
}
47+
}
48+
49+
pub struct BabeNextEpochRef<'a>(&'a ());
50+
51+
impl<'a> BabeNextEpochRef<'a> {
52+
pub fn scale_encoding(
53+
&self,
54+
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
55+
std::iter::once([1])
56+
}
57+
}
58+
59+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: the trait bound `Either<Either<Map<Map<impl Iterator<Item = impl AsRef<[u8]> + Clone + '_> + Clone + '_, fn(impl AsRef<[u8]> + Clone + '_) -> Either<impl AsRef<[u8]> + Clone + '_, _> {Either::<impl AsRef<[u8]> + Clone + '_, _>::Left}>, fn(Either<impl AsRef<[u8]> + Clone + '_, _>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Left}>, _>, std::iter::Chain<std::iter::Once<Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>>, Map<Map<std::iter::Once<[{integer}; 1]>, fn([{integer}; 1]) -> Either<[{integer}; 1], [{integer}; 1]> {Either::<[{integer}; 1], [{integer}; 1]>::Right}>, fn(Either<[{integer}; 1], [{integer}; 1]>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Right}>>>: Clone` is not satisfied
2+
--> $DIR/lazy_subtyping_of_opaques.rs:30:10
3+
|
4+
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Either<Either<Map<Map<impl Iterator<Item = impl AsRef<[u8]> + Clone + '_> + Clone + '_, fn(impl AsRef<[u8]> + Clone + '_) -> Either<impl AsRef<[u8]> + Clone + '_, _> {Either::<impl AsRef<[u8]> + Clone + '_, _>::Left}>, fn(Either<impl AsRef<[u8]> + Clone + '_, _>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Left}>, _>, std::iter::Chain<std::iter::Once<Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>>, Map<Map<std::iter::Once<[{integer}; 1]>, fn([{integer}; 1]) -> Either<[{integer}; 1], [{integer}; 1]> {Either::<[{integer}; 1], [{integer}; 1]>::Right}>, fn(Either<[{integer}; 1], [{integer}; 1]>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Right}>>>`
6+
7+
error[E0277]: the trait bound `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>: AsRef<[u8]>` is not satisfied
8+
--> $DIR/lazy_subtyping_of_opaques.rs:30:31
9+
|
10+
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsRef<[u8]>` is not implemented for `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>`
12+
13+
error[E0277]: the trait bound `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>: Clone` is not satisfied
14+
--> $DIR/lazy_subtyping_of_opaques.rs:30:31
15+
|
16+
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>`
18+
19+
error: aborting due to 3 previous errors
20+
21+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![feature(type_alias_impl_trait)]
2+
3+
//! This test used to ICE rust-lang/rust#124891
4+
//! because we added an assertion for catching cases where opaque types get
5+
//! registered during the processing of subtyping predicates.
6+
7+
type Tait = impl FnOnce() -> ();
8+
9+
fn reify_as_tait() -> Thunk<Tait> {
10+
Thunk::new(|cont| cont)
11+
//~^ ERROR: mismatched types
12+
//~| ERROR: mismatched types
13+
}
14+
15+
struct Thunk<F>(F);
16+
17+
impl<F> Thunk<F> {
18+
fn new(f: F)
19+
where
20+
F: ContFn,
21+
{
22+
todo!();
23+
}
24+
}
25+
26+
trait ContFn {}
27+
28+
impl<F: FnOnce(Tait) -> ()> ContFn for F {}
29+
30+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/lazy_subtyping_of_opaques.rs:10:23
3+
|
4+
LL | type Tait = impl FnOnce() -> ();
5+
| ------------------- the found opaque type
6+
...
7+
LL | Thunk::new(|cont| cont)
8+
| ^^^^ expected `()`, found opaque type
9+
|
10+
= note: expected unit type `()`
11+
found opaque type `Tait`
12+
13+
error[E0308]: mismatched types
14+
--> $DIR/lazy_subtyping_of_opaques.rs:10:5
15+
|
16+
LL | fn reify_as_tait() -> Thunk<Tait> {
17+
| ----------- expected `Thunk<_>` because of return type
18+
LL | Thunk::new(|cont| cont)
19+
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `Thunk<_>`, found `()`
20+
|
21+
= note: expected struct `Thunk<_>`
22+
found unit type `()`
23+
24+
error: aborting due to 2 previous errors
25+
26+
For more information about this error, try `rustc --explain E0308`.

triagebot.toml

+4
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ cc = ["@Zalathar"]
842842
message = "Some changes occurred in coverage tests."
843843
cc = ["@Zalathar"]
844844

845+
[mentions."src/tools/opt-dist"]
846+
cc = ["@kobzol"]
847+
845848
[assign]
846849
warn_non_default_branch = true
847850
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
@@ -1059,6 +1062,7 @@ project-exploit-mitigations = [
10591062
"/src/tools/cargo" = ["@ehuss"]
10601063
"/src/tools/compiletest" = ["bootstrap", "@wesleywiser", "@oli-obk", "@compiler-errors", "@jieyouxu"]
10611064
"/src/tools/linkchecker" = ["@ehuss"]
1065+
"/src/tools/opt-dist" = ["@kobzol"]
10621066
"/src/tools/run-make-support" = ["@jieyouxu"]
10631067
"/src/tools/rust-installer" = ["bootstrap"]
10641068
"/src/tools/rustbook" = ["@ehuss"]

0 commit comments

Comments
 (0)