Skip to content

Commit 7e5b9e2

Browse files
committed
Auto merge of rust-lang#3606 - RalfJung:rustup, r=RalfJung
Rustup, aligned heap-allocations on wasm Pulls in rust-lang#125003 so allocation tests should now work on wasm.
2 parents d0b2c66 + 6d314f3 commit 7e5b9e2

File tree

149 files changed

+2404
-1095
lines changed

Some content is hidden

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

149 files changed

+2404
-1095
lines changed

compiler/rustc_ast/src/ast.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -2961,6 +2961,7 @@ impl Item {
29612961
| ItemKind::GlobalAsm(_)
29622962
| ItemKind::MacCall(_)
29632963
| ItemKind::Delegation(_)
2964+
| ItemKind::DelegationMac(_)
29642965
| ItemKind::MacroDef(_) => None,
29652966
ItemKind::Static(_) => None,
29662967
ItemKind::Const(i) => Some(&i.generics),
@@ -3123,8 +3124,16 @@ pub struct Delegation {
31233124
/// Path resolution id.
31243125
pub id: NodeId,
31253126
pub qself: Option<P<QSelf>>,
3126-
pub rename: Option<Ident>,
31273127
pub path: Path,
3128+
pub rename: Option<Ident>,
3129+
pub body: Option<P<Block>>,
3130+
}
3131+
3132+
#[derive(Clone, Encodable, Decodable, Debug)]
3133+
pub struct DelegationMac {
3134+
pub qself: Option<P<QSelf>>,
3135+
pub prefix: Path,
3136+
pub suffixes: ThinVec<(Ident, Option<Ident>)>,
31283137
pub body: Option<P<Block>>,
31293138
}
31303139

@@ -3243,10 +3252,13 @@ pub enum ItemKind {
32433252
/// A macro definition.
32443253
MacroDef(MacroDef),
32453254

3246-
/// A delegation item (`reuse`).
3255+
/// A single delegation item (`reuse`).
32473256
///
32483257
/// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
32493258
Delegation(Box<Delegation>),
3259+
/// A list delegation item (`reuse prefix::{a, b, c}`).
3260+
/// Treated similarly to a macro call and expanded early.
3261+
DelegationMac(Box<DelegationMac>),
32503262
}
32513263

32523264
impl ItemKind {
@@ -3256,7 +3268,7 @@ impl ItemKind {
32563268
match self {
32573269
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
32583270
| Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..)
3259-
| Delegation(..) => "a",
3271+
| Delegation(..) | DelegationMac(..) => "a",
32603272
ExternCrate(..) | ForeignMod(..) | MacCall(..) | Enum(..) | Impl { .. } => "an",
32613273
}
32623274
}
@@ -3281,6 +3293,7 @@ impl ItemKind {
32813293
ItemKind::MacroDef(..) => "macro definition",
32823294
ItemKind::Impl { .. } => "implementation",
32833295
ItemKind::Delegation(..) => "delegated function",
3296+
ItemKind::DelegationMac(..) => "delegation",
32843297
}
32853298
}
32863299

@@ -3324,6 +3337,8 @@ pub enum AssocItemKind {
33243337
MacCall(P<MacCall>),
33253338
/// An associated delegation item.
33263339
Delegation(Box<Delegation>),
3340+
/// An associated delegation item list.
3341+
DelegationMac(Box<DelegationMac>),
33273342
}
33283343

33293344
impl AssocItemKind {
@@ -3332,7 +3347,9 @@ impl AssocItemKind {
33323347
Self::Const(box ConstItem { defaultness, .. })
33333348
| Self::Fn(box Fn { defaultness, .. })
33343349
| Self::Type(box TyAlias { defaultness, .. }) => defaultness,
3335-
Self::MacCall(..) | Self::Delegation(..) => Defaultness::Final,
3350+
Self::MacCall(..) | Self::Delegation(..) | Self::DelegationMac(..) => {
3351+
Defaultness::Final
3352+
}
33363353
}
33373354
}
33383355
}
@@ -3345,6 +3362,7 @@ impl From<AssocItemKind> for ItemKind {
33453362
AssocItemKind::Type(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
33463363
AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
33473364
AssocItemKind::Delegation(delegation) => ItemKind::Delegation(delegation),
3365+
AssocItemKind::DelegationMac(delegation) => ItemKind::DelegationMac(delegation),
33483366
}
33493367
}
33503368
}
@@ -3359,6 +3377,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
33593377
ItemKind::TyAlias(ty_kind) => AssocItemKind::Type(ty_kind),
33603378
ItemKind::MacCall(a) => AssocItemKind::MacCall(a),
33613379
ItemKind::Delegation(d) => AssocItemKind::Delegation(d),
3380+
ItemKind::DelegationMac(d) => AssocItemKind::DelegationMac(d),
33623381
_ => return Err(item_kind),
33633382
})
33643383
}

compiler/rustc_ast/src/mut_visit.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,19 @@ impl NoopVisitItemKind for ItemKind {
11701170
vis.visit_block(body);
11711171
}
11721172
}
1173+
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
1174+
vis.visit_qself(qself);
1175+
vis.visit_path(prefix);
1176+
for (ident, rename) in suffixes {
1177+
vis.visit_ident(ident);
1178+
if let Some(rename) = rename {
1179+
vis.visit_ident(rename);
1180+
}
1181+
}
1182+
if let Some(body) = body {
1183+
vis.visit_block(body);
1184+
}
1185+
}
11731186
}
11741187
}
11751188
}
@@ -1213,6 +1226,19 @@ impl NoopVisitItemKind for AssocItemKind {
12131226
visitor.visit_block(body);
12141227
}
12151228
}
1229+
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
1230+
visitor.visit_qself(qself);
1231+
visitor.visit_path(prefix);
1232+
for (ident, rename) in suffixes {
1233+
visitor.visit_ident(ident);
1234+
if let Some(rename) = rename {
1235+
visitor.visit_ident(rename);
1236+
}
1237+
}
1238+
if let Some(body) = body {
1239+
visitor.visit_block(body);
1240+
}
1241+
}
12161242
}
12171243
}
12181244
}

compiler/rustc_ast/src/visit.rs

+26
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,19 @@ impl WalkItemKind for ItemKind {
403403
visit_opt!(visitor, visit_ident, *rename);
404404
visit_opt!(visitor, visit_block, body);
405405
}
406+
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
407+
if let Some(qself) = qself {
408+
try_visit!(visitor.visit_ty(&qself.ty));
409+
}
410+
try_visit!(visitor.visit_path(prefix, item.id));
411+
for (ident, rename) in suffixes {
412+
visitor.visit_ident(*ident);
413+
if let Some(rename) = rename {
414+
visitor.visit_ident(*rename);
415+
}
416+
}
417+
visit_opt!(visitor, visit_block, body);
418+
}
406419
}
407420
V::Result::output()
408421
}
@@ -815,6 +828,19 @@ impl WalkItemKind for AssocItemKind {
815828
visit_opt!(visitor, visit_ident, *rename);
816829
visit_opt!(visitor, visit_block, body);
817830
}
831+
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
832+
if let Some(qself) = qself {
833+
try_visit!(visitor.visit_ty(&qself.ty));
834+
}
835+
try_visit!(visitor.visit_path(prefix, item.id));
836+
for (ident, rename) in suffixes {
837+
visitor.visit_ident(*ident);
838+
if let Some(rename) = rename {
839+
visitor.visit_ident(*rename);
840+
}
841+
}
842+
visit_opt!(visitor, visit_block, body);
843+
}
818844
}
819845
V::Result::output()
820846
}

compiler/rustc_ast_lowering/src/item.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
460460
delegation_results.body_id,
461461
)
462462
}
463-
ItemKind::MacCall(..) => {
464-
panic!("`TyMac` should have been expanded by now")
463+
ItemKind::MacCall(..) | ItemKind::DelegationMac(..) => {
464+
panic!("macros should have been expanded by now")
465465
}
466466
}
467467
}
@@ -845,7 +845,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
845845
);
846846
(delegation_results.generics, item_kind, true)
847847
}
848-
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
848+
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
849+
panic!("macros should have been expanded by now")
850+
}
849851
};
850852

851853
let item = hir::TraitItem {
@@ -869,7 +871,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
869871
AssocItemKind::Delegation(box delegation) => hir::AssocItemKind::Fn {
870872
has_self: self.delegation_has_self(i.id, delegation.id, i.span),
871873
},
872-
AssocItemKind::MacCall(..) => unimplemented!(),
874+
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
875+
panic!("macros should have been expanded by now")
876+
}
873877
};
874878
let id = hir::TraitItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
875879
hir::TraitItemRef {
@@ -964,7 +968,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
964968
hir::ImplItemKind::Fn(delegation_results.sig, delegation_results.body_id),
965969
)
966970
}
967-
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
971+
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
972+
panic!("macros should have been expanded by now")
973+
}
968974
};
969975

970976
let item = hir::ImplItem {
@@ -993,7 +999,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
993999
AssocItemKind::Delegation(box delegation) => hir::AssocItemKind::Fn {
9941000
has_self: self.delegation_has_self(i.id, delegation.id, i.span),
9951001
},
996-
AssocItemKind::MacCall(..) => unimplemented!(),
1002+
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
1003+
panic!("macros should have been expanded by now")
1004+
}
9971005
},
9981006
trait_item_def_id: self
9991007
.resolver

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+60-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
55
use ast::StaticItem;
66
use itertools::{Itertools, Position};
77
use rustc_ast as ast;
8+
use rustc_ast::ptr::P;
89
use rustc_ast::ModKind;
910
use rustc_span::symbol::Ident;
1011

@@ -374,9 +375,22 @@ impl<'a> State<'a> {
374375
state.print_visibility(&item.vis)
375376
});
376377
}
377-
ast::ItemKind::Delegation(box delegation) => {
378-
self.print_delegation(delegation, &item.vis, &item.attrs)
379-
}
378+
ast::ItemKind::Delegation(deleg) => self.print_delegation(
379+
&item.attrs,
380+
&item.vis,
381+
&deleg.qself,
382+
&deleg.path,
383+
None,
384+
&deleg.body,
385+
),
386+
ast::ItemKind::DelegationMac(deleg) => self.print_delegation(
387+
&item.attrs,
388+
&item.vis,
389+
&deleg.qself,
390+
&deleg.prefix,
391+
Some(&deleg.suffixes),
392+
&deleg.body,
393+
),
380394
}
381395
self.ann.post(self, AnnNode::Item(item))
382396
}
@@ -553,31 +567,63 @@ impl<'a> State<'a> {
553567
self.word(";");
554568
}
555569
}
556-
ast::AssocItemKind::Delegation(box delegation) => {
557-
self.print_delegation(delegation, vis, &item.attrs)
558-
}
570+
ast::AssocItemKind::Delegation(deleg) => self.print_delegation(
571+
&item.attrs,
572+
vis,
573+
&deleg.qself,
574+
&deleg.path,
575+
None,
576+
&deleg.body,
577+
),
578+
ast::AssocItemKind::DelegationMac(deleg) => self.print_delegation(
579+
&item.attrs,
580+
vis,
581+
&deleg.qself,
582+
&deleg.prefix,
583+
Some(&deleg.suffixes),
584+
&deleg.body,
585+
),
559586
}
560587
self.ann.post(self, AnnNode::SubItem(id))
561588
}
562589

563590
pub(crate) fn print_delegation(
564591
&mut self,
565-
delegation: &ast::Delegation,
566-
vis: &ast::Visibility,
567592
attrs: &[ast::Attribute],
593+
vis: &ast::Visibility,
594+
qself: &Option<P<ast::QSelf>>,
595+
path: &ast::Path,
596+
suffixes: Option<&[(Ident, Option<Ident>)]>,
597+
body: &Option<P<ast::Block>>,
568598
) {
569-
if delegation.body.is_some() {
599+
if body.is_some() {
570600
self.head("");
571601
}
572602
self.print_visibility(vis);
573-
self.word_space("reuse");
603+
self.word_nbsp("reuse");
574604

575-
if let Some(qself) = &delegation.qself {
576-
self.print_qpath(&delegation.path, qself, false);
605+
if let Some(qself) = qself {
606+
self.print_qpath(path, qself, false);
577607
} else {
578-
self.print_path(&delegation.path, false, 0);
608+
self.print_path(path, false, 0);
609+
}
610+
if let Some(suffixes) = suffixes {
611+
self.word("::");
612+
self.word("{");
613+
for (i, (ident, rename)) in suffixes.iter().enumerate() {
614+
self.print_ident(*ident);
615+
if let Some(rename) = rename {
616+
self.nbsp();
617+
self.word_nbsp("as");
618+
self.print_ident(*rename);
619+
}
620+
if i != suffixes.len() - 1 {
621+
self.word_space(",");
622+
}
623+
}
624+
self.word("}");
579625
}
580-
if let Some(body) = &delegation.body {
626+
if let Some(body) = body {
581627
self.nbsp();
582628
self.print_block_with_attrs(body, attrs);
583629
} else {

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,8 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
207207
let cond_bitmap = coverage_context
208208
.try_get_mcdc_condition_bitmap(&instance, decision_depth)
209209
.expect("mcdc cond bitmap should have been allocated for merging into the global bitmap");
210-
let bitmap_bytes = bx.tcx().coverage_ids_info(instance.def).mcdc_bitmap_bytes;
210+
let bitmap_bytes = function_coverage_info.mcdc_bitmap_bytes;
211211
assert!(bitmap_idx < bitmap_bytes, "bitmap index of the decision out of range");
212-
assert!(
213-
bitmap_bytes <= function_coverage_info.mcdc_bitmap_bytes,
214-
"bitmap length disagreement: query says {bitmap_bytes} but function info only has {}",
215-
function_coverage_info.mcdc_bitmap_bytes
216-
);
217212

218213
let fn_name = bx.get_pgo_func_name_var(instance);
219214
let hash = bx.const_u64(function_coverage_info.function_source_hash);

compiler/rustc_errors/src/diagnostic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
896896
style: SuggestionStyle,
897897
) -> &mut Self {
898898
suggestion.sort_unstable();
899-
suggestion.dedup();
899+
suggestion.dedup_by(|(s1, m1), (s2, m2)| s1.source_equal(*s2) && m1 == m2);
900900

901901
let parts = suggestion
902902
.into_iter()

compiler/rustc_errors/src/diagnostic_impls.rs

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ impl<I: rustc_type_ir::Interner> IntoDiagArg for rustc_type_ir::ExistentialTrait
106106
}
107107
}
108108

109+
impl<I: rustc_type_ir::Interner> IntoDiagArg for rustc_type_ir::UnevaluatedConst<I> {
110+
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
111+
format!("{self:?}").into_diag_arg()
112+
}
113+
}
114+
109115
into_diag_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
110116

111117
impl IntoDiagArg for bool {

compiler/rustc_expand/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ expand_duplicate_matcher_binding = duplicate matcher binding
3030
.label = duplicate binding
3131
.label2 = previous binding
3232
33+
expand_empty_delegation_list =
34+
empty list delegation is not supported
35+
3336
expand_expected_paren_or_brace =
3437
expected `(` or `{"{"}`, found `{$token}`
3538

compiler/rustc_expand/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,10 @@ pub struct ExpectedParenOrBrace<'a> {
433433
pub span: Span,
434434
pub token: Cow<'a, str>,
435435
}
436+
437+
#[derive(Diagnostic)]
438+
#[diag(expand_empty_delegation_list)]
439+
pub(crate) struct EmptyDelegationList {
440+
#[primary_span]
441+
pub span: Span,
442+
}

0 commit comments

Comments
 (0)