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
This commit is contained in:
commit
697ac29a80
17 changed files with 185 additions and 56 deletions
|
@ -29,8 +29,8 @@ use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, Debugger
|
|||
use rustc_middle::middle::exported_symbols;
|
||||
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir::BinOp;
|
||||
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
|
||||
use rustc_middle::mir::BinOp;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
|
|
|
@ -139,10 +139,9 @@ where
|
|||
ErrorHandled::TooGeneric(span)
|
||||
}
|
||||
err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar, span),
|
||||
err_inval!(Layout(LayoutError::ReferencesError(guar))) => ErrorHandled::Reported(
|
||||
ReportedErrorInfo::tainted_by_errors(guar),
|
||||
span,
|
||||
),
|
||||
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
|
||||
ErrorHandled::Reported(ReportedErrorInfo::tainted_by_errors(guar), span)
|
||||
}
|
||||
// Report remaining errors.
|
||||
_ => {
|
||||
let (our_span, frames) = get_span_and_frames();
|
||||
|
|
|
@ -116,8 +116,7 @@ fn load_dep_graph(sess: &Session) -> LoadResult<(Arc<SerializedDepGraph>, WorkPr
|
|||
|
||||
if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
|
||||
// Decode the list of work_products
|
||||
let Ok(mut work_product_decoder) =
|
||||
MemDecoder::new(&work_products_data[..], start_pos)
|
||||
let Ok(mut work_product_decoder) = MemDecoder::new(&work_products_data[..], start_pos)
|
||||
else {
|
||||
sess.dcx().emit_warn(errors::CorruptFile { path: &work_products_path });
|
||||
return LoadResult::DataOutOfDate;
|
||||
|
|
|
@ -957,27 +957,14 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
(&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => {
|
||||
return Err((a_vid, b_vid));
|
||||
}
|
||||
// We don't silently want to constrain hidden types here, so we assert that either one side is
|
||||
// an infer var, so it'll get constrained to whatever the other side is, or there are no opaque
|
||||
// types involved.
|
||||
// We don't expect this to actually get hit, but if it does, we now at least know how to write
|
||||
// a test for it.
|
||||
(_, ty::Infer(ty::TyVar(_))) => {}
|
||||
(ty::Infer(ty::TyVar(_)), _) => {}
|
||||
_ if r_a != r_b && (r_a, r_b).has_opaque_types() => {
|
||||
span_bug!(
|
||||
cause.span(),
|
||||
"opaque types got hidden types registered from within subtype predicate: {r_a:?} vs {r_b:?}"
|
||||
)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.enter_forall(predicate, |ty::SubtypePredicate { a_is_expected, a, b }| {
|
||||
if a_is_expected {
|
||||
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
|
||||
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::No, a, b))
|
||||
} else {
|
||||
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
|
||||
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::No, b, a))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -62,7 +62,9 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
|
|||
};
|
||||
|
||||
let (article, ty, var) = match adt.did() {
|
||||
did if cx.tcx.is_diagnostic_item(sym::Option, did) && ref_mutability.is_some() => ("a", "Option", "Some"),
|
||||
did if cx.tcx.is_diagnostic_item(sym::Option, did) && ref_mutability.is_some() => {
|
||||
("a", "Option", "Some")
|
||||
}
|
||||
did if cx.tcx.is_diagnostic_item(sym::Option, did) => ("an", "Option", "Some"),
|
||||
did if cx.tcx.is_diagnostic_item(sym::Result, did) => ("a", "Result", "Ok"),
|
||||
_ => return,
|
||||
|
|
|
@ -898,6 +898,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
|
|||
/// assert_eq!(2.clamp(-2, 1), 1);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[stable(feature = "clamp", since = "1.50.0")]
|
||||
fn clamp(self, min: Self, max: Self) -> Self
|
||||
where
|
||||
|
|
|
@ -98,7 +98,7 @@ fn fmt_thousands_sep(mut n: f64, sep: char) -> String {
|
|||
(0, true) => write!(output, "{:06.2}", n / base as f64).unwrap(),
|
||||
(0, false) => write!(output, "{:.2}", n / base as f64).unwrap(),
|
||||
(_, true) => write!(output, "{:03}", n as usize / base).unwrap(),
|
||||
_ => write!(output, "{}", n as usize / base).unwrap()
|
||||
_ => write!(output, "{}", n as usize / base).unwrap(),
|
||||
}
|
||||
if pow != 0 {
|
||||
output.push(sep);
|
||||
|
|
|
@ -6,7 +6,7 @@ and some of the technical details of the build system.
|
|||
Note that this README only covers internal information, not how to use the tool.
|
||||
Please check [bootstrapping dev guide][bootstrapping-dev-guide] for further information.
|
||||
|
||||
[bootstrapping-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html
|
||||
[bootstrapping-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/bootstrapping/intro.html
|
||||
|
||||
## Introduction
|
||||
|
||||
|
|
|
@ -60,7 +60,14 @@ fn check_cli<const N: usize>(paths: [&str; N]) {
|
|||
macro_rules! std {
|
||||
($host:ident => $target:ident, stage = $stage:literal) => {
|
||||
compile::Std::new(
|
||||
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
|
||||
Compiler {
|
||||
host: TargetSelection::from_user(concat!(
|
||||
stringify!($host),
|
||||
"-",
|
||||
stringify!($host)
|
||||
)),
|
||||
stage: $stage,
|
||||
},
|
||||
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
|
||||
)
|
||||
};
|
||||
|
@ -83,7 +90,14 @@ macro_rules! doc_std {
|
|||
macro_rules! rustc {
|
||||
($host:ident => $target:ident, stage = $stage:literal) => {
|
||||
compile::Rustc::new(
|
||||
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
|
||||
Compiler {
|
||||
host: TargetSelection::from_user(concat!(
|
||||
stringify!($host),
|
||||
"-",
|
||||
stringify!($host)
|
||||
)),
|
||||
stage: $stage,
|
||||
},
|
||||
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
|
||||
)
|
||||
};
|
||||
|
@ -141,10 +155,14 @@ fn check_missing_paths_for_x_test_tests() {
|
|||
|
||||
// Skip if not a test directory.
|
||||
if path.ends_with("tests/auxiliary") || !path.is_dir() {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
assert!(tests_remap_paths.iter().any(|item| path.ends_with(*item)), "{} is missing in PATH_REMAP tests list.", path.display());
|
||||
assert!(
|
||||
tests_remap_paths.iter().any(|item| path.ends_with(*item)),
|
||||
"{} is missing in PATH_REMAP tests list.",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,7 +203,8 @@ fn alias_and_path_for_library() {
|
|||
&[std!(A => A, stage = 0), std!(A => A, stage = 1)]
|
||||
);
|
||||
|
||||
let mut cache = run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
|
||||
let mut cache =
|
||||
run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
|
||||
assert_eq!(first(cache.all::<doc::Std>()), &[doc_std!(A => A, stage = 0)]);
|
||||
}
|
||||
|
||||
|
|
|
@ -199,11 +199,15 @@ than building it.
|
|||
if !["A-A", "B-B", "C-C"].contains(&target_str.as_str()) {
|
||||
let mut has_target = false;
|
||||
|
||||
let missing_targets_hashset: HashSet<_> = STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
|
||||
let duplicated_targets: Vec<_> = stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
|
||||
let missing_targets_hashset: HashSet<_> =
|
||||
STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
|
||||
let duplicated_targets: Vec<_> =
|
||||
stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
|
||||
|
||||
if !duplicated_targets.is_empty() {
|
||||
println!("Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list.");
|
||||
println!(
|
||||
"Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list."
|
||||
);
|
||||
for duplicated_target in duplicated_targets {
|
||||
println!(" {duplicated_target}");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pub mod ci;
|
||||
pub mod git;
|
||||
pub mod metrics;
|
||||
pub mod util;
|
||||
pub mod stage0_parser;
|
||||
pub mod util;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
//@ known-bug: rust-lang/rust#124891
|
||||
|
||||
type Tait = impl FnOnce() -> ();
|
||||
|
||||
fn reify_as_tait() -> Thunk<Tait> {
|
||||
Thunk::new(|cont| cont)
|
||||
}
|
||||
|
||||
struct Thunk<F>(F);
|
||||
|
||||
impl<F> Thunk<F> {
|
||||
fn new(f: F)
|
||||
where
|
||||
F: ContFn,
|
||||
{
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
trait ContFn {}
|
||||
|
||||
impl<F: FnOnce(Tait) -> ()> ContFn for F {}
|
59
tests/ui/impl-trait/lazy_subtyping_of_opaques.rs
Normal file
59
tests/ui/impl-trait/lazy_subtyping_of_opaques.rs
Normal file
|
@ -0,0 +1,59 @@
|
|||
//! This test checks that we allow subtyping predicates that contain opaque types.
|
||||
//! No hidden types are being constrained in the subtyping predicate, but type and
|
||||
//! lifetime variables get subtyped in the generic parameter list of the opaque.
|
||||
|
||||
use std::iter;
|
||||
|
||||
mod either {
|
||||
pub enum Either<L, R> {
|
||||
Left(L),
|
||||
Right(R),
|
||||
}
|
||||
|
||||
impl<L: Iterator, R: Iterator<Item = L::Item>> Iterator for Either<L, R> {
|
||||
type Item = L::Item;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
pub use self::Either::{Left, Right};
|
||||
}
|
||||
|
||||
pub enum BabeConsensusLogRef<'a> {
|
||||
NextEpochData(BabeNextEpochRef<'a>),
|
||||
NextConfigData,
|
||||
}
|
||||
|
||||
impl<'a> BabeConsensusLogRef<'a> {
|
||||
pub fn scale_encoding(
|
||||
&self,
|
||||
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
|
||||
//~^ ERROR is not satisfied
|
||||
//~| ERROR is not satisfied
|
||||
//~| ERROR is not satisfied
|
||||
match self {
|
||||
BabeConsensusLogRef::NextEpochData(digest) => either::Left(either::Left(
|
||||
digest.scale_encoding().map(either::Left).map(either::Left),
|
||||
)),
|
||||
BabeConsensusLogRef::NextConfigData => either::Right(
|
||||
// The Opaque type from ``scale_encoding` gets used opaquely here, while the `R`
|
||||
// generic parameter of `Either` contains type variables that get subtyped and the
|
||||
// opaque type contains lifetime variables that get subtyped.
|
||||
iter::once(either::Right(either::Left([1])))
|
||||
.chain(std::iter::once([1]).map(either::Right).map(either::Right)),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BabeNextEpochRef<'a>(&'a ());
|
||||
|
||||
impl<'a> BabeNextEpochRef<'a> {
|
||||
pub fn scale_encoding(
|
||||
&self,
|
||||
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
|
||||
std::iter::once([1])
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
21
tests/ui/impl-trait/lazy_subtyping_of_opaques.stderr
Normal file
21
tests/ui/impl-trait/lazy_subtyping_of_opaques.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
--> $DIR/lazy_subtyping_of_opaques.rs:30:10
|
||||
|
|
||||
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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}>>>`
|
||||
|
||||
error[E0277]: the trait bound `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>: AsRef<[u8]>` is not satisfied
|
||||
--> $DIR/lazy_subtyping_of_opaques.rs:30:31
|
||||
|
|
||||
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsRef<[u8]>` is not implemented for `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>`
|
||||
|
||||
error[E0277]: the trait bound `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>: Clone` is not satisfied
|
||||
--> $DIR/lazy_subtyping_of_opaques.rs:30:31
|
||||
|
|
||||
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
30
tests/ui/type-alias-impl-trait/lazy_subtyping_of_opaques.rs
Normal file
30
tests/ui/type-alias-impl-trait/lazy_subtyping_of_opaques.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
//! This test used to ICE rust-lang/rust#124891
|
||||
//! because we added an assertion for catching cases where opaque types get
|
||||
//! registered during the processing of subtyping predicates.
|
||||
|
||||
type Tait = impl FnOnce() -> ();
|
||||
|
||||
fn reify_as_tait() -> Thunk<Tait> {
|
||||
Thunk::new(|cont| cont)
|
||||
//~^ ERROR: mismatched types
|
||||
//~| ERROR: mismatched types
|
||||
}
|
||||
|
||||
struct Thunk<F>(F);
|
||||
|
||||
impl<F> Thunk<F> {
|
||||
fn new(f: F)
|
||||
where
|
||||
F: ContFn,
|
||||
{
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
trait ContFn {}
|
||||
|
||||
impl<F: FnOnce(Tait) -> ()> ContFn for F {}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,26 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/lazy_subtyping_of_opaques.rs:10:23
|
||||
|
|
||||
LL | type Tait = impl FnOnce() -> ();
|
||||
| ------------------- the found opaque type
|
||||
...
|
||||
LL | Thunk::new(|cont| cont)
|
||||
| ^^^^ expected `()`, found opaque type
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found opaque type `Tait`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/lazy_subtyping_of_opaques.rs:10:5
|
||||
|
|
||||
LL | fn reify_as_tait() -> Thunk<Tait> {
|
||||
| ----------- expected `Thunk<_>` because of return type
|
||||
LL | Thunk::new(|cont| cont)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `Thunk<_>`, found `()`
|
||||
|
|
||||
= note: expected struct `Thunk<_>`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
|
@ -842,6 +842,9 @@ cc = ["@Zalathar"]
|
|||
message = "Some changes occurred in coverage tests."
|
||||
cc = ["@Zalathar"]
|
||||
|
||||
[mentions."src/tools/opt-dist"]
|
||||
cc = ["@kobzol"]
|
||||
|
||||
[assign]
|
||||
warn_non_default_branch = true
|
||||
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
|
||||
|
@ -1059,6 +1062,7 @@ project-exploit-mitigations = [
|
|||
"/src/tools/cargo" = ["@ehuss"]
|
||||
"/src/tools/compiletest" = ["bootstrap", "@wesleywiser", "@oli-obk", "@compiler-errors", "@jieyouxu"]
|
||||
"/src/tools/linkchecker" = ["@ehuss"]
|
||||
"/src/tools/opt-dist" = ["@kobzol"]
|
||||
"/src/tools/run-make-support" = ["@jieyouxu"]
|
||||
"/src/tools/rust-installer" = ["bootstrap"]
|
||||
"/src/tools/rustbook" = ["@ehuss"]
|
||||
|
|
Loading…
Add table
Reference in a new issue