Skip to content

Commit c078410

Browse files
committed
Auto merge of rust-lang#102822 - notriddle:rollup-mgfjb62, r=notriddle
Rollup of 8 pull requests Successful merges: - rust-lang#99818 (don't ICE when normalizing closure input tys) - rust-lang#102514 (Don't repeat lifetime names from outer binder in print) - rust-lang#102661 (rustdoc: Document effect of fundamental types) - rust-lang#102782 (Add regression test for rust-lang#102124) - rust-lang#102790 (Fix llvm-tblgen for cross compiling) - rust-lang#102807 (Document `rust-docs-json` component) - rust-lang#102812 (Remove empty core::lazy and std::lazy) - rust-lang#102818 (Clean up rustdoc highlight.rs imports a bit) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f382c27 + 16a1eea commit c078410

26 files changed

+339
-101
lines changed

compiler/rustc_borrowck/src/type_check/canonical.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
5252
Some(error_info) => error_info.to_universe_info(old_universe),
5353
None => UniverseInfo::other(),
5454
};
55-
for u in old_universe..universe {
56-
self.borrowck_context
57-
.constraints
58-
.universe_causes
59-
.insert(u + 1, universe_info.clone());
55+
for u in (old_universe + 1)..=universe {
56+
self.borrowck_context.constraints.universe_causes.insert(u, universe_info.clone());
6057
}
6158
}
6259

@@ -71,15 +68,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
7168
where
7269
T: TypeFoldable<'tcx>,
7370
{
71+
let old_universe = self.infcx.universe();
72+
7473
let (instantiated, _) =
7574
self.infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical);
7675

77-
for u in 0..canonical.max_universe.as_u32() {
78-
let info = UniverseInfo::other();
79-
self.borrowck_context
80-
.constraints
81-
.universe_causes
82-
.insert(ty::UniverseIndex::from_u32(u), info);
76+
for u in (old_universe + 1)..=self.infcx.universe() {
77+
self.borrowck_context.constraints.universe_causes.insert(u, UniverseInfo::other());
8378
}
8479

8580
instantiated

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_infer::infer::InferCtxt;
88
use rustc_middle::mir::ConstraintCategory;
99
use rustc_middle::traits::query::OutlivesBound;
1010
use rustc_middle::ty::{self, RegionVid, Ty};
11-
use rustc_span::DUMMY_SP;
1211
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
1312
use std::rc::Rc;
1413
use type_op::TypeOpOutput;
@@ -219,6 +218,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
219218
}
220219

221220
pub(crate) fn create(mut self) -> CreateResult<'tcx> {
221+
let span = self.infcx.tcx.def_span(self.universal_regions.defining_ty.def_id());
222222
let unnormalized_input_output_tys = self
223223
.universal_regions
224224
.unnormalized_input_tys
@@ -250,7 +250,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
250250
self.infcx
251251
.tcx
252252
.sess
253-
.delay_span_bug(DUMMY_SP, &format!("failed to normalize {:?}", ty));
253+
.delay_span_bug(span, &format!("failed to normalize {:?}", ty));
254254
TypeOpOutput {
255255
output: self.infcx.tcx.ty_error(),
256256
constraints: None,
@@ -301,8 +301,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
301301
&self.region_bound_pairs,
302302
self.implicit_region_bound,
303303
self.param_env,
304-
Locations::All(DUMMY_SP),
305-
DUMMY_SP,
304+
Locations::All(span),
305+
span,
306306
ConstraintCategory::Internal,
307307
&mut self.constraints,
308308
)

compiler/rustc_borrowck/src/type_check/input_output.rs

+2-37
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@
77
//! `RETURN_PLACE` the MIR arguments) are always fully normalized (and
88
//! contain revealed `impl Trait` values).
99
10-
use crate::type_check::constraint_conversion::ConstraintConversion;
1110
use rustc_index::vec::Idx;
1211
use rustc_infer::infer::LateBoundRegionConversionTime;
1312
use rustc_middle::mir::*;
1413
use rustc_middle::ty::Ty;
1514
use rustc_span::Span;
16-
use rustc_span::DUMMY_SP;
17-
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
18-
use rustc_trait_selection::traits::query::Fallible;
19-
use type_op::TypeOpOutput;
2015

2116
use crate::universal_regions::UniversalRegions;
2217

@@ -185,7 +180,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
185180
}
186181
}
187182

188-
#[instrument(skip(self, span), level = "debug")]
183+
#[instrument(skip(self), level = "debug")]
189184
fn equate_normalized_input_or_output(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, span: Span) {
190185
if let Err(_) =
191186
self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation)
@@ -194,13 +189,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
194189
// `rustc_traits::normalize_after_erasing_regions`. Ideally, we'd
195190
// like to normalize *before* inserting into `local_decls`, but
196191
// doing so ends up causing some other trouble.
197-
let b = match self.normalize_and_add_constraints(b) {
198-
Ok(n) => n,
199-
Err(_) => {
200-
debug!("equate_inputs_and_outputs: NoSolution");
201-
b
202-
}
203-
};
192+
let b = self.normalize(b, Locations::All(span));
204193

205194
// Note: if we have to introduce new placeholders during normalization above, then we won't have
206195
// added those universes to the universe info, which we would want in `relate_tys`.
@@ -218,28 +207,4 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
218207
}
219208
}
220209
}
221-
222-
pub(crate) fn normalize_and_add_constraints(&mut self, t: Ty<'tcx>) -> Fallible<Ty<'tcx>> {
223-
let TypeOpOutput { output: norm_ty, constraints, .. } =
224-
self.param_env.and(type_op::normalize::Normalize::new(t)).fully_perform(self.infcx)?;
225-
226-
debug!("{:?} normalized to {:?}", t, norm_ty);
227-
228-
for data in constraints {
229-
ConstraintConversion::new(
230-
self.infcx,
231-
&self.borrowck_context.universal_regions,
232-
&self.region_bound_pairs,
233-
self.implicit_region_bound,
234-
self.param_env,
235-
Locations::All(DUMMY_SP),
236-
DUMMY_SP,
237-
ConstraintCategory::Internal,
238-
&mut self.borrowck_context.constraints,
239-
)
240-
.convert_all(&*data);
241-
}
242-
243-
Ok(norm_ty)
244-
}
245210
}

compiler/rustc_borrowck/src/type_check/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
138138
use_polonius: bool,
139139
) -> MirTypeckResults<'tcx> {
140140
let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
141-
let mut universe_causes = FxHashMap::default();
142-
universe_causes.insert(ty::UniverseIndex::from_u32(0), UniverseInfo::other());
143141
let mut constraints = MirTypeckRegionConstraints {
144142
placeholder_indices: PlaceholderIndices::default(),
145143
placeholder_index_to_region: IndexVec::default(),
@@ -148,7 +146,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
148146
member_constraints: MemberConstraintSet::default(),
149147
closure_bounds_mapping: Default::default(),
150148
type_tests: Vec::default(),
151-
universe_causes,
149+
universe_causes: FxHashMap::default(),
152150
};
153151

154152
let CreateResult {
@@ -165,9 +163,8 @@ pub(crate) fn type_check<'mir, 'tcx>(
165163

166164
debug!(?normalized_inputs_and_output);
167165

168-
for u in ty::UniverseIndex::ROOT..infcx.universe() {
169-
let info = UniverseInfo::other();
170-
constraints.universe_causes.insert(u, info);
166+
for u in ty::UniverseIndex::ROOT..=infcx.universe() {
167+
constraints.universe_causes.insert(u, UniverseInfo::other());
171168
}
172169

173170
let mut borrowck_context = BorrowCheckContext {

compiler/rustc_middle/src/ty/print/pretty.rs

+63-12
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,14 @@ struct RegionFolder<'a, 'tcx> {
20552055
tcx: TyCtxt<'tcx>,
20562056
current_index: ty::DebruijnIndex,
20572057
region_map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
2058-
name: &'a mut (dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a),
2058+
name: &'a mut (
2059+
dyn FnMut(
2060+
Option<ty::DebruijnIndex>, // Debruijn index of the folded late-bound region
2061+
ty::DebruijnIndex, // Index corresponding to binder level
2062+
ty::BoundRegion,
2063+
) -> ty::Region<'tcx>
2064+
+ 'a
2065+
),
20592066
}
20602067

20612068
impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
@@ -2086,7 +2093,9 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
20862093
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
20872094
let name = &mut self.name;
20882095
let region = match *r {
2089-
ty::ReLateBound(_, br) => *self.region_map.entry(br).or_insert_with(|| name(br)),
2096+
ty::ReLateBound(db, br) if db >= self.current_index => {
2097+
*self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br))
2098+
}
20902099
ty::RePlaceholder(ty::PlaceholderRegion { name: kind, .. }) => {
20912100
// If this is an anonymous placeholder, don't rename. Otherwise, in some
20922101
// async fns, we get a `for<'r> Send` bound
@@ -2095,7 +2104,10 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
20952104
_ => {
20962105
// Index doesn't matter, since this is just for naming and these never get bound
20972106
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind };
2098-
*self.region_map.entry(br).or_insert_with(|| name(br))
2107+
*self
2108+
.region_map
2109+
.entry(br)
2110+
.or_insert_with(|| name(None, self.current_index, br))
20992111
}
21002112
}
21012113
}
@@ -2234,24 +2246,63 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
22342246
})
22352247
} else {
22362248
let tcx = self.tcx;
2237-
let mut name = |br: ty::BoundRegion| {
2238-
start_or_continue(&mut self, "for<", ", ");
2239-
let kind = match br.kind {
2249+
2250+
// Closure used in `RegionFolder` to create names for anonymous late-bound
2251+
// regions. We use two `DebruijnIndex`es (one for the currently folded
2252+
// late-bound region and the other for the binder level) to determine
2253+
// whether a name has already been created for the currently folded region,
2254+
// see issue #102392.
2255+
let mut name = |lifetime_idx: Option<ty::DebruijnIndex>,
2256+
binder_level_idx: ty::DebruijnIndex,
2257+
br: ty::BoundRegion| {
2258+
let (name, kind) = match br.kind {
22402259
ty::BrAnon(_) | ty::BrEnv => {
22412260
let name = next_name(&self);
2242-
do_continue(&mut self, name);
2243-
ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)
2261+
2262+
if let Some(lt_idx) = lifetime_idx {
2263+
if lt_idx > binder_level_idx {
2264+
let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name);
2265+
return tcx.mk_region(ty::ReLateBound(
2266+
ty::INNERMOST,
2267+
ty::BoundRegion { var: br.var, kind },
2268+
));
2269+
}
2270+
}
2271+
2272+
(name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name))
22442273
}
22452274
ty::BrNamed(def_id, kw::UnderscoreLifetime) => {
22462275
let name = next_name(&self);
2247-
do_continue(&mut self, name);
2248-
ty::BrNamed(def_id, name)
2276+
2277+
if let Some(lt_idx) = lifetime_idx {
2278+
if lt_idx > binder_level_idx {
2279+
let kind = ty::BrNamed(def_id, name);
2280+
return tcx.mk_region(ty::ReLateBound(
2281+
ty::INNERMOST,
2282+
ty::BoundRegion { var: br.var, kind },
2283+
));
2284+
}
2285+
}
2286+
2287+
(name, ty::BrNamed(def_id, name))
22492288
}
22502289
ty::BrNamed(_, name) => {
2251-
do_continue(&mut self, name);
2252-
br.kind
2290+
if let Some(lt_idx) = lifetime_idx {
2291+
if lt_idx > binder_level_idx {
2292+
let kind = br.kind;
2293+
return tcx.mk_region(ty::ReLateBound(
2294+
ty::INNERMOST,
2295+
ty::BoundRegion { var: br.var, kind },
2296+
));
2297+
}
2298+
}
2299+
2300+
(name, br.kind)
22532301
}
22542302
};
2303+
2304+
start_or_continue(&mut self, "for<", ", ");
2305+
do_continue(&mut self, name);
22552306
tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BoundRegion { var: br.var, kind }))
22562307
};
22572308
let mut folder = RegionFolder {

library/core/src/lazy.rs

-1
This file was deleted.

library/core/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ pub mod cell;
326326
pub mod char;
327327
pub mod ffi;
328328
pub mod iter;
329-
#[unstable(feature = "once_cell", issue = "74465")]
330-
pub mod lazy;
331329
pub mod option;
332330
pub mod panic;
333331
pub mod panicking;

library/std/src/lazy.rs

-1
This file was deleted.

library/std/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,6 @@ pub mod process;
529529
pub mod sync;
530530
pub mod time;
531531

532-
#[unstable(feature = "once_cell", issue = "74465")]
533-
pub mod lazy;
534-
535532
// Pull in `std_float` crate into libstd. The contents of
536533
// `std_float` are in a different repository: rust-lang/portable-simd.
537534
#[path = "../../portable-simd/crates/std_float/src/lib.rs"]

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,7 @@ impl Step for RustDev {
20282028
"llvm-nm",
20292029
"llvm-dwarfdump",
20302030
"llvm-dis",
2031+
"llvm-tblgen",
20312032
] {
20322033
tarball.add_file(src_bindir.join(exe(bin, target)), "bin", 0o755);
20332034
}

src/bootstrap/download-ci-llvm-stamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/97550
4+
Last change is for: https://github.com/rust-lang/rust/pull/102790

src/bootstrap/native.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,18 @@ impl Step for Llvm {
497497

498498
// https://llvm.org/docs/HowToCrossCompileLLVM.html
499499
if target != builder.config.build {
500-
builder.ensure(Llvm { target: builder.config.build });
501-
// FIXME: if the llvm root for the build triple is overridden then we
502-
// should use llvm-tblgen from there, also should verify that it
503-
// actually exists most of the time in normal installs of LLVM.
504-
let host_bin = builder.llvm_out(builder.config.build).join("bin");
505-
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
506-
// LLVM_NM is required for cross compiling using MSVC
507-
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
508-
cfg.define(
509-
"LLVM_CONFIG_PATH",
510-
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
511-
);
500+
let llvm_config = builder.ensure(Llvm { target: builder.config.build });
501+
if !builder.config.dry_run {
502+
let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir"));
503+
let host_bin = Path::new(llvm_bindir.trim());
504+
cfg.define(
505+
"LLVM_TABLEGEN",
506+
host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION),
507+
);
508+
// LLVM_NM is required for cross compiling using MSVC
509+
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
510+
}
511+
cfg.define("LLVM_CONFIG_PATH", llvm_config);
512512
if builder.config.llvm_clang {
513513
let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
514514
let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);

0 commit comments

Comments
 (0)