Skip to content

Commit 79a272c

Browse files
committed
Auto merge of #139938 - matthiaskrgr:rollup-19ddpus, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #139084 (hygiene: Rename semi-transparent to semi-opaque) - #139236 (Use a session counter to make anon dep nodes unique) - #139650 (Fix `register_group_alias` for tools) - #139770 (Rename `LifetimeName` as `LifetimeKind`.) - #139846 (Remove `kw::Empty` uses in rustdoc) - #139891 (Include optional dso_local marker for functions in `enum-match.rs`) - #139908 (parser: Remove old diagnostic notes for type ascription syntax) - #139917 (fix for multiple `#[repr(align(N))]` on functions) Failed merges: - #139615 (Remove `name_or_empty`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3920514 + cbe469a commit 79a272c

File tree

66 files changed

+265
-302
lines changed

Some content is hidden

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

66 files changed

+265
-302
lines changed

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1767,21 +1767,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17671767
) -> &'hir hir::Lifetime {
17681768
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
17691769
let res = match res {
1770-
LifetimeRes::Param { param, .. } => hir::LifetimeName::Param(param),
1770+
LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
17711771
LifetimeRes::Fresh { param, .. } => {
17721772
debug_assert_eq!(ident.name, kw::UnderscoreLifetime);
17731773
let param = self.local_def_id(param);
1774-
hir::LifetimeName::Param(param)
1774+
hir::LifetimeKind::Param(param)
17751775
}
17761776
LifetimeRes::Infer => {
17771777
debug_assert_eq!(ident.name, kw::UnderscoreLifetime);
1778-
hir::LifetimeName::Infer
1778+
hir::LifetimeKind::Infer
17791779
}
17801780
LifetimeRes::Static { .. } => {
17811781
debug_assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
1782-
hir::LifetimeName::Static
1782+
hir::LifetimeKind::Static
17831783
}
1784-
LifetimeRes::Error => hir::LifetimeName::Error,
1784+
LifetimeRes::Error => hir::LifetimeKind::Error,
17851785
LifetimeRes::ElidedAnchor { .. } => {
17861786
panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
17871787
}
@@ -2388,7 +2388,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23882388
let r = hir::Lifetime::new(
23892389
self.next_id(),
23902390
Ident::new(kw::UnderscoreLifetime, self.lower_span(span)),
2391-
hir::LifetimeName::ImplicitObjectLifetimeDefault,
2391+
hir::LifetimeKind::ImplicitObjectLifetimeDefault,
23922392
IsAnonInPath::No,
23932393
);
23942394
debug!("elided_dyn_bound: r={:?}", r);

Diff for: compiler/rustc_attr_parsing/src/attributes/transparency.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl SingleAttributeParser for TransparencyParser {
2020
fn convert(cx: &AcceptContext<'_>, args: &ArgParser<'_>) -> Option<AttributeKind> {
2121
match args.name_value().and_then(|nv| nv.value_as_str()) {
2222
Some(sym::transparent) => Some(Transparency::Transparent),
23-
Some(sym::semitransparent) => Some(Transparency::SemiTransparent),
23+
Some(sym::semiopaque | sym::semitransparent) => Some(Transparency::SemiOpaque),
2424
Some(sym::opaque) => Some(Transparency::Opaque),
2525
Some(other) => {
2626
cx.dcx().span_err(cx.attr_span, format!("unknown macro transparency: `{other}`"));

Diff for: compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
888888
// Skip `async` desugaring `impl Future`.
889889
}
890890
if let TyKind::TraitObject(_, lt) = alias_ty.kind {
891-
if lt.res == hir::LifetimeName::ImplicitObjectLifetimeDefault {
891+
if lt.kind == hir::LifetimeKind::ImplicitObjectLifetimeDefault {
892892
spans_suggs.push((lt.ident.span.shrink_to_hi(), " + 'a".to_string()));
893893
} else {
894894
spans_suggs.push((lt.ident.span, "'a".to_string()));

Diff for: compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
114114
AttributeKind::Repr(reprs) => {
115115
codegen_fn_attrs.alignment = reprs
116116
.iter()
117-
.find_map(|(r, _)| if let ReprAlign(x) = r { Some(*x) } else { None });
117+
.filter_map(|(r, _)| if let ReprAlign(x) = r { Some(*x) } else { None })
118+
.max();
118119
}
119120

120121
_ => {}

Diff for: compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
767767
),
768768
rustc_attr!(
769769
rustc_macro_transparency, Normal,
770-
template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing,
770+
template!(NameValueStr: "transparent|semiopaque|opaque"), ErrorFollowing,
771771
EncodeCrossCrate::Yes, "used internally for testing macro hygiene",
772772
),
773773
rustc_attr!(

Diff for: compiler/rustc_hir/src/hir.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub enum IsAnonInPath {
4242
}
4343

4444
/// A lifetime. The valid field combinations are non-obvious. The following
45-
/// example shows some of them. See also the comments on `LifetimeName`.
45+
/// example shows some of them. See also the comments on `LifetimeKind`.
4646
/// ```
4747
/// #[repr(C)]
4848
/// struct S<'a>(&'a u32); // res=Param, name='a, IsAnonInPath::No
@@ -84,7 +84,7 @@ pub struct Lifetime {
8484
pub ident: Ident,
8585

8686
/// Semantics of this lifetime.
87-
pub res: LifetimeName,
87+
pub kind: LifetimeKind,
8888

8989
/// Is the lifetime anonymous and in a path? Used only for error
9090
/// suggestions. See `Lifetime::suggestion` for example use.
@@ -130,7 +130,7 @@ impl ParamName {
130130
}
131131

132132
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)]
133-
pub enum LifetimeName {
133+
pub enum LifetimeKind {
134134
/// User-given names or fresh (synthetic) names.
135135
Param(LocalDefId),
136136

@@ -160,16 +160,16 @@ pub enum LifetimeName {
160160
Static,
161161
}
162162

163-
impl LifetimeName {
163+
impl LifetimeKind {
164164
fn is_elided(&self) -> bool {
165165
match self {
166-
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,
166+
LifetimeKind::ImplicitObjectLifetimeDefault | LifetimeKind::Infer => true,
167167

168168
// It might seem surprising that `Fresh` counts as not *elided*
169169
// -- but this is because, as far as the code in the compiler is
170170
// concerned -- `Fresh` variants act equivalently to "some fresh name".
171171
// They correspond to early-bound regions on an impl, in other words.
172-
LifetimeName::Error | LifetimeName::Param(..) | LifetimeName::Static => false,
172+
LifetimeKind::Error | LifetimeKind::Param(..) | LifetimeKind::Static => false,
173173
}
174174
}
175175
}
@@ -184,10 +184,10 @@ impl Lifetime {
184184
pub fn new(
185185
hir_id: HirId,
186186
ident: Ident,
187-
res: LifetimeName,
187+
kind: LifetimeKind,
188188
is_anon_in_path: IsAnonInPath,
189189
) -> Lifetime {
190-
let lifetime = Lifetime { hir_id, ident, res, is_anon_in_path };
190+
let lifetime = Lifetime { hir_id, ident, kind, is_anon_in_path };
191191

192192
// Sanity check: elided lifetimes form a strict subset of anonymous lifetimes.
193193
#[cfg(debug_assertions)]
@@ -202,7 +202,7 @@ impl Lifetime {
202202
}
203203

204204
pub fn is_elided(&self) -> bool {
205-
self.res.is_elided()
205+
self.kind.is_elided()
206206
}
207207

208208
pub fn is_anonymous(&self) -> bool {
@@ -1014,7 +1014,7 @@ pub struct WhereRegionPredicate<'hir> {
10141014
impl<'hir> WhereRegionPredicate<'hir> {
10151015
/// Returns `true` if `param_def_id` matches the `lifetime` of this predicate.
10161016
fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1017-
self.lifetime.res == LifetimeName::Param(param_def_id)
1017+
self.lifetime.kind == LifetimeKind::Param(param_def_id)
10181018
}
10191019
}
10201020

Diff for: compiler/rustc_hir/src/hir/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn trait_object_roundtrips_impl(syntax: TraitObjectSyntax) {
5757
Lifetime {
5858
hir_id: HirId::INVALID,
5959
ident: Ident::new(sym::name, DUMMY_SP),
60-
res: LifetimeName::Static,
60+
kind: LifetimeKind::Static,
6161
is_anon_in_path: IsAnonInPath::No,
6262
}
6363
},

Diff for: compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_errors::ErrorGuaranteed;
1616
use rustc_hir::def::{DefKind, Res};
1717
use rustc_hir::intravisit::{self, InferKind, Visitor, VisitorExt};
1818
use rustc_hir::{
19-
self as hir, AmbigArg, GenericArg, GenericParam, GenericParamKind, HirId, LifetimeName, Node,
19+
self as hir, AmbigArg, GenericArg, GenericParam, GenericParamKind, HirId, LifetimeKind, Node,
2020
};
2121
use rustc_macros::extension;
2222
use rustc_middle::hir::nested_filter;
@@ -646,14 +646,14 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
646646
arg: &'tcx hir::PreciseCapturingArg<'tcx>,
647647
) -> Self::Result {
648648
match *arg {
649-
hir::PreciseCapturingArg::Lifetime(lt) => match lt.res {
650-
LifetimeName::Param(def_id) => {
649+
hir::PreciseCapturingArg::Lifetime(lt) => match lt.kind {
650+
LifetimeKind::Param(def_id) => {
651651
self.resolve_lifetime_ref(def_id, lt);
652652
}
653-
LifetimeName::Error => {}
654-
LifetimeName::ImplicitObjectLifetimeDefault
655-
| LifetimeName::Infer
656-
| LifetimeName::Static => {
653+
LifetimeKind::Error => {}
654+
LifetimeKind::ImplicitObjectLifetimeDefault
655+
| LifetimeKind::Infer
656+
| LifetimeKind::Static => {
657657
self.tcx.dcx().emit_err(errors::BadPreciseCapture {
658658
span: lt.ident.span,
659659
kind: "lifetime",
@@ -774,26 +774,26 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
774774
);
775775
}
776776
});
777-
match lifetime.res {
778-
LifetimeName::ImplicitObjectLifetimeDefault => {
777+
match lifetime.kind {
778+
LifetimeKind::ImplicitObjectLifetimeDefault => {
779779
// If the user does not write *anything*, we
780780
// use the object lifetime defaulting
781781
// rules. So e.g., `Box<dyn Debug>` becomes
782782
// `Box<dyn Debug + 'static>`.
783783
self.resolve_object_lifetime_default(&*lifetime)
784784
}
785-
LifetimeName::Infer => {
785+
LifetimeKind::Infer => {
786786
// If the user writes `'_`, we use the *ordinary* elision
787787
// rules. So the `'_` in e.g., `Box<dyn Debug + '_>` will be
788788
// resolved the same as the `'_` in `&'_ Foo`.
789789
//
790790
// cc #48468
791791
}
792-
LifetimeName::Param(..) | LifetimeName::Static => {
792+
LifetimeKind::Param(..) | LifetimeKind::Static => {
793793
// If the user wrote an explicit name, use that.
794794
self.visit_lifetime(&*lifetime);
795795
}
796-
LifetimeName::Error => {}
796+
LifetimeKind::Error => {}
797797
}
798798
}
799799
hir::TyKind::Ref(lifetime_ref, ref mt) => {
@@ -873,17 +873,17 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
873873

874874
#[instrument(level = "debug", skip(self))]
875875
fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
876-
match lifetime_ref.res {
877-
hir::LifetimeName::Static => {
876+
match lifetime_ref.kind {
877+
hir::LifetimeKind::Static => {
878878
self.insert_lifetime(lifetime_ref, ResolvedArg::StaticLifetime)
879879
}
880-
hir::LifetimeName::Param(param_def_id) => {
880+
hir::LifetimeKind::Param(param_def_id) => {
881881
self.resolve_lifetime_ref(param_def_id, lifetime_ref)
882882
}
883883
// If we've already reported an error, just ignore `lifetime_ref`.
884-
hir::LifetimeName::Error => {}
884+
hir::LifetimeKind::Error => {}
885885
// Those will be resolved by typechecking.
886-
hir::LifetimeName::ImplicitObjectLifetimeDefault | hir::LifetimeName::Infer => {}
886+
hir::LifetimeKind::ImplicitObjectLifetimeDefault | hir::LifetimeKind::Infer => {}
887887
}
888888
}
889889

@@ -1063,15 +1063,15 @@ fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: LocalDefId) -> ObjectL
10631063

10641064
for bound in bound.bounds {
10651065
if let hir::GenericBound::Outlives(lifetime) = bound {
1066-
set.insert(lifetime.res);
1066+
set.insert(lifetime.kind);
10671067
}
10681068
}
10691069
}
10701070

10711071
match set {
10721072
Set1::Empty => ObjectLifetimeDefault::Empty,
1073-
Set1::One(hir::LifetimeName::Static) => ObjectLifetimeDefault::Static,
1074-
Set1::One(hir::LifetimeName::Param(param_def_id)) => {
1073+
Set1::One(hir::LifetimeKind::Static) => ObjectLifetimeDefault::Static,
1074+
Set1::One(hir::LifetimeKind::Param(param_def_id)) => {
10751075
ObjectLifetimeDefault::Param(param_def_id.to_def_id())
10761076
}
10771077
_ => ObjectLifetimeDefault::Ambiguous,
@@ -1241,7 +1241,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
12411241
// Fresh lifetimes in APIT used to be allowed in async fns and forbidden in
12421242
// regular fns.
12431243
if let Some(hir::PredicateOrigin::ImplTrait) = where_bound_origin
1244-
&& let hir::LifetimeName::Param(param_id) = lifetime_ref.res
1244+
&& let hir::LifetimeKind::Param(param_id) = lifetime_ref.kind
12451245
&& let Some(generics) =
12461246
self.tcx.hir_get_generics(self.tcx.local_parent(param_id))
12471247
&& let Some(param) = generics.params.iter().find(|p| p.def_id == param_id)
@@ -2440,7 +2440,7 @@ fn is_late_bound_map(
24402440
}
24412441

24422442
fn visit_lifetime(&mut self, lifetime_ref: &'v hir::Lifetime) {
2443-
if let hir::LifetimeName::Param(def_id) = lifetime_ref.res {
2443+
if let hir::LifetimeKind::Param(def_id) = lifetime_ref.kind {
24442444
self.regions.insert(def_id);
24452445
}
24462446
}
@@ -2453,7 +2453,7 @@ fn is_late_bound_map(
24532453

24542454
impl<'tcx> Visitor<'tcx> for AllCollector {
24552455
fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
2456-
if let hir::LifetimeName::Param(def_id) = lifetime_ref.res {
2456+
if let hir::LifetimeKind::Param(def_id) = lifetime_ref.kind {
24572457
self.regions.insert(def_id);
24582458
}
24592459
}

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
415415
self.lower_lifetime(lifetime, RegionInferReason::ExplicitObjectLifetime)
416416
} else {
417417
let reason =
418-
if let hir::LifetimeName::ImplicitObjectLifetimeDefault = lifetime.res {
418+
if let hir::LifetimeKind::ImplicitObjectLifetimeDefault = lifetime.kind {
419419
if let hir::Node::Ty(hir::Ty {
420420
kind: hir::TyKind::Ref(parent_lifetime, _),
421421
..

0 commit comments

Comments
 (0)