Skip to content

Commit 8e7fd55

Browse files
committed
Auto merge of rust-lang#114604 - matthiaskrgr:rollup-o1jltfn, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#114376 (Avoid exporting __rust_alloc_error_handler_should_panic more than once.) - rust-lang#114413 (Warn when #[macro_export] is applied on decl macros) - rust-lang#114497 (Revert rust-lang#98333 "Re-enable atomic loads and stores for all RISC-V targets") - rust-lang#114500 (Remove arm crypto target feature) - rust-lang#114566 (Store the laziness of type aliases in their `DefKind`) - rust-lang#114594 (Structurally normalize weak and inherent in new solver) - rust-lang#114596 (Rename method in `opt-dist`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 443c316 + 07b2c97 commit 8e7fd55

File tree

75 files changed

+321
-165
lines changed

Some content is hidden

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

75 files changed

+321
-165
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
516516
// be the same as those of the ADT.
517517
// FIXME: We should be able to do something similar to
518518
// match_adt_and_segment in this case.
519-
Res::Def(DefKind::TyAlias, _) => (),
519+
Res::Def(DefKind::TyAlias { .. }, _) => (),
520520
_ => {
521521
if let Some(last_segment) = path.segments.last() {
522522
if let Some(highlight) = self.match_adt_and_segment(

Diff for: compiler/rustc_codegen_ssa/src/back/symbol_export.rs

-9
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,6 @@ fn exported_symbols_provider_local(
233233
));
234234
}
235235

236-
symbols.push((
237-
ExportedSymbol::NoDefId(SymbolName::new(tcx, OomStrategy::SYMBOL)),
238-
SymbolExportInfo {
239-
level: SymbolExportLevel::Rust,
240-
kind: SymbolExportKind::Text,
241-
used: false,
242-
},
243-
));
244-
245236
let exported_symbol =
246237
ExportedSymbol::NoDefId(SymbolName::new(tcx, NO_ALLOC_SHIM_IS_UNSTABLE));
247238
symbols.push((

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

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
2929
("aclass", Some(sym::arm_target_feature)),
3030
("aes", Some(sym::arm_target_feature)),
3131
("crc", Some(sym::arm_target_feature)),
32-
("crypto", Some(sym::arm_target_feature)),
3332
("d32", Some(sym::arm_target_feature)),
3433
("dotprod", Some(sym::arm_target_feature)),
3534
("dsp", Some(sym::arm_target_feature)),

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ pub enum DefKind {
6161
Variant,
6262
Trait,
6363
/// Type alias: `type Foo = Bar;`
64-
TyAlias,
64+
TyAlias {
65+
lazy: bool,
66+
},
6567
/// Type from an `extern` block.
6668
ForeignTy,
6769
/// Trait alias: `trait IntIterator = Iterator<Item = i32>;`
@@ -141,7 +143,7 @@ impl DefKind {
141143
DefKind::Ctor(CtorOf::Struct, CtorKind::Fn) => "tuple struct",
142144
DefKind::Ctor(CtorOf::Struct, CtorKind::Const) => "unit struct",
143145
DefKind::OpaqueTy => "opaque type",
144-
DefKind::TyAlias => "type alias",
146+
DefKind::TyAlias { .. } => "type alias",
145147
DefKind::TraitAlias => "trait alias",
146148
DefKind::AssocTy => "associated type",
147149
DefKind::Union => "union",
@@ -197,7 +199,7 @@ impl DefKind {
197199
| DefKind::Variant
198200
| DefKind::Trait
199201
| DefKind::OpaqueTy
200-
| DefKind::TyAlias
202+
| DefKind::TyAlias { .. }
201203
| DefKind::ForeignTy
202204
| DefKind::TraitAlias
203205
| DefKind::AssocTy
@@ -248,7 +250,7 @@ impl DefKind {
248250
| DefKind::Enum
249251
| DefKind::Variant
250252
| DefKind::Trait
251-
| DefKind::TyAlias
253+
| DefKind::TyAlias { .. }
252254
| DefKind::ForeignTy
253255
| DefKind::TraitAlias
254256
| DefKind::AssocTy

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Target {
101101
DefKind::Mod => Target::Mod,
102102
DefKind::ForeignMod => Target::ForeignMod,
103103
DefKind::GlobalAsm => Target::GlobalAsm,
104-
DefKind::TyAlias => Target::TyAlias,
104+
DefKind::TyAlias { .. } => Target::TyAlias,
105105
DefKind::OpaqueTy => Target::OpaqueTy,
106106
DefKind::Enum => Target::Enum,
107107
DefKind::Struct => Target::Struct,

Diff for: compiler/rustc_hir_analysis/src/astconv/mod.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -907,19 +907,21 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
907907
did: DefId,
908908
item_segment: &hir::PathSegment<'_>,
909909
) -> Ty<'tcx> {
910+
let tcx = self.tcx();
910911
let args = self.ast_path_args_for_ty(span, did, item_segment);
911-
let ty = self.tcx().at(span).type_of(did);
912+
let ty = tcx.at(span).type_of(did);
912913

913-
if matches!(self.tcx().def_kind(did), DefKind::TyAlias)
914-
&& (ty.skip_binder().has_opaque_types() || self.tcx().features().lazy_type_alias)
914+
if let DefKind::TyAlias { lazy } = tcx.def_kind(did)
915+
&& (lazy || ty.skip_binder().has_opaque_types())
915916
{
916917
// Type aliases referring to types that contain opaque types (but aren't just directly
917-
// referencing a single opaque type) get encoded as a type alias that normalization will
918+
// referencing a single opaque type) as well as those defined in crates that have the
919+
// feature `lazy_type_alias` enabled get encoded as a type alias that normalization will
918920
// then actually instantiate the where bounds of.
919-
let alias_ty = self.tcx().mk_alias_ty(did, args);
920-
Ty::new_alias(self.tcx(), ty::Weak, alias_ty)
921+
let alias_ty = tcx.mk_alias_ty(did, args);
922+
Ty::new_alias(tcx, ty::Weak, alias_ty)
921923
} else {
922-
ty.instantiate(self.tcx(), args)
924+
ty.instantiate(tcx, args)
923925
}
924926
}
925927

@@ -2158,7 +2160,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21582160
}
21592161
Res::Def(
21602162
DefKind::Enum
2161-
| DefKind::TyAlias
2163+
| DefKind::TyAlias { .. }
21622164
| DefKind::Struct
21632165
| DefKind::Union
21642166
| DefKind::ForeignTy,

Diff for: compiler/rustc_hir_analysis/src/autoderef.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
7474
// we have some type like `&<Ty as Trait>::Assoc`, since users of
7575
// autoderef expect this type to have been structurally normalized.
7676
if self.infcx.next_trait_solver()
77-
&& let ty::Alias(ty::Projection, _) = ty.kind()
77+
&& let ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _) = ty.kind()
7878
{
7979
let (normalized_ty, obligations) = self.structurally_normalize(ty)?;
8080
self.state.obligations.extend(obligations);

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
728728
check_opaque(tcx, id);
729729
}
730730
}
731-
DefKind::TyAlias => {
731+
DefKind::TyAlias { .. } => {
732732
let pty_ty = tcx.type_of(id.owner_id).instantiate_identity();
733733
let generics = tcx.generics_of(id.owner_id);
734734
check_type_params_are_used(tcx, &generics, pty_ty);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
14801480
DefKind::Struct
14811481
| DefKind::Union
14821482
| DefKind::Enum
1483-
| DefKind::TyAlias
1483+
| DefKind::TyAlias { .. }
14841484
| DefKind::Trait,
14851485
def_id,
14861486
) if depth == 0 => Some(def_id),
@@ -1990,7 +1990,7 @@ fn is_late_bound_map(
19901990

19911991
hir::TyKind::Path(hir::QPath::Resolved(
19921992
None,
1993-
hir::Path { res: Res::Def(DefKind::TyAlias, alias_def), segments, span },
1993+
hir::Path { res: Res::Def(DefKind::TyAlias { .. }, alias_def), segments, span },
19941994
)) => {
19951995
// See comments on `ConstrainedCollectorPostAstConv` for why this arm does not just consider
19961996
// args to be unconstrained.

Diff for: compiler/rustc_hir_analysis/src/variance/constraints.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ pub fn add_constraints_from_crate<'a, 'tcx>(
7878
}
7979
}
8080
DefKind::Fn | DefKind::AssocFn => constraint_cx.build_constraints_for_item(def_id),
81-
DefKind::TyAlias
82-
if tcx.features().lazy_type_alias
83-
|| tcx.type_of(def_id).instantiate_identity().has_opaque_types() =>
81+
DefKind::TyAlias { lazy }
82+
if lazy || tcx.type_of(def_id).instantiate_identity().has_opaque_types() =>
8483
{
8584
constraint_cx.build_constraints_for_item(def_id)
8685
}
@@ -111,8 +110,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
111110

112111
// The type as returned by `type_of` is the underlying type and generally not a weak projection.
113112
// Therefore we need to check the `DefKind` first.
114-
if let DefKind::TyAlias = tcx.def_kind(def_id)
115-
&& (tcx.features().lazy_type_alias || ty.has_opaque_types())
113+
if let DefKind::TyAlias { lazy } = tcx.def_kind(def_id)
114+
&& (lazy || ty.has_opaque_types())
116115
{
117116
self.add_constraints_from_ty(current_item, ty, self.covariant);
118117
return;

Diff for: compiler/rustc_hir_analysis/src/variance/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] {
5656
let crate_map = tcx.crate_variances(());
5757
return crate_map.variances.get(&item_def_id.to_def_id()).copied().unwrap_or(&[]);
5858
}
59-
DefKind::TyAlias
60-
if tcx.features().lazy_type_alias
61-
|| tcx.type_of(item_def_id).instantiate_identity().has_opaque_types() =>
59+
DefKind::TyAlias { lazy }
60+
if lazy || tcx.type_of(item_def_id).instantiate_identity().has_opaque_types() =>
6261
{
6362
// These are inferred.
6463
let crate_map = tcx.crate_variances(());

Diff for: compiler/rustc_hir_analysis/src/variance/terms.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(
9797
}
9898
}
9999
DefKind::Fn | DefKind::AssocFn => terms_cx.add_inferreds_for_item(def_id),
100-
DefKind::TyAlias
101-
if tcx.features().lazy_type_alias
102-
|| tcx.type_of(def_id).instantiate_identity().has_opaque_types() =>
100+
DefKind::TyAlias { lazy }
101+
if lazy || tcx.type_of(def_id).instantiate_identity().has_opaque_types() =>
103102
{
104103
terms_cx.add_inferreds_for_item(def_id)
105104
}

Diff for: compiler/rustc_hir_typeck/src/coercion.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10121012
cause: Option<ObligationCause<'tcx>>,
10131013
) -> RelateResult<'tcx, Ty<'tcx>> {
10141014
let source = self.try_structurally_resolve_type(expr.span, expr_ty);
1015+
let target = self.try_structurally_resolve_type(
1016+
cause.as_ref().map_or(expr.span, |cause| cause.span),
1017+
target,
1018+
);
10151019
debug!("coercion::try({:?}: {:?} -> {:?})", expr, source, target);
10161020

10171021
let cause =
@@ -1097,8 +1101,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10971101
where
10981102
E: AsCoercionSite,
10991103
{
1100-
let prev_ty = self.resolve_vars_with_obligations(prev_ty);
1101-
let new_ty = self.resolve_vars_with_obligations(new_ty);
1104+
let prev_ty = self.try_structurally_resolve_type(cause.span, prev_ty);
1105+
let new_ty = self.try_structurally_resolve_type(new.span, new_ty);
11021106
debug!(
11031107
"coercion::try_find_coercion_lub({:?}, {:?}, exprs={:?} exprs)",
11041108
prev_ty,

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14741474
let ty = self.resolve_vars_with_obligations(ty);
14751475

14761476
if self.next_trait_solver()
1477-
&& let ty::Alias(ty::Projection, _) = ty.kind()
1477+
&& let ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _) = ty.kind()
14781478
{
14791479
match self
14801480
.at(&self.misc(sp), self.param_env)

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13591359
}
13601360
_ => bug!("unexpected type: {:?}", ty.normalized),
13611361
},
1362-
Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
1362+
Res::Def(
1363+
DefKind::Struct | DefKind::Union | DefKind::TyAlias { .. } | DefKind::AssocTy,
1364+
_,
1365+
)
13631366
| Res::SelfTyParam { .. }
13641367
| Res::SelfTyAlias { .. } => match ty.normalized.ty_adt_def() {
13651368
Some(adt) if !adt.is_enum() => {

Diff for: compiler/rustc_hir_typeck/src/mem_categorization.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,10 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
557557
Ok(adt_def.variant_index_with_ctor_id(variant_ctor_id))
558558
}
559559
Res::Def(DefKind::Ctor(CtorOf::Struct, ..), _)
560-
| Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
560+
| Res::Def(
561+
DefKind::Struct | DefKind::Union | DefKind::TyAlias { .. } | DefKind::AssocTy,
562+
_,
563+
)
561564
| Res::SelfCtor(..)
562565
| Res::SelfTyParam { .. }
563566
| Res::SelfTyAlias { .. } => {

Diff for: compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
951951
//
952952
// See the `need_type_info/issue-103053.rs` test for
953953
// a example.
954-
if !matches!(path.res, Res::Def(DefKind::TyAlias, _)) => {
954+
if !matches!(path.res, Res::Def(DefKind::TyAlias { .. }, _)) => {
955955
if let Some(ty) = self.opt_node_type(expr.hir_id)
956956
&& let ty::Adt(_, args) = ty.kind()
957957
{
@@ -1080,7 +1080,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
10801080
) => {
10811081
if tcx.res_generics_def_id(path.res) != Some(def.did()) {
10821082
match path.res {
1083-
Res::Def(DefKind::TyAlias, _) => {
1083+
Res::Def(DefKind::TyAlias { .. }, _) => {
10841084
// FIXME: Ideally we should support this. For that
10851085
// we have to map back from the self type to the
10861086
// type alias though. That's difficult.

Diff for: compiler/rustc_metadata/src/rmeta/encoder.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
819819
| DefKind::Enum
820820
| DefKind::Variant
821821
| DefKind::Trait
822-
| DefKind::TyAlias
822+
| DefKind::TyAlias { .. }
823823
| DefKind::ForeignTy
824824
| DefKind::TraitAlias
825825
| DefKind::AssocTy
@@ -854,7 +854,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
854854
| DefKind::Enum
855855
| DefKind::Variant
856856
| DefKind::Trait
857-
| DefKind::TyAlias
857+
| DefKind::TyAlias { .. }
858858
| DefKind::ForeignTy
859859
| DefKind::TraitAlias
860860
| DefKind::AssocTy
@@ -895,7 +895,7 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
895895
| DefKind::Variant
896896
| DefKind::Trait
897897
| DefKind::Impl { .. } => true,
898-
DefKind::TyAlias
898+
DefKind::TyAlias { .. }
899899
| DefKind::ForeignTy
900900
| DefKind::TraitAlias
901901
| DefKind::AssocTy
@@ -930,7 +930,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
930930
| DefKind::Enum
931931
| DefKind::Variant
932932
| DefKind::Trait
933-
| DefKind::TyAlias
933+
| DefKind::TyAlias { .. }
934934
| DefKind::ForeignTy
935935
| DefKind::TraitAlias
936936
| DefKind::AssocTy
@@ -974,7 +974,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
974974
| DefKind::Const
975975
| DefKind::Fn
976976
| DefKind::ForeignMod
977-
| DefKind::TyAlias
977+
| DefKind::TyAlias { .. }
978978
| DefKind::OpaqueTy
979979
| DefKind::Enum
980980
| DefKind::Union
@@ -1067,9 +1067,8 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
10671067
| DefKind::Closure
10681068
| DefKind::Generator
10691069
| DefKind::ExternCrate => false,
1070-
DefKind::TyAlias => {
1071-
tcx.features().lazy_type_alias
1072-
|| tcx.type_of(def_id).instantiate_identity().has_opaque_types()
1070+
DefKind::TyAlias { lazy } => {
1071+
lazy || tcx.type_of(def_id).instantiate_identity().has_opaque_types()
10731072
}
10741073
}
10751074
}
@@ -1081,7 +1080,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
10811080
| DefKind::Enum
10821081
| DefKind::Variant
10831082
| DefKind::Trait
1084-
| DefKind::TyAlias
1083+
| DefKind::TyAlias { .. }
10851084
| DefKind::ForeignTy
10861085
| DefKind::TraitAlias
10871086
| DefKind::AssocTy
@@ -1121,7 +1120,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
11211120
| DefKind::Fn
11221121
| DefKind::Const
11231122
| DefKind::Static(..)
1124-
| DefKind::TyAlias
1123+
| DefKind::TyAlias { .. }
11251124
| DefKind::ForeignTy
11261125
| DefKind::Impl { .. }
11271126
| DefKind::AssocFn
@@ -1181,7 +1180,7 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
11811180
| DefKind::Const
11821181
| DefKind::Static(..)
11831182
| DefKind::Ctor(..)
1184-
| DefKind::TyAlias
1183+
| DefKind::TyAlias { .. }
11851184
| DefKind::OpaqueTy
11861185
| DefKind::ForeignTy
11871186
| DefKind::Impl { .. }
@@ -1222,7 +1221,7 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
12221221
| DefKind::AssocConst
12231222
| DefKind::AnonConst
12241223
| DefKind::Static(..)
1225-
| DefKind::TyAlias
1224+
| DefKind::TyAlias { .. }
12261225
| DefKind::OpaqueTy
12271226
| DefKind::Impl { of_trait: false }
12281227
| DefKind::ForeignTy
@@ -1255,7 +1254,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
12551254
| DefKind::Field
12561255
| DefKind::Fn
12571256
| DefKind::Static(..)
1258-
| DefKind::TyAlias
1257+
| DefKind::TyAlias { .. }
12591258
| DefKind::OpaqueTy
12601259
| DefKind::ForeignTy
12611260
| DefKind::Impl { .. }

Diff for: compiler/rustc_metadata/src/rmeta/table.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ fixed_size_enum! {
126126
( Enum )
127127
( Variant )
128128
( Trait )
129-
( TyAlias )
129+
( TyAlias { lazy: false } )
130+
( TyAlias { lazy: true } )
130131
( ForeignTy )
131132
( TraitAlias )
132133
( AssocTy )

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ impl<'hir> Map<'hir> {
196196
ItemKind::Macro(_, macro_kind) => DefKind::Macro(macro_kind),
197197
ItemKind::Mod(..) => DefKind::Mod,
198198
ItemKind::OpaqueTy(..) => DefKind::OpaqueTy,
199-
ItemKind::TyAlias(..) => DefKind::TyAlias,
199+
ItemKind::TyAlias(..) => {
200+
DefKind::TyAlias { lazy: self.tcx.features().lazy_type_alias }
201+
}
200202
ItemKind::Enum(..) => DefKind::Enum,
201203
ItemKind::Struct(..) => DefKind::Struct,
202204
ItemKind::Union(..) => DefKind::Union,

0 commit comments

Comments
 (0)