Skip to content

[beta] backports #88946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1902,10 +1902,6 @@ pub enum TyKind {
Never,
/// A tuple (`(A, B, C, D,...)`).
Tup(Vec<P<Ty>>),
/// An anonymous struct type i.e. `struct { foo: Type }`
AnonymousStruct(Vec<FieldDef>, bool),
/// An anonymous union type i.e. `union { bar: Type }`
AnonymousUnion(Vec<FieldDef>, bool),
/// A path (`module::module::...::Type`), optionally
/// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
///
3 changes: 0 additions & 3 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
@@ -484,9 +484,6 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
visit_vec(bounds, |bound| vis.visit_param_bound(bound));
}
TyKind::MacCall(mac) => vis.visit_mac_call(mac),
TyKind::AnonymousStruct(fields, ..) | TyKind::AnonymousUnion(fields, ..) => {
fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
}
}
vis.visit_span(span);
visit_lazy_tts(tokens, vis);
3 changes: 0 additions & 3 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
@@ -407,9 +407,6 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => {}
TyKind::MacCall(ref mac) => visitor.visit_mac_call(mac),
TyKind::AnonymousStruct(ref fields, ..) | TyKind::AnonymousUnion(ref fields, ..) => {
walk_list!(visitor, visit_field_def, fields)
}
TyKind::Never | TyKind::CVarArgs => {}
}
}
5 changes: 1 addition & 4 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
@@ -749,10 +749,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

pub(super) fn lower_field_def(
&mut self,
(index, f): (usize, &FieldDef),
) -> hir::FieldDef<'hir> {
fn lower_field_def(&mut self, (index, f): (usize, &FieldDef)) -> hir::FieldDef<'hir> {
let ty = if let TyKind::Path(ref qself, ref path) = f.ty.kind {
let t = self.lower_path_ty(
&f.ty,
9 changes: 0 additions & 9 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1290,15 +1290,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let kind = match t.kind {
TyKind::Infer => hir::TyKind::Infer,
TyKind::Err => hir::TyKind::Err,
// FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
TyKind::AnonymousStruct(ref _fields, _recovered) => {
self.sess.struct_span_err(t.span, "anonymous structs are unimplemented").emit();
hir::TyKind::Err
}
TyKind::AnonymousUnion(ref _fields, _recovered) => {
self.sess.struct_span_err(t.span, "anonymous unions are unimplemented").emit();
hir::TyKind::Err
}
TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)),
TyKind::Ptr(ref mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)),
TyKind::Rptr(ref region, ref mt) => {
68 changes: 0 additions & 68 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
@@ -193,19 +193,13 @@ impl<'a> AstValidator<'a> {
}
}
}
TyKind::AnonymousStruct(ref fields, ..) | TyKind::AnonymousUnion(ref fields, ..) => {
self.with_banned_assoc_ty_bound(|this| {
walk_list!(this, visit_struct_field_def, fields)
});
}
_ => visit::walk_ty(self, t),
}
}

fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
if let Some(ident) = field.ident {
if ident.name == kw::Underscore {
self.check_anonymous_field(field);
self.visit_vis(&field.vis);
self.visit_ident(ident);
self.visit_ty_common(&field.ty);
@@ -251,66 +245,6 @@ impl<'a> AstValidator<'a> {
err.emit();
}

fn check_anonymous_field(&self, field: &FieldDef) {
let FieldDef { ty, .. } = field;
match &ty.kind {
TyKind::AnonymousStruct(..) | TyKind::AnonymousUnion(..) => {
// We already checked for `kw::Underscore` before calling this function,
// so skip the check
}
TyKind::Path(..) => {
// If the anonymous field contains a Path as type, we can't determine
// if the path is a valid struct or union, so skip the check
}
_ => {
let msg = "unnamed fields can only have struct or union types";
let label = "not a struct or union";
self.err_handler()
.struct_span_err(field.span, msg)
.span_label(ty.span, label)
.emit();
}
}
}

fn deny_anonymous_struct(&self, ty: &Ty) {
match &ty.kind {
TyKind::AnonymousStruct(..) => {
self.err_handler()
.struct_span_err(
ty.span,
"anonymous structs are not allowed outside of unnamed struct or union fields",
)
.span_label(ty.span, "anonymous struct declared here")
.emit();
}
TyKind::AnonymousUnion(..) => {
self.err_handler()
.struct_span_err(
ty.span,
"anonymous unions are not allowed outside of unnamed struct or union fields",
)
.span_label(ty.span, "anonymous union declared here")
.emit();
}
_ => {}
}
}

fn deny_anonymous_field(&self, field: &FieldDef) {
if let Some(ident) = field.ident {
if ident.name == kw::Underscore {
self.err_handler()
.struct_span_err(
field.span,
"anonymous fields are not allowed outside of structs or unions",
)
.span_label(ident.span, "anonymous field declared here")
.emit()
}
}
}

fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) {
for Param { pat, .. } in &decl.inputs {
match pat.kind {
@@ -1067,7 +1001,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {

fn visit_ty(&mut self, ty: &'a Ty) {
self.visit_ty_common(ty);
self.deny_anonymous_struct(ty);
self.walk_ty(ty)
}

@@ -1082,7 +1015,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}

fn visit_field_def(&mut self, s: &'a FieldDef) {
self.deny_anonymous_field(s);
visit::walk_field_def(self, s)
}

1 change: 0 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -668,7 +668,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
// involved, so we only emit errors where there are no other parsing errors.
gate_all!(destructuring_assignment, "destructuring assignments are unstable");
}
gate_all!(unnamed_fields, "unnamed fields are not yet fully implemented");

// All uses of `gate_all!` below this point were added in #65742,
// and subsequently disabled (with the non-early gating readded).
16 changes: 6 additions & 10 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
@@ -985,14 +985,6 @@ impl<'a> State<'a> {
}
self.pclose();
}
ast::TyKind::AnonymousStruct(ref fields, ..) => {
self.head("struct");
self.print_record_struct_body(&fields, ty.span);
}
ast::TyKind::AnonymousUnion(ref fields, ..) => {
self.head("union");
self.print_record_struct_body(&fields, ty.span);
}
ast::TyKind::Paren(ref typ) => {
self.popen();
self.print_type(typ);
@@ -1413,7 +1405,12 @@ impl<'a> State<'a> {
}
}

crate fn print_record_struct_body(&mut self, fields: &[ast::FieldDef], span: rustc_span::Span) {
crate fn print_record_struct_body(
&mut self,
fields: &Vec<ast::FieldDef>,
span: rustc_span::Span,
) {
self.nbsp();
self.bopen();
self.hardbreak_if_not_bol();

@@ -1462,7 +1459,6 @@ impl<'a> State<'a> {
}
ast::VariantData::Struct(ref fields, ..) => {
self.print_where_clause(&generics.where_clause);
self.nbsp();
self.print_record_struct_body(fields, span);
}
}
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
@@ -639,9 +639,6 @@ declare_features! (
/// Allows specifying the as-needed link modifier
(active, native_link_modifiers_as_needed, "1.53.0", Some(81490), None),

/// Allows unnamed fields of struct and union type
(incomplete, unnamed_fields, "1.53.0", Some(49804), None),

/// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns.
(active, more_qualified_paths, "1.54.0", Some(86935), None),

2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let then_blk = unpack!(this.then_else_break(
block,
&this.thir[cond],
condition_scope,
Some(condition_scope),
condition_scope,
then_expr.span,
));
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self,
mut block: BasicBlock,
expr: &Expr<'tcx>,
temp_scope: region::Scope,
temp_scope_override: Option<region::Scope>,
break_scope: region::Scope,
variable_scope_span: Span,
) -> BlockAnd<()> {
@@ -53,7 +53,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.then_else_break(
block,
&this.thir[value],
temp_scope,
temp_scope_override,
break_scope,
variable_scope_span,
)
@@ -63,6 +63,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.lower_let_expr(block, &this.thir[expr], pat, break_scope, variable_scope_span)
}
_ => {
let temp_scope = temp_scope_override.unwrap_or_else(|| this.local_scope());
let mutability = Mutability::Mut;
let place =
unpack!(block = this.as_temp(block, Some(temp_scope), expr, mutability));
@@ -1948,7 +1949,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

let arm_span = arm_span.unwrap();
let arm_scope = self.local_scope();
let match_scope = match_scope.unwrap();
let mut guard_span = rustc_span::DUMMY_SP;

@@ -1957,7 +1957,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Guard::If(e) => {
let e = &this.thir[e];
guard_span = e.span;
this.then_else_break(block, e, arm_scope, match_scope, arm_span)
this.then_else_break(block, e, None, match_scope, arm_span)
}
Guard::IfLet(ref pat, scrutinee) => {
let s = &this.thir[scrutinee];
38 changes: 16 additions & 22 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
@@ -1234,7 +1234,7 @@ impl<'a> Parser<'a> {
Ok((class_name, ItemKind::Union(vdata, generics)))
}

pub(super) fn parse_record_struct_body(
fn parse_record_struct_body(
&mut self,
adt_ty: &str,
) -> PResult<'a, (Vec<FieldDef>, /* recovered */ bool)> {
@@ -1468,28 +1468,22 @@ impl<'a> Parser<'a> {
fn parse_field_ident(&mut self, adt_ty: &str, lo: Span) -> PResult<'a, Ident> {
let (ident, is_raw) = self.ident_or_err()?;
if !is_raw && ident.is_reserved() {
if ident.name == kw::Underscore {
self.sess.gated_spans.gate(sym::unnamed_fields, lo);
let err = if self.check_fn_front_matter(false) {
// We use `parse_fn` to get a span for the function
if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
db.delay_as_bug();
}
let mut err = self.struct_span_err(
lo.to(self.prev_token.span),
&format!("functions are not allowed in {} definitions", adt_ty),
);
err.help("unlike in C++, Java, and C#, functions are declared in `impl` blocks");
err.help("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information");
err
} else {
let err = if self.check_fn_front_matter(false) {
// We use `parse_fn` to get a span for the function
if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
db.delay_as_bug();
}
let mut err = self.struct_span_err(
lo.to(self.prev_token.span),
&format!("functions are not allowed in {} definitions", adt_ty),
);
err.help(
"unlike in C++, Java, and C#, functions are declared in `impl` blocks",
);
err.help("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information");
err
} else {
self.expected_ident_found()
};
return Err(err);
}
self.expected_ident_found()
};
return Err(err);
}
self.bump();
Ok(ident)
13 changes: 0 additions & 13 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
@@ -226,19 +226,6 @@ impl<'a> Parser<'a> {
}
} else if self.eat_keyword(kw::Impl) {
self.parse_impl_ty(&mut impl_dyn_multi)?
} else if self.token.is_keyword(kw::Union)
&& self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace))
{
self.bump();
let (fields, recovered) = self.parse_record_struct_body("union")?;
let span = lo.to(self.prev_token.span);
self.sess.gated_spans.gate(sym::unnamed_fields, span);
TyKind::AnonymousUnion(fields, recovered)
} else if self.eat_keyword(kw::Struct) {
let (fields, recovered) = self.parse_record_struct_body("struct")?;
let span = lo.to(self.prev_token.span);
self.sess.gated_spans.gate(sym::unnamed_fields, span);
TyKind::AnonymousStruct(fields, recovered)
} else if self.is_explicit_dyn_type() {
self.parse_dyn_ty(&mut impl_dyn_multi)?
} else if self.eat_lt() {
1 change: 0 additions & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
@@ -1358,7 +1358,6 @@ symbols! {
unix,
unlikely,
unmarked_api,
unnamed_fields,
unpin,
unreachable,
unreachable_code,
8 changes: 4 additions & 4 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
@@ -945,7 +945,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ok(s) if s.starts_with('<') => sugg,
_ => format!("<{}>", sugg),
};
let replace = String::from("use `dyn`");
let sugg_label = "use `dyn`";
if self.sess().edition() >= Edition::Edition2021 {
let mut err = rustc_errors::struct_span_err!(
self.sess(),
@@ -956,8 +956,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
err.span_suggestion(
self_ty.span,
&sugg,
replace,
sugg_label,
sugg,
Applicability::MachineApplicable,
)
.emit();
@@ -968,7 +968,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self_ty.span,
|lint| {
let mut db = lint.build(msg);
db.span_suggestion(self_ty.span, &replace, sugg, app);
db.span_suggestion(self_ty.span, sugg_label, sugg, app);
db.emit()
},
);
63 changes: 39 additions & 24 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
@@ -254,6 +254,10 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl

debug!("{:?}", indices);
let mut curty = None;
// See: https://github.com/rust-lang/rust/issues/88545
let item_table_block_size = 900usize;
let mut item_table_nth_element = 0usize;

for &idx in &indices {
let myitem = &items[idx];
if myitem.is_stripped() {
@@ -278,6 +282,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
id = cx.derive_id(short.to_owned()),
name = name
);
item_table_nth_element = 0;
}

match *myitem.kind {
@@ -384,6 +389,13 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
);
}
}

item_table_nth_element += 1;
if item_table_nth_element > item_table_block_size {
w.write_str(ITEM_TABLE_CLOSE);
w.write_str(ITEM_TABLE_OPEN);
item_table_nth_element = 0;
}
}

if curty.is_some() {
@@ -942,15 +954,15 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
}

fn print_tuple_struct_fields(w: &mut Buffer, cx: &Context<'_>, s: &[clean::Item]) {
for (i, ty) in s
.iter()
.map(|f| if let clean::StructFieldItem(ref ty) = *f.kind { ty } else { unreachable!() })
.enumerate()
{
for (i, ty) in s.iter().enumerate() {
if i > 0 {
w.write_str(",&nbsp;");
}
write!(w, "{}", ty.print(cx));
match *ty.kind {
clean::StrippedItem(box clean::StructFieldItem(_)) => w.write_str("_"),
clean::StructFieldItem(ref ty) => write!(w, "{}", ty.print(cx)),
_ => unreachable!(),
}
}
}

@@ -1066,24 +1078,27 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
name = variant.name.as_ref().unwrap(),
);
for field in fields {
use crate::clean::StructFieldItem;
if let StructFieldItem(ref ty) = *field.kind {
let id = cx.derive_id(format!(
"variant.{}.field.{}",
variant.name.as_ref().unwrap(),
field.name.as_ref().unwrap()
));
write!(
w,
"<span id=\"{id}\" class=\"variant small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<code>{f}:&nbsp;{t}</code>\
</span>",
id = id,
f = field.name.as_ref().unwrap(),
t = ty.print(cx)
);
document(w, cx, field, Some(variant));
match *field.kind {
clean::StrippedItem(box clean::StructFieldItem(_)) => {}
clean::StructFieldItem(ref ty) => {
let id = cx.derive_id(format!(
"variant.{}.field.{}",
variant.name.as_ref().unwrap(),
field.name.as_ref().unwrap()
));
write!(
w,
"<span id=\"{id}\" class=\"variant small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<code>{f}:&nbsp;{t}</code>\
</span>",
id = id,
f = field.name.as_ref().unwrap(),
t = ty.print(cx)
);
document(w, cx, field, Some(variant));
}
_ => unreachable!(),
}
}
w.write_str("</div></div>");
2 changes: 1 addition & 1 deletion src/stage0.txt
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ rustc: 1.55.0
# bootstrapping issues with use of new syntax in this repo. If you're looking at
# the beta/stable branch, this key should be omitted, as we don't want to depend
# on rustfmt from nightly there.
rustfmt: nightly-2021-03-25
#rustfmt: nightly-2021-03-25

# When making a stable release the process currently looks like:
#
2 changes: 2 additions & 0 deletions src/test/debuginfo/mutex.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
// cdb-only
// min-cdb-version: 10.0.21287.1005
// compile-flags:-g
// FIXME: Failed on update to 10.0.22000.1
// ignore-windows

// === CDB TESTS ==================================================================================
//
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@
+ bb6: {
_0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60
StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- goto -> bb23; // scope 0 at no-location
+ goto -> bb20; // scope 0 at no-location
}
@@ -108,6 +108,7 @@
- bb11: {
+ bb8: {
StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
@@ -123,7 +124,7 @@
- bb12: {
+ bb9: {
StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
- falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
@@ -149,7 +150,7 @@
+ bb11: {
_0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60
StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- goto -> bb23; // scope 0 at no-location
+ goto -> bb20; // scope 0 at no-location
}
@@ -164,6 +165,7 @@
- bb16: {
+ bb13: {
StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
@@ -179,7 +181,7 @@
- bb17: {
+ bb14: {
StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
- falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
@@ -190,7 +192,6 @@
+ bb15: {
StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
- goto -> bb22; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@ fn full_tested_match() -> () {
}

bb7: {
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:26: 16:27
FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:16:26: 16:27
FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:16:26: 16:27
StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
@@ -81,13 +82,12 @@ fn full_tested_match() -> () {
_1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:16:31: 16:37
StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:16:36: 16:37
StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37
}

bb8: {
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:26: 16:27
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37
goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:16:20: 16:27
}
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ fn full_tested_match2() -> () {
}

bb7: {
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:26: 27:27
FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:27:26: 27:27
FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:27:26: 27:27
StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
@@ -79,13 +80,12 @@ fn full_tested_match2() -> () {
_1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:27:31: 27:37
StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:27:36: 27:37
StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37
}

bb8: {
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:26: 27:27
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37
falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:27:20: 27:27
}
Original file line number Diff line number Diff line change
@@ -78,19 +78,19 @@ fn main() -> () {
}

bb7: {
StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:27: 36:28
FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:36:27: 36:28
FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:36:27: 36:28
StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
_6 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
_1 = const 1_i32; // scope 2 at $DIR/match_false_edges.rs:36:32: 36:33
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33
StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33
goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33
}

bb8: {
StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33
StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:27: 36:28
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33
falseEdge -> [real: bb1, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:36:21: 36:28
}
@@ -122,20 +122,20 @@ fn main() -> () {

bb12: {
StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
FakeRead(ForGuardBinding, _11); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
StorageLive(_10); // scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
_10 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
_1 = const 3_i32; // scope 4 at $DIR/match_false_edges.rs:38:33: 38:34
StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34
StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34
StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34
goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34
}

bb13: {
StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34
StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34
falseEdge -> [real: bb3, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:38:20: 38:29
}
Original file line number Diff line number Diff line change
@@ -75,14 +75,14 @@ fn main() -> () {
}

bb10: {
StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:18: 13:19
FakeRead(ForMatchGuard, _8); // scope 2 at $DIR/match_test.rs:13:18: 13:19
_3 = const 0_i32; // scope 2 at $DIR/match_test.rs:13:23: 13:24
StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:23: 13:24
goto -> bb14; // scope 2 at $DIR/match_test.rs:13:23: 13:24
}

bb11: {
StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:23: 13:24
StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:18: 13:19
falseEdge -> [real: bb3, imaginary: bb6]; // scope 2 at $DIR/match_test.rs:13:18: 13:19
}

Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@
+ _7 = move _2; // scope 0 at $DIR/matches_reduce_branches.rs:41:18: 41:76
StorageDead(_2); // scope 0 at $DIR/matches_reduce_branches.rs:45:9: 45:10
- _1 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:47:13: 47:17
- goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:48:9: 48:10
- goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:47:13: 47:17
- }
-
- bb8: {
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@
+ _7 = move _2; // scope 0 at $DIR/matches_reduce_branches.rs:41:18: 41:76
StorageDead(_2); // scope 0 at $DIR/matches_reduce_branches.rs:45:9: 45:10
- _1 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:47:13: 47:17
- goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:48:9: 48:10
- goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:47:13: 47:17
- }
-
- bb8: {
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@
}

bb5: {
StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
- FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
- FakeRead(ForMatchGuard, _6); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
@@ -56,12 +57,11 @@
+ nop; // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+ nop; // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
_0 = const 0_i32; // scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26
StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26
goto -> bb7; // scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26
}

bb6: {
StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26
StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
goto -> bb1; // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
}

24 changes: 0 additions & 24 deletions src/test/pretty/anonymous-types.rs

This file was deleted.

34 changes: 34 additions & 0 deletions src/test/rustdoc/issue-88600.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This test ensure that #[doc(hidden)] is applied correctly in enum variant fields.

// Denotes a field which should be hidden.
pub struct H;

// Denotes a field which should not be hidden (shown).
pub struct S;

// @has issue_88600/enum.FooEnum.html
pub enum FooEnum {
// @has - '//*[@id="variant.HiddenTupleItem"]//code' 'HiddenTupleItem(_)'
// @count - '//*[@id="variant.HiddenTupleItem.field.0"]' 0
HiddenTupleItem(#[doc(hidden)] H),
// @has - '//*[@id="variant.MultipleHidden"]//code' 'MultipleHidden(_, _)'
// @count - '//*[@id="variant.MultipleHidden.field.0"]' 0
// @count - '//*[@id="variant.MultipleHidden.field.1"]' 0
MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H),
// @has - '//*[@id="variant.MixedHiddenFirst"]//code' 'MixedHiddenFirst(_, S)'
// @count - '//*[@id="variant.MixedHiddenFirst.field.0"]' 0
// @has - '//*[@id="variant.MixedHiddenFirst.field.1"]' '1: S'
MixedHiddenFirst(#[doc(hidden)] H, S),
// @has - '//*[@id="variant.MixedHiddenLast"]//code' 'MixedHiddenLast(S, _)'
// @has - '//*[@id="variant.MixedHiddenLast.field.0"]' '0: S'
// @count - '//*[@id="variant.MixedHiddenLast.field.1"]' 0
MixedHiddenLast(S, #[doc(hidden)] H),
// @has - '//*[@id="variant.HiddenStruct"]//code' 'HiddenStruct'
// @count - '//*[@id="variant.HiddenStruct.field.h"]' 0
// @has - '//*[@id="variant.HiddenStruct.field.s"]' 's: S'
HiddenStruct {
#[doc(hidden)]
h: H,
s: S,
},
}
18 changes: 18 additions & 0 deletions src/test/ui/consts/issue-88649.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// check-pass
#![crate_type = "lib"]

enum Foo {
Variant1(bool),
Variant2(bool),
}

const _: () = {
let mut n = 0;
while n < 2 {
match Foo::Variant1(true) {
Foo::Variant1(x) | Foo::Variant2(x) if x => {}
_ => {}
}
n += 1;
}
};
12 changes: 12 additions & 0 deletions src/test/ui/editions/dyn-trait-sugg-2021.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// edition:2021

trait Foo<T> {}

impl<T> dyn Foo<T> {
fn hi(_x: T) {}
}

fn main() {
Foo::hi(123);
//~^ ERROR trait objects without an explicit `dyn` are deprecated
}
9 changes: 9 additions & 0 deletions src/test/ui/editions/dyn-trait-sugg-2021.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0783]: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-trait-sugg-2021.rs:10:5
|
LL | Foo::hi(123);
| ^^^ help: use `dyn`: `<dyn Foo>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0783`.
27 changes: 0 additions & 27 deletions src/test/ui/feature-gates/feature-gate-unnamed_fields.rs

This file was deleted.

111 changes: 0 additions & 111 deletions src/test/ui/feature-gates/feature-gate-unnamed_fields.stderr

This file was deleted.

15 changes: 15 additions & 0 deletions src/test/ui/parser/issue-88583-union-as-ident.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// check-pass

#![allow(non_camel_case_types)]

struct union;

impl union {
pub fn new() -> Self {
union { }
}
}

fn main() {
let _u = union::new();
}
52 changes: 0 additions & 52 deletions src/test/ui/unnamed_fields/restrict_anonymous.rs

This file was deleted.

175 changes: 0 additions & 175 deletions src/test/ui/unnamed_fields/restrict_anonymous.stderr

This file was deleted.

8 changes: 7 additions & 1 deletion src/tools/publish_toolstate.py
Original file line number Diff line number Diff line change
@@ -299,7 +299,13 @@ def update_latest(
if repo:
github_token = os.environ.get('TOOLSTATE_REPO_ACCESS_TOKEN')
if github_token:
validate_maintainers(repo, github_token)
# FIXME: This is currently broken. Starting on 2021-09-15, GitHub
# seems to have changed it so that to list the collaborators
# requires admin permissions. I think this will probably just need
# to be removed since we are probably not going to use an admin
# token, and I don't see another way to do this.
print('maintainer validation disabled')
# validate_maintainers(repo, github_token)
else:
print('skipping toolstate maintainers validation since no GitHub token is present')
# When validating maintainers don't run the full script.
11 changes: 8 additions & 3 deletions src/tools/rustfmt/src/items.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ use std::cmp::{max, min, Ordering};
use regex::Regex;
use rustc_ast::visit;
use rustc_ast::{ast, ptr};
use rustc_span::{symbol, BytePos, Span};
use rustc_span::{symbol, BytePos, Span, DUMMY_SP};

use crate::attr::filter_inline_attrs;
use crate::comment::{
@@ -31,7 +31,12 @@ use crate::stmt::Stmt;
use crate::utils::*;
use crate::vertical::rewrite_with_alignment;
use crate::visitor::FmtVisitor;
use crate::DEFAULT_VISIBILITY;

const DEFAULT_VISIBILITY: ast::Visibility = ast::Visibility {
kind: ast::VisibilityKind::Inherited,
span: DUMMY_SP,
tokens: None,
};

fn type_annotation_separator(config: &Config) -> &str {
colon_spaces(config)
@@ -972,7 +977,7 @@ impl<'a> StructParts<'a> {
format_header(context, self.prefix, self.ident, self.vis, offset)
}

pub(crate) fn from_variant(variant: &'a ast::Variant) -> Self {
fn from_variant(variant: &'a ast::Variant) -> Self {
StructParts {
prefix: "",
ident: variant.ident,
7 changes: 1 addition & 6 deletions src/tools/rustfmt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ use std::path::PathBuf;
use std::rc::Rc;

use rustc_ast::ast;
use rustc_span::{symbol, DUMMY_SP};
use rustc_span::symbol;
use thiserror::Error;

use crate::comment::LineClasses;
@@ -96,11 +96,6 @@ mod types;
mod vertical;
pub(crate) mod visitor;

const DEFAULT_VISIBILITY: ast::Visibility = ast::Visibility {
kind: ast::VisibilityKind::Inherited,
span: DUMMY_SP,
tokens: None,
};
/// The various errors that can occur during formatting. Note that not all of
/// these can currently be propagated to clients.
#[derive(Error, Debug)]
59 changes: 3 additions & 56 deletions src/tools/rustfmt/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use std::iter::ExactSizeIterator;
use std::ops::Deref;

use rustc_ast::ast::{self, AttrVec, FnRetTy, Mutability};
use rustc_span::{symbol::kw, symbol::Ident, BytePos, Pos, Span};
use rustc_ast::ast::{self, FnRetTy, Mutability};
use rustc_span::{symbol::kw, BytePos, Pos, Span};

use crate::comment::{combine_strs_with_missing_comments, contains_comment};
use crate::config::lists::*;
use crate::config::{IndentStyle, TypeDensity, Version};
use crate::expr::{
format_expr, rewrite_assign_rhs, rewrite_call, rewrite_tuple, rewrite_unary_prefix, ExprType,
};
use crate::items::StructParts;
use crate::lists::{
definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator,
};
@@ -24,11 +24,6 @@ use crate::utils::{
colon_spaces, extra_offset, first_line_width, format_extern, format_mutability,
last_line_extendable, last_line_width, mk_sp, rewrite_ident,
};
use crate::DEFAULT_VISIBILITY;
use crate::{
comment::{combine_strs_with_missing_comments, contains_comment},
items::format_struct_struct,
};

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub(crate) enum PathContext {
@@ -769,54 +764,6 @@ impl Rewrite for ast::Ty {
ast::TyKind::Tup(ref items) => {
rewrite_tuple(context, items.iter(), self.span, shape, items.len() == 1)
}
ast::TyKind::AnonymousStruct(ref fields, recovered) => {
let ident = Ident::new(
kw::Struct,
mk_sp(self.span.lo(), self.span.lo() + BytePos(6)),
);
let data = ast::VariantData::Struct(fields.clone(), recovered);
let variant = ast::Variant {
attrs: AttrVec::new(),
id: self.id,
span: self.span,
vis: DEFAULT_VISIBILITY,
ident,
data,
disr_expr: None,
is_placeholder: false,
};
format_struct_struct(
&context,
&StructParts::from_variant(&variant),
fields,
shape.indent,
None,
)
}
ast::TyKind::AnonymousUnion(ref fields, recovered) => {
let ident = Ident::new(
kw::Union,
mk_sp(self.span.lo(), self.span.lo() + BytePos(5)),
);
let data = ast::VariantData::Struct(fields.clone(), recovered);
let variant = ast::Variant {
attrs: AttrVec::new(),
id: self.id,
span: self.span,
vis: DEFAULT_VISIBILITY,
ident,
data,
disr_expr: None,
is_placeholder: false,
};
format_struct_struct(
&context,
&StructParts::from_variant(&variant),
fields,
shape.indent,
None,
)
}
ast::TyKind::Path(ref q_self, ref path) => {
rewrite_path(context, PathContext::Type, q_self.as_ref(), path, shape)
}