Skip to content

Commit 9142ac9

Browse files
committed
Auto merge of #55849 - pietroalbini:beta-rollup, r=pietroalbini
[beta] Rollup backports Merged and approved: * #55831: [beta]: Update Cargo's submodule * #55717: Bubble up an overflow error so that rustdoc can ignore it * #55637: Do not attempt to ascribe projections out of a ty var * #55378: rustbuild: use configured linker to build bootstrap r? @ghost
2 parents bee06e3 + a7f329f commit 9142ac9

File tree

9 files changed

+101
-25
lines changed

9 files changed

+101
-25
lines changed

src/Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ dependencies = [
209209
"crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
210210
"crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
211211
"curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)",
212+
"curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
212213
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
213214
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
214215
"filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",

src/bootstrap/bootstrap.py

+3
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,9 @@ def build_bootstrap(self):
632632
target_features += ["-crt-static"]
633633
if target_features:
634634
env["RUSTFLAGS"] += "-C target-feature=" + (",".join(target_features)) + " "
635+
target_linker = self.get_toml("linker", build_section)
636+
if target_linker is not None:
637+
env["RUSTFLAGS"] += "-C linker=" + target_linker + " "
635638

636639
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
637640
os.pathsep + env["PATH"]

src/librustc/mir/tcx.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,21 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
8080
elem: &PlaceElem<'tcx>)
8181
-> PlaceTy<'tcx>
8282
{
83-
self.projection_ty_core(tcx, elem, |_, _, ty| ty)
83+
self.projection_ty_core(tcx, elem, |_, _, ty| -> Result<Ty<'tcx>, ()> { Ok(ty) })
84+
.unwrap()
8485
}
8586

8687
/// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
8788
/// projects `place_ty` onto `elem`, returning the appropriate
8889
/// `Ty` or downcast variant corresponding to that projection.
8990
/// The `handle_field` callback must map a `Field` to its `Ty`,
9091
/// (which should be trivial when `T` = `Ty`).
91-
pub fn projection_ty_core<V, T>(self,
92-
tcx: TyCtxt<'a, 'gcx, 'tcx>,
93-
elem: &ProjectionElem<'tcx, V, T>,
94-
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>)
95-
-> PlaceTy<'tcx>
92+
pub fn projection_ty_core<V, T, E>(
93+
self,
94+
tcx: TyCtxt<'a, 'gcx, 'tcx>,
95+
elem: &ProjectionElem<'tcx, V, T>,
96+
mut handle_field: impl FnMut(&Self, &Field, &T) -> Result<Ty<'tcx>, E>)
97+
-> Result<PlaceTy<'tcx>, E>
9698
where
9799
V: ::std::fmt::Debug, T: ::std::fmt::Debug
98100
{
@@ -142,10 +144,11 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
142144
bug!("cannot downcast non-ADT type: `{:?}`", self)
143145
}
144146
},
145-
ProjectionElem::Field(ref f, ref fty) => PlaceTy::Ty { ty: handle_field(&self, f, fty) }
147+
ProjectionElem::Field(ref f, ref fty) =>
148+
PlaceTy::Ty { ty: handle_field(&self, f, fty)? },
146149
};
147150
debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer);
148-
answer
151+
Ok(answer)
149152
}
150153
}
151154

src/librustc/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ fn project_type<'cx, 'gcx, 'tcx>(
888888
let recursion_limit = *selcx.tcx().sess.recursion_limit.get();
889889
if obligation.recursion_depth >= recursion_limit {
890890
debug!("project: overflow!");
891-
selcx.infcx().report_overflow_error(&obligation, true);
891+
return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
892892
}
893893

894894
let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx());

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -991,20 +991,39 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
991991
let v1 = ty::Contravariant.xform(v);
992992

993993
let tcx = self.infcx.tcx;
994-
let mut projected_ty = PlaceTy::from_ty(ty);
994+
let ty = self.normalize(ty, locations);
995+
996+
// We need to follow any provided projetions into the type.
997+
//
998+
// if we hit a ty var as we descend, then just skip the
999+
// attempt to relate the mir local with any type.
1000+
#[derive(Debug)] struct HitTyVar;
1001+
let mut curr_projected_ty: Result<PlaceTy, HitTyVar>;
1002+
1003+
curr_projected_ty = Ok(PlaceTy::from_ty(ty));
9951004
for proj in &user_ty.projs {
996-
projected_ty = projected_ty.projection_ty_core(
1005+
let projected_ty = if let Ok(projected_ty) = curr_projected_ty {
1006+
projected_ty
1007+
} else {
1008+
break;
1009+
};
1010+
curr_projected_ty = projected_ty.projection_ty_core(
9971011
tcx, proj, |this, field, &()| {
998-
let ty = this.field_ty(tcx, field);
999-
self.normalize(ty, locations)
1012+
if this.to_ty(tcx).is_ty_var() {
1013+
Err(HitTyVar)
1014+
} else {
1015+
let ty = this.field_ty(tcx, field);
1016+
Ok(self.normalize(ty, locations))
1017+
}
10001018
});
10011019
}
10021020
debug!("user_ty base: {:?} freshened: {:?} projs: {:?} yields: {:?}",
1003-
user_ty.base, ty, user_ty.projs, projected_ty);
1021+
user_ty.base, ty, user_ty.projs, curr_projected_ty);
10041022

1005-
let ty = projected_ty.to_ty(tcx);
1006-
1007-
self.relate_types(ty, v1, a, locations, category)?;
1023+
if let Ok(projected_ty) = curr_projected_ty {
1024+
let ty = projected_ty.to_ty(tcx);
1025+
self.relate_types(ty, v1, a, locations, category)?;
1026+
}
10081027
}
10091028
UserTypeAnnotation::TypeOf(def_id, canonical_substs) => {
10101029
let (

src/librustc_traits/type_op.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,35 @@ impl AscribeUserTypeCx<'me, 'gcx, 'tcx> {
151151
debug!("relate_type_and_user_type: ty of def-id is {:?}", ty);
152152
let ty = self.normalize(ty);
153153

154-
let mut projected_ty = PlaceTy::from_ty(ty);
154+
// We need to follow any provided projetions into the type.
155+
//
156+
// if we hit a ty var as we descend, then just skip the
157+
// attempt to relate the mir local with any type.
158+
159+
struct HitTyVar;
160+
let mut curr_projected_ty: Result<PlaceTy, HitTyVar>;
161+
curr_projected_ty = Ok(PlaceTy::from_ty(ty));
155162
for proj in projs {
156-
projected_ty = projected_ty.projection_ty_core(
163+
let projected_ty = if let Ok(projected_ty) = curr_projected_ty {
164+
projected_ty
165+
} else {
166+
break;
167+
};
168+
curr_projected_ty = projected_ty.projection_ty_core(
157169
tcx, proj, |this, field, &()| {
158-
let ty = this.field_ty(tcx, field);
159-
self.normalize(ty)
170+
if this.to_ty(tcx).is_ty_var() {
171+
Err(HitTyVar)
172+
} else {
173+
let ty = this.field_ty(tcx, field);
174+
Ok(self.normalize(ty))
175+
}
160176
});
161177
}
162-
let ty = projected_ty.to_ty(tcx);
163178

164-
self.relate(mir_ty, variance, ty)?;
179+
if let Ok(projected_ty) = curr_projected_ty {
180+
let ty = projected_ty.to_ty(tcx);
181+
self.relate(mir_ty, variance, ty)?;
182+
}
165183

166184
if let Some(UserSelfTy {
167185
impl_def_id,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// compile-pass
2+
3+
// rust-lang/rust#55552: The strategy pnkfelix landed in PR #55274
4+
// (for ensuring that NLL respects user-provided lifetime annotations)
5+
// did not handle the case where the ascribed type has some expliit
6+
// wildcards (`_`) mixed in, and it caused an internal compiler error
7+
// (ICE).
8+
//
9+
// This test is just checking that we do not ICE when such things
10+
// occur.
11+
12+
struct X;
13+
struct Y;
14+
struct Z;
15+
16+
struct Pair { x: X, y: Y }
17+
18+
pub fn join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
19+
where A: FnOnce() -> RA + Send,
20+
B: FnOnce() -> RB + Send,
21+
RA: Send,
22+
RB: Send
23+
{
24+
(oper_a(), oper_b())
25+
}
26+
27+
fn main() {
28+
let ((_x, _y), _z): (_, Z) = join(|| (X, Y), || Z);
29+
30+
let (Pair { x: _x, y: _y }, Z): (_, Z) = join(|| Pair { x: X, y: Y }, || Z);
31+
}

src/test/ui/issues/issue-23122-2.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next`
1+
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: std::marker::Sized`
22
--> $DIR/issue-23122-2.rs:17:15
33
|
44
LL | impl<T: Next> Next for GetNext<T> {
55
| ^^^^
66
|
77
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
8+
= note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>`
89

910
error: aborting due to previous error
1011

0 commit comments

Comments
 (0)