Skip to content

Commit af3e06f

Browse files
committed
Auto merge of rust-lang#106087 - Nilstrieb:rollup-2m3nies, r=Nilstrieb
Rollup of 6 pull requests Successful merges: - rust-lang#105661 (implement the skeleton of the updated trait solver) - rust-lang#105853 (Make the pre-push script work on directories with spaces) - rust-lang#106043 (Move tests) - rust-lang#106048 (Run `tidy` in its own job in PR CI) - rust-lang#106055 (Check arg expressions properly on error in `confirm_builtin_call`) - rust-lang#106067 (A few metadata nits) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c2ff8ad + 659c218 commit af3e06f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1706
-144
lines changed

.github/workflows/ci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,24 @@ jobs:
4141
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
4242
CACHE_DOMAIN: ci-caches.rust-lang.org
4343
if: "github.event_name == 'pull_request'"
44+
continue-on-error: "${{ matrix.tidy }}"
4445
strategy:
4546
matrix:
4647
include:
4748
- name: mingw-check
49+
tidy: false
50+
os: ubuntu-20.04-xl
51+
env: {}
52+
- name: mingw-check-tidy
53+
tidy: true
4854
os: ubuntu-20.04-xl
4955
env: {}
5056
- name: x86_64-gnu-llvm-13
57+
tidy: false
5158
os: ubuntu-20.04-xl
5259
env: {}
5360
- name: x86_64-gnu-tools
61+
tidy: false
5462
env:
5563
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
5664
os: ubuntu-20.04-xl

compiler/rustc_hir_typeck/src/callee.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
399399
}
400400
ty::FnPtr(sig) => (sig, None),
401401
_ => {
402+
for arg in arg_exprs {
403+
self.check_expr(arg);
404+
}
405+
402406
if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &callee_expr.kind
403407
&& let [segment] = path.segments
404408
&& let Some(mut diag) = self
@@ -486,7 +490,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
486490
expected: Expectation<'tcx>,
487491
) -> Option<Ty<'tcx>> {
488492
if let [callee_expr, rest @ ..] = arg_exprs {
489-
let callee_ty = self.check_expr(callee_expr);
493+
let callee_ty = self.typeck_results.borrow().expr_ty_adjusted_opt(callee_expr)?;
494+
490495
// First, do a probe with `IsSuggestion(true)` to avoid emitting
491496
// any strange errors. If it's successful, then we'll do a true
492497
// method lookup.

compiler/rustc_infer/src/infer/canonical/query_response.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ impl<'tcx> InferCtxt<'tcx> {
151151
})
152152
}
153153

154-
fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
154+
/// FIXME: This method should only be used for canonical queries and therefore be private.
155+
///
156+
/// As the new solver does canonicalization slightly differently, this is also used there
157+
/// for now. This should hopefully change fairly soon.
158+
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
155159
self.inner
156160
.borrow_mut()
157161
.opaque_type_storage

compiler/rustc_metadata/src/locator.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,7 @@ impl CrateError {
10111011
sess.emit_err(SymbolConflictsOthers { span, crate_name: root_name });
10121012
}
10131013
CrateError::StableCrateIdCollision(crate_name0, crate_name1) => {
1014-
sess.emit_err(StableCrateIdCollision {
1015-
span,
1016-
crate_name0: crate_name0,
1017-
crate_name1: crate_name1,
1018-
});
1014+
sess.emit_err(StableCrateIdCollision { span, crate_name0, crate_name1 });
10191015
}
10201016
CrateError::DlOpen(s) | CrateError::DlSym(s) => {
10211017
sess.emit_err(DlError { span, err: s });
@@ -1074,7 +1070,7 @@ impl CrateError {
10741070
}
10751071
sess.emit_err(NoCrateWithTriple {
10761072
span,
1077-
crate_name: crate_name,
1073+
crate_name,
10781074
locator_triple: locator.triple.triple(),
10791075
add_info,
10801076
found_crates,

compiler/rustc_metadata/src/rmeta/decoder.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ pub(crate) struct CrateMetadata {
7878
blob: MetadataBlob,
7979

8080
// --- Some data pre-decoded from the metadata blob, usually for performance ---
81-
/// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
82-
/// lifetime is only used behind `LazyValue`, `LazyArray`, or `LazyTable`, and therefore acts like a
83-
/// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
84-
/// is being used to decode those values.
8581
root: CrateRoot,
8682
/// Trait impl data.
8783
/// FIXME: Used only from queries and can use query cache,
@@ -688,10 +684,10 @@ impl MetadataBlob {
688684
pub(crate) fn get_root(&self) -> CrateRoot {
689685
let slice = &self.blob()[..];
690686
let offset = METADATA_HEADER.len();
691-
let pos = (((slice[offset + 0] as u32) << 24)
692-
| ((slice[offset + 1] as u32) << 16)
693-
| ((slice[offset + 2] as u32) << 8)
694-
| ((slice[offset + 3] as u32) << 0)) as usize;
687+
688+
let pos_bytes = slice[offset..][..4].try_into().unwrap();
689+
let pos = u32::from_be_bytes(pos_bytes) as usize;
690+
695691
LazyValue::<CrateRoot>::from_position(NonZeroUsize::new(pos).unwrap()).decode(self)
696692
}
697693

@@ -702,16 +698,14 @@ impl MetadataBlob {
702698
writeln!(out, "hash {} stable_crate_id {:?}", root.hash, root.stable_crate_id)?;
703699
writeln!(out, "proc_macro {:?}", root.proc_macro_data.is_some())?;
704700
writeln!(out, "=External Dependencies=")?;
701+
705702
for (i, dep) in root.crate_deps.decode(self).enumerate() {
703+
let CrateDep { name, extra_filename, hash, host_hash, kind } = dep;
704+
let number = i + 1;
705+
706706
writeln!(
707707
out,
708-
"{} {}{} hash {} host_hash {:?} kind {:?}",
709-
i + 1,
710-
dep.name,
711-
dep.extra_filename,
712-
dep.hash,
713-
dep.host_hash,
714-
dep.kind
708+
"{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?}"
715709
)?;
716710
}
717711
write!(out, "\n")?;

compiler/rustc_metadata/src/rmeta/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ struct VariantData {
416416
is_non_exhaustive: bool,
417417
}
418418

419-
#[derive(TyEncodable, TyDecodable)]
420-
struct GeneratorData<'tcx> {
421-
layout: mir::GeneratorLayout<'tcx>,
422-
}
423-
424419
// Tags used for encoding Spans:
425420
const TAG_VALID_SPAN_LOCAL: u8 = 0;
426421
const TAG_VALID_SPAN_FOREIGN: u8 = 1;

compiler/rustc_middle/src/infer/canonical.rs

+10
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,16 @@ impl<'tcx, V> Canonical<'tcx, V> {
300300
let Canonical { max_universe, variables, value } = self;
301301
Canonical { max_universe, variables, value: map_op(value) }
302302
}
303+
304+
/// Allows you to map the `value` of a canonical while keeping the same set of
305+
/// bound variables.
306+
///
307+
/// **WARNING:** This function is very easy to mis-use, hence the name! See
308+
/// the comment of [Canonical::unchecked_map] for more details.
309+
pub fn unchecked_rebind<W>(self, value: W) -> Canonical<'tcx, W> {
310+
let Canonical { max_universe, variables, value: _ } = self;
311+
Canonical { max_universe, variables, value }
312+
}
303313
}
304314

305315
pub type QueryOutlivesConstraint<'tcx> = (

compiler/rustc_middle/src/traits/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub type CanonicalTypeOpProvePredicateGoal<'tcx> =
9696
pub type CanonicalTypeOpNormalizeGoal<'tcx, T> =
9797
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>;
9898

99-
#[derive(Copy, Clone, Debug, HashStable)]
99+
#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)]
100100
pub struct NoSolution;
101101

102102
pub type Fallible<T> = Result<T, NoSolution>;

compiler/rustc_middle/src/traits/specialization_graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ impl Iterator for Ancestors<'_> {
180180
}
181181

182182
/// Information about the most specialized definition of an associated item.
183+
#[derive(Debug)]
183184
pub struct LeafDef {
184185
/// The associated item described by this `LeafDef`.
185186
pub item: ty::AssocItem,

compiler/rustc_middle/src/ty/mod.rs

+29-12
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,17 @@ impl<'tcx> Predicate<'tcx> {
535535
self
536536
}
537537

538+
#[instrument(level = "debug", skip(tcx), ret)]
539+
pub fn is_coinductive(self, tcx: TyCtxt<'tcx>) -> bool {
540+
match self.kind().skip_binder() {
541+
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
542+
tcx.trait_is_coinductive(data.def_id())
543+
}
544+
ty::PredicateKind::WellFormed(_) => true,
545+
_ => false,
546+
}
547+
}
548+
538549
/// Whether this projection can be soundly normalized.
539550
///
540551
/// Wf predicates must not be normalized, as normalization
@@ -1018,6 +1029,24 @@ pub struct ProjectionPredicate<'tcx> {
10181029
pub term: Term<'tcx>,
10191030
}
10201031

1032+
impl<'tcx> ProjectionPredicate<'tcx> {
1033+
pub fn self_ty(self) -> Ty<'tcx> {
1034+
self.projection_ty.self_ty()
1035+
}
1036+
1037+
pub fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ProjectionPredicate<'tcx> {
1038+
Self { projection_ty: self.projection_ty.with_self_ty(tcx, self_ty), ..self }
1039+
}
1040+
1041+
pub fn trait_def_id(self, tcx: TyCtxt<'tcx>) -> DefId {
1042+
self.projection_ty.trait_def_id(tcx)
1043+
}
1044+
1045+
pub fn def_id(self) -> DefId {
1046+
self.projection_ty.def_id
1047+
}
1048+
}
1049+
10211050
pub type PolyProjectionPredicate<'tcx> = Binder<'tcx, ProjectionPredicate<'tcx>>;
10221051

10231052
impl<'tcx> PolyProjectionPredicate<'tcx> {
@@ -1054,18 +1083,6 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
10541083
}
10551084
}
10561085

1057-
impl<'tcx> ProjectionPredicate<'tcx> {
1058-
pub fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
1059-
Self {
1060-
projection_ty: tcx.mk_alias_ty(
1061-
self.projection_ty.def_id,
1062-
[self_ty.into()].into_iter().chain(self.projection_ty.substs.iter().skip(1)),
1063-
),
1064-
..self
1065-
}
1066-
}
1067-
}
1068-
10691086
pub trait ToPolyTraitRef<'tcx> {
10701087
fn to_poly_trait_ref(&self) -> PolyTraitRef<'tcx>;
10711088
}

compiler/rustc_middle/src/ty/sty.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ pub struct AliasTy<'tcx> {
11691169
}
11701170

11711171
impl<'tcx> AliasTy<'tcx> {
1172-
pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId {
1172+
pub fn trait_def_id(self, tcx: TyCtxt<'tcx>) -> DefId {
11731173
match tcx.def_kind(self.def_id) {
11741174
DefKind::AssocTy | DefKind::AssocConst => tcx.parent(self.def_id),
11751175
DefKind::ImplTraitPlaceholder => {
@@ -1183,7 +1183,7 @@ impl<'tcx> AliasTy<'tcx> {
11831183
/// For example, if this is a projection of `<T as StreamingIterator>::Item<'a>`,
11841184
/// then this function would return a `T: Iterator` trait reference and `['a]` as the own substs
11851185
pub fn trait_ref_and_own_substs(
1186-
&self,
1186+
self,
11871187
tcx: TyCtxt<'tcx>,
11881188
) -> (ty::TraitRef<'tcx>, &'tcx [ty::GenericArg<'tcx>]) {
11891189
debug_assert!(matches!(tcx.def_kind(self.def_id), DefKind::AssocTy | DefKind::AssocConst));
@@ -1202,14 +1202,18 @@ impl<'tcx> AliasTy<'tcx> {
12021202
/// WARNING: This will drop the substs for generic associated types
12031203
/// consider calling [Self::trait_ref_and_own_substs] to get those
12041204
/// as well.
1205-
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
1205+
pub fn trait_ref(self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
12061206
let def_id = self.trait_def_id(tcx);
12071207
tcx.mk_trait_ref(def_id, self.substs.truncate_to(tcx, tcx.generics_of(def_id)))
12081208
}
12091209

1210-
pub fn self_ty(&self) -> Ty<'tcx> {
1210+
pub fn self_ty(self) -> Ty<'tcx> {
12111211
self.substs.type_at(0)
12121212
}
1213+
1214+
pub fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
1215+
tcx.mk_alias_ty(self.def_id, [self_ty.into()].into_iter().chain(self.substs.iter().skip(1)))
1216+
}
12131217
}
12141218

12151219
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift)]

compiler/rustc_middle/src/ty/subst.rs

+4
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ impl<T> EarlyBinder<T> {
577577
pub fn rebind<U>(&self, value: U) -> EarlyBinder<U> {
578578
EarlyBinder(value)
579579
}
580+
581+
pub fn skip_binder(self) -> T {
582+
self.0
583+
}
580584
}
581585

582586
impl<T> EarlyBinder<Option<T>> {

compiler/rustc_trait_selection/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#![feature(let_chains)]
2020
#![feature(if_let_guard)]
2121
#![feature(never_type)]
22+
#![feature(result_option_inspect)]
2223
#![feature(type_alias_impl_trait)]
2324
#![recursion_limit = "512"] // For rustdoc
2425

@@ -37,4 +38,5 @@ extern crate smallvec;
3738
pub mod autoderef;
3839
pub mod errors;
3940
pub mod infer;
41+
pub mod solve;
4042
pub mod traits;

0 commit comments

Comments
 (0)