Skip to content

Commit 255d04c

Browse files
committed
Auto merge of rust-lang#3167 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 012bd49 + 13bfe14 commit 255d04c

File tree

83 files changed

+878
-339
lines changed

Some content is hidden

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

83 files changed

+878
-339
lines changed

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ impl OutlivesSuggestionBuilder {
5050
// naming the `'self` lifetime in methods, etc.
5151
fn region_name_is_suggestable(name: &RegionName) -> bool {
5252
match name.source {
53-
RegionNameSource::NamedEarlyBoundRegion(..)
54-
| RegionNameSource::NamedFreeRegion(..)
53+
RegionNameSource::NamedEarlyParamRegion(..)
54+
| RegionNameSource::NamedLateParamRegion(..)
5555
| RegionNameSource::Static => true,
5656

5757
// Don't give suggestions for upvars, closure return types, or other unnameable

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
181181

182182
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
183183
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
184-
if let Some(ty::ReFree(free_region)) = self.to_error_region(fr).as_deref()
185-
&& let ty::BoundRegionKind::BrEnv = free_region.bound_region
184+
if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).as_deref()
185+
&& let ty::BoundRegionKind::BrEnv = late_param.bound_region
186186
&& let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty
187187
{
188188
return args.as_closure().kind() == ty::ClosureKind::FnMut;
@@ -995,7 +995,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
995995
.infcx
996996
.tcx
997997
.is_suitable_region(sub)
998-
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.boundregion))
998+
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.bound_region))
999999
else {
10001000
return;
10011001
};
@@ -1004,7 +1004,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
10041004
.infcx
10051005
.tcx
10061006
.is_suitable_region(sup)
1007-
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.boundregion))
1007+
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.bound_region))
10081008
else {
10091009
return;
10101010
};

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+23-20
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ pub(crate) struct RegionName {
2323
}
2424

2525
/// Denotes the source of a region that is named by a `RegionName`. For example, a free region that
26-
/// was named by the user would get `NamedFreeRegion` and `'static` lifetime would get `Static`.
26+
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get `Static`.
2727
/// This helps to print the right kinds of diagnostics.
2828
#[derive(Debug, Clone)]
2929
pub(crate) enum RegionNameSource {
3030
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
31-
NamedEarlyBoundRegion(Span),
31+
NamedEarlyParamRegion(Span),
3232
/// A free region that the user has a name (`'a`) for.
33-
NamedFreeRegion(Span),
33+
NamedLateParamRegion(Span),
3434
/// The `'static` region.
3535
Static,
3636
/// The free region corresponding to the environment of a closure.
@@ -69,8 +69,8 @@ pub(crate) enum RegionNameHighlight {
6969
impl RegionName {
7070
pub(crate) fn was_named(&self) -> bool {
7171
match self.source {
72-
RegionNameSource::NamedEarlyBoundRegion(..)
73-
| RegionNameSource::NamedFreeRegion(..)
72+
RegionNameSource::NamedEarlyParamRegion(..)
73+
| RegionNameSource::NamedLateParamRegion(..)
7474
| RegionNameSource::Static => true,
7575
RegionNameSource::SynthesizedFreeEnvRegion(..)
7676
| RegionNameSource::AnonRegionFromArgument(..)
@@ -85,8 +85,8 @@ impl RegionName {
8585
pub(crate) fn span(&self) -> Option<Span> {
8686
match self.source {
8787
RegionNameSource::Static => None,
88-
RegionNameSource::NamedEarlyBoundRegion(span)
89-
| RegionNameSource::NamedFreeRegion(span)
88+
RegionNameSource::NamedEarlyParamRegion(span)
89+
| RegionNameSource::NamedLateParamRegion(span)
9090
| RegionNameSource::SynthesizedFreeEnvRegion(span, _)
9191
| RegionNameSource::AnonRegionFromUpvar(span, _)
9292
| RegionNameSource::AnonRegionFromYieldTy(span, _)
@@ -104,8 +104,8 @@ impl RegionName {
104104

105105
pub(crate) fn highlight_region_name(&self, diag: &mut Diagnostic) {
106106
match &self.source {
107-
RegionNameSource::NamedFreeRegion(span)
108-
| RegionNameSource::NamedEarlyBoundRegion(span) => {
107+
RegionNameSource::NamedLateParamRegion(span)
108+
| RegionNameSource::NamedEarlyParamRegion(span) => {
109109
diag.span_label(*span, format!("lifetime `{self}` defined here"));
110110
}
111111
RegionNameSource::SynthesizedFreeEnvRegion(span, note) => {
@@ -280,28 +280,31 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
280280

281281
debug!("give_region_a_name: error_region = {:?}", error_region);
282282
match *error_region {
283-
ty::ReEarlyBound(ebr) => ebr.has_name().then(|| {
283+
ty::ReEarlyParam(ebr) => ebr.has_name().then(|| {
284284
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
285-
RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyBoundRegion(span) }
285+
RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyParamRegion(span) }
286286
}),
287287

288288
ty::ReStatic => {
289289
Some(RegionName { name: kw::StaticLifetime, source: RegionNameSource::Static })
290290
}
291291

292-
ty::ReFree(free_region) => match free_region.bound_region {
292+
ty::ReLateParam(late_param) => match late_param.bound_region {
293293
ty::BoundRegionKind::BrNamed(region_def_id, name) => {
294294
// Get the span to point to, even if we don't use the name.
295295
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
296296
debug!(
297297
"bound region named: {:?}, is_named: {:?}",
298298
name,
299-
free_region.bound_region.is_named()
299+
late_param.bound_region.is_named()
300300
);
301301

302-
if free_region.bound_region.is_named() {
302+
if late_param.bound_region.is_named() {
303303
// A named region that is actually named.
304-
Some(RegionName { name, source: RegionNameSource::NamedFreeRegion(span) })
304+
Some(RegionName {
305+
name,
306+
source: RegionNameSource::NamedLateParamRegion(span),
307+
})
305308
} else if tcx.asyncness(self.mir_hir_id().owner).is_async() {
306309
// If we spuriously thought that the region is named, we should let the
307310
// system generate a true name for error messages. Currently this can
@@ -847,7 +850,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
847850
&self,
848851
fr: RegionVid,
849852
) -> Option<RegionName> {
850-
let ty::ReEarlyBound(region) = *self.to_error_region(fr)? else {
853+
let ty::ReEarlyParam(region) = *self.to_error_region(fr)? else {
851854
return None;
852855
};
853856
if region.has_name() {
@@ -862,7 +865,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
862865

863866
let found = tcx
864867
.any_free_region_meets(&tcx.type_of(region_parent).instantiate_identity(), |r| {
865-
*r == ty::ReEarlyBound(region)
868+
*r == ty::ReEarlyParam(region)
866869
});
867870

868871
Some(RegionName {
@@ -881,7 +884,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
881884
&self,
882885
fr: RegionVid,
883886
) -> Option<RegionName> {
884-
let ty::ReEarlyBound(region) = *self.to_error_region(fr)? else {
887+
let ty::ReEarlyParam(region) = *self.to_error_region(fr)? else {
885888
return None;
886889
};
887890
if region.has_name() {
@@ -943,7 +946,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
943946
&self,
944947
clauses: &[ty::Clause<'tcx>],
945948
ty: Ty<'tcx>,
946-
region: ty::EarlyBoundRegion,
949+
region: ty::EarlyParamRegion,
947950
) -> bool {
948951
let tcx = self.infcx.tcx;
949952
ty.walk().any(|arg| {
@@ -956,7 +959,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
956959
ty::ClauseKind::Projection(data) if data.projection_ty.self_ty() == ty => {}
957960
_ => return false,
958961
}
959-
tcx.any_free_region_meets(pred, |r| *r == ty::ReEarlyBound(region))
962+
tcx.any_free_region_meets(pred, |r| *r == ty::ReEarlyParam(region))
960963
})
961964
} else {
962965
false

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
3636
/// call `infer_opaque_definition_from_instantiation` to get the inferred
3737
/// type of `_Return<'_a>`. `infer_opaque_definition_from_instantiation`
3838
/// compares lifetimes directly, so we need to map the inference variables
39-
/// back to concrete lifetimes: `'static`, `ReEarlyBound` or `ReFree`.
39+
/// back to concrete lifetimes: `'static`, `ReEarlyParam` or `ReLateParam`.
4040
///
4141
/// First we map all the lifetimes in the concrete type to an equal
4242
/// universal region that occurs in the concrete type's args, in this case
@@ -386,7 +386,7 @@ fn check_opaque_type_parameter_valid(
386386
let arg_is_param = match arg.unpack() {
387387
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
388388
GenericArgKind::Lifetime(lt) if is_ty_alias => {
389-
matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
389+
matches!(*lt, ty::ReEarlyParam(_) | ty::ReLateParam(_))
390390
}
391391
// FIXME(#113916): we can't currently check for unique lifetime params,
392392
// see that issue for more. We will also have to ignore unused lifetime

compiler/rustc_borrowck/src/universal_regions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
462462

463463
// "Liberate" the late-bound regions. These correspond to
464464
// "local" free regions.
465-
466465
let bound_inputs_and_output = self.compute_inputs_and_output(&indices, defining_ty);
467466

468467
let inputs_and_output = self.infcx.replace_bound_regions_with_nll_infer_vars(
@@ -784,7 +783,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
784783
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
785784
debug!(?br);
786785
let liberated_region =
787-
ty::Region::new_free(self.tcx, all_outlive_scope.to_def_id(), br.kind);
786+
ty::Region::new_late_param(self.tcx, all_outlive_scope.to_def_id(), br.kind);
788787
let region_vid = {
789788
let name = match br.kind.get_name() {
790789
Some(name) => name,
@@ -854,7 +853,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
854853
/// Initially, the `UniversalRegionIndices` map contains only the
855854
/// early-bound regions in scope. Once that is all setup, we come
856855
/// in later and instantiate the late-bound regions, and then we
857-
/// insert the `ReFree` version of those into the map as
856+
/// insert the `ReLateParam` version of those into the map as
858857
/// well. These are used for error reporting.
859858
fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>, vid: ty::RegionVid) {
860859
debug!("insert_late_bound_region({:?}, {:?})", r, vid);
@@ -933,7 +932,8 @@ fn for_each_late_bound_region_in_item<'tcx>(
933932
let ty::BoundVariableKind::Region(bound_region) = bound_var else {
934933
continue;
935934
};
936-
let liberated_region = ty::Region::new_free(tcx, mir_def_id.to_def_id(), bound_region);
935+
let liberated_region =
936+
ty::Region::new_late_param(tcx, mir_def_id.to_def_id(), bound_region);
937937
f(liberated_region);
938938
}
939939
}

compiler/rustc_codegen_llvm/src/context.rs

+18
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,24 @@ pub unsafe fn create_module<'ll>(
368368
llvm::LLVMMDNodeInContext(llcx, &name_metadata, 1),
369369
);
370370

371+
// Add module flags specified via -Z llvm_module_flag
372+
for (key, value, behavior) in &sess.opts.unstable_opts.llvm_module_flag {
373+
let key = format!("{key}\0");
374+
let behavior = match behavior.as_str() {
375+
"error" => llvm::LLVMModFlagBehavior::Error,
376+
"warning" => llvm::LLVMModFlagBehavior::Warning,
377+
"require" => llvm::LLVMModFlagBehavior::Require,
378+
"override" => llvm::LLVMModFlagBehavior::Override,
379+
"append" => llvm::LLVMModFlagBehavior::Append,
380+
"appendunique" => llvm::LLVMModFlagBehavior::AppendUnique,
381+
"max" => llvm::LLVMModFlagBehavior::Max,
382+
"min" => llvm::LLVMModFlagBehavior::Min,
383+
// We already checked this during option parsing
384+
_ => unreachable!(),
385+
};
386+
llvm::LLVMRustAddModuleFlag(llmod, behavior, key.as_ptr().cast(), *value)
387+
}
388+
371389
llmod
372390
}
373391

compiler/rustc_driver_impl/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1520,14 +1520,14 @@ fn report_ice(
15201520
/// This allows tools to enable rust logging without having to magically match rustc's
15211521
/// tracing crate version.
15221522
pub fn init_rustc_env_logger(handler: &EarlyErrorHandler) {
1523-
init_env_logger(handler, "RUSTC_LOG");
1523+
init_logger(handler, rustc_log::LoggerConfig::from_env("RUSTC_LOG"));
15241524
}
15251525

15261526
/// This allows tools to enable rust logging without having to magically match rustc's
1527-
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
1528-
/// other than `RUSTC_LOG`.
1529-
pub fn init_env_logger(handler: &EarlyErrorHandler, env: &str) {
1530-
if let Err(error) = rustc_log::init_env_logger(env) {
1527+
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose
1528+
/// the values directly rather than having to set an environment variable.
1529+
pub fn init_logger(handler: &EarlyErrorHandler, cfg: rustc_log::LoggerConfig) {
1530+
if let Err(error) = rustc_log::init_logger(cfg) {
15311531
handler.early_error(error.to_string());
15321532
}
15331533
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
258258
let item_def_id = tcx.hir().ty_param_owner(def_id.expect_local());
259259
let generics = tcx.generics_of(item_def_id);
260260
let index = generics.param_def_id_to_index[&def_id];
261-
ty::Region::new_early_bound(tcx, ty::EarlyBoundRegion { def_id, index, name })
261+
ty::Region::new_early_param(tcx, ty::EarlyParamRegion { def_id, index, name })
262262
}
263263

264264
Some(rbv::ResolvedArg::Free(scope, id)) => {
265265
let name = lifetime_name(id.expect_local());
266-
ty::Region::new_free(tcx, scope, ty::BrNamed(id, name))
266+
ty::Region::new_late_param(tcx, scope, ty::BrNamed(id, name))
267267

268268
// (*) -- not late-bound, won't change
269269
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
532532
}
533533

534534
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
535-
if let ty::ReFree(fr) = *r {
536-
ty::Region::new_free(
535+
if let ty::ReLateParam(fr) = *r {
536+
ty::Region::new_late_param(
537537
self.tcx,
538538
fr.scope,
539539
self.mapping.get(&fr.bound_region).copied().unwrap_or(fr.bound_region),
@@ -1078,20 +1078,20 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
10781078
region: ty::Region<'tcx>,
10791079
) -> Result<ty::Region<'tcx>, Self::Error> {
10801080
match region.kind() {
1081-
// Remap all free regions, which correspond to late-bound regions in the function.
1082-
ty::ReFree(_) => {}
1081+
// Remap late-bound regions from the function.
1082+
ty::ReLateParam(_) => {}
10831083
// Remap early-bound regions as long as they don't come from the `impl` itself,
10841084
// in which case we don't really need to renumber them.
1085-
ty::ReEarlyBound(ebr) if self.tcx.parent(ebr.def_id) != self.impl_def_id => {}
1085+
ty::ReEarlyParam(ebr) if self.tcx.parent(ebr.def_id) != self.impl_def_id => {}
10861086
_ => return Ok(region),
10871087
}
10881088

10891089
let e = if let Some(region) = self.map.get(&region) {
1090-
if let ty::ReEarlyBound(e) = region.kind() { e } else { bug!() }
1090+
if let ty::ReEarlyParam(e) = region.kind() { e } else { bug!() }
10911091
} else {
10921092
let guar = match region.kind() {
1093-
ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, .. })
1094-
| ty::ReFree(ty::FreeRegion {
1093+
ty::ReEarlyParam(ty::EarlyParamRegion { def_id, .. })
1094+
| ty::ReLateParam(ty::LateParamRegion {
10951095
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
10961096
..
10971097
}) => {
@@ -1119,9 +1119,9 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
11191119
return Err(guar);
11201120
};
11211121

1122-
Ok(ty::Region::new_early_bound(
1122+
Ok(ty::Region::new_early_param(
11231123
self.tcx,
1124-
ty::EarlyBoundRegion {
1124+
ty::EarlyParamRegion {
11251125
def_id: e.def_id,
11261126
name: e.name,
11271127
index: (e.index as usize - self.num_trait_args + self.num_impl_args) as u32,

compiler/rustc_hir_analysis/src/check/dropck.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
8181
self_type_did: DefId,
8282
adt_to_impl_args: GenericArgsRef<'tcx>,
8383
) -> Result<(), ErrorGuaranteed> {
84-
let Err(arg) = tcx.uses_unique_generic_params(adt_to_impl_args, CheckRegions::OnlyEarlyBound)
85-
else {
84+
let Err(arg) = tcx.uses_unique_generic_params(adt_to_impl_args, CheckRegions::OnlyParam) else {
8685
return Ok(());
8786
};
8887

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
595595
// Same for the region. In our example, 'a corresponds
596596
// to the 'me parameter.
597597
let region_param = gat_generics.param_at(*region_a_idx, tcx);
598-
let region_param = ty::Region::new_early_bound(
598+
let region_param = ty::Region::new_early_param(
599599
tcx,
600-
ty::EarlyBoundRegion {
600+
ty::EarlyParamRegion {
601601
def_id: region_param.def_id,
602602
index: region_param.index,
603603
name: region_param.name,
@@ -628,19 +628,19 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
628628
debug!("required clause: {region_a} must outlive {region_b}");
629629
// Translate into the generic parameters of the GAT.
630630
let region_a_param = gat_generics.param_at(*region_a_idx, tcx);
631-
let region_a_param = ty::Region::new_early_bound(
631+
let region_a_param = ty::Region::new_early_param(
632632
tcx,
633-
ty::EarlyBoundRegion {
633+
ty::EarlyParamRegion {
634634
def_id: region_a_param.def_id,
635635
index: region_a_param.index,
636636
name: region_a_param.name,
637637
},
638638
);
639639
// Same for the region.
640640
let region_b_param = gat_generics.param_at(*region_b_idx, tcx);
641-
let region_b_param = ty::Region::new_early_bound(
641+
let region_b_param = ty::Region::new_early_param(
642642
tcx,
643-
ty::EarlyBoundRegion {
643+
ty::EarlyParamRegion {
644644
def_id: region_b_param.def_id,
645645
index: region_b_param.index,
646646
name: region_b_param.name,

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ fn infringing_fields_error(
550550
.entry((ty.clone(), predicate.clone()))
551551
.or_default()
552552
.push(origin.span());
553-
if let ty::RegionKind::ReEarlyBound(ebr) = *b
553+
if let ty::RegionKind::ReEarlyParam(ebr) = *b
554554
&& ebr.has_name()
555555
{
556556
bounds.push((b.to_string(), a.to_string(), None));

0 commit comments

Comments
 (0)