From f5cd6b3e9bbe1f020e1784af3227e8d5a9ca7e8f Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 28 Jul 2022 13:12:32 -0700 Subject: [PATCH 01/10] rustdoc: align invalid-html-tags lint with commonmark spec --- src/librustdoc/passes/html_tags.rs | 10 +++++++++- src/test/rustdoc-ui/invalid-html-tags.rs | 6 ++++++ src/test/rustdoc-ui/invalid-html-tags.stderr | 14 +++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index d8ad299c3d3..d65e076b818 100644 --- a/src/librustdoc/passes/html_tags.rs +++ b/src/librustdoc/passes/html_tags.rs @@ -94,6 +94,14 @@ fn extract_path_backwards(text: &str, end_pos: usize) -> Option { if current_pos == end_pos { None } else { Some(current_pos) } } +fn is_valid_for_html_tag_name(c: char, is_empty: bool) -> bool { + // https://spec.commonmark.org/0.30/#raw-html + // + // > A tag name consists of an ASCII letter followed by zero or more ASCII letters, digits, or + // > hyphens (-). + c.is_ascii_alphabetic() || (c.is_ascii_digit() && !is_empty) || (c == '-' && !is_empty) +} + fn extract_html_tag( tags: &mut Vec<(String, Range)>, text: &str, @@ -117,7 +125,7 @@ fn extract_html_tag( // Checking if this is a closing tag (like `` for ``). if c == '/' && tag_name.is_empty() { is_closing = true; - } else if c.is_ascii_alphanumeric() { + } else if is_valid_for_html_tag_name(c, tag_name.is_empty()) { tag_name.push(c); } else { if !tag_name.is_empty() { diff --git a/src/test/rustdoc-ui/invalid-html-tags.rs b/src/test/rustdoc-ui/invalid-html-tags.rs index cec44b6d2ca..0f9d2e4b35d 100644 --- a/src/test/rustdoc-ui/invalid-html-tags.rs +++ b/src/test/rustdoc-ui/invalid-html-tags.rs @@ -108,3 +108,9 @@ pub fn j() {} /// shouldn't warn! /// `````` pub fn k() {} + +/// Web Components style +//~^ ERROR unclosed HTML tag `dashed-tags` +/// Web Components style +//~^ ERROR unopened HTML tag `unopened-tag` +pub fn m() {} diff --git a/src/test/rustdoc-ui/invalid-html-tags.stderr b/src/test/rustdoc-ui/invalid-html-tags.stderr index 335e100c89d..24a455576e8 100644 --- a/src/test/rustdoc-ui/invalid-html-tags.stderr +++ b/src/test/rustdoc-ui/invalid-html-tags.stderr @@ -82,5 +82,17 @@ error: Unclosed HTML comment LL | /// $DIR/invalid-html-tags.rs:114:26 + | +LL | /// Web Components style + | ^^^^^^^^^^^^^^^ + +error: unclosed HTML tag `dashed-tags` + --> $DIR/invalid-html-tags.rs:112:26 + | +LL | /// Web Components style + | ^^^^^^^^^^^^^ + +error: aborting due to 15 previous errors From 940ec1e51725a63c80f42f02735e87a12c9c5edb Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 29 Jul 2022 05:44:05 +0000 Subject: [PATCH 02/10] Remove parent_pat from TopInfo --- compiler/rustc_typeck/src/check/pat.rs | 54 +++++++++----------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index c7318cd6e53..837c323553c 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -72,22 +72,6 @@ struct TopInfo<'tcx> { /// found type `std::result::Result<_, _>` /// ``` span: Option, - /// This refers to the parent pattern. Used to provide extra diagnostic information on errors. - /// ```text - /// error[E0308]: mismatched types - /// --> $DIR/const-in-struct-pat.rs:8:17 - /// | - /// L | struct f; - /// | --------- unit struct defined here - /// ... - /// L | let Thing { f } = t; - /// | ^ - /// | | - /// | expected struct `std::string::String`, found struct `f` - /// | `f` is interpreted as a unit struct, not a new binding - /// | help: bind the struct field to a different name instead: `f: other_f` - /// ``` - parent_pat: Option<&'tcx Pat<'tcx>>, } impl<'tcx> FnCtxt<'_, 'tcx> { @@ -147,7 +131,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span: Option, origin_expr: bool, ) { - let info = TopInfo { expected, origin_expr, span, parent_pat: None }; + let info = TopInfo { expected, origin_expr, span }; self.check_pat(pat, expected, INITIAL_BM, info); } @@ -190,9 +174,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, def_bm, ti) } PatKind::Or(pats) => { - let parent_pat = Some(pat); for pat in pats { - self.check_pat(pat, expected, def_bm, TopInfo { parent_pat, ..ti }); + self.check_pat(pat, expected, def_bm, ti); } expected } @@ -621,7 +604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if let Some(p) = sub { - self.check_pat(p, expected, def_bm, TopInfo { parent_pat: Some(pat), ..ti }); + self.check_pat(p, expected, def_bm, ti); } local_ty @@ -782,7 +765,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let Some((variant, pat_ty)) = self.check_struct_path(qpath, pat.hir_id) else { let err = self.tcx.ty_error(); for field in fields { - let ti = TopInfo { parent_pat: Some(pat), ..ti }; + let ti = ti; self.check_pat(field.pat, err, def_bm, ti); } return err; @@ -799,11 +782,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_pat_path<'b>( + fn check_pat_path( &self, - pat: &Pat<'_>, + pat: &Pat<'tcx>, qpath: &hir::QPath<'_>, - path_resolution: (Res, Option>, &'b [hir::PathSegment<'b>]), + path_resolution: (Res, Option>, &'tcx [hir::PathSegment<'tcx>]), expected: Ty<'tcx>, ti: TopInfo<'tcx>, ) -> Ty<'tcx> { @@ -837,7 +820,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(err) = self.demand_suptype_with_origin(&self.pattern_cause(ti, pat.span), expected, pat_ty) { - self.emit_bad_pat_path(err, pat.span, res, pat_res, pat_ty, segments, ti.parent_pat); + self.emit_bad_pat_path(err, pat, res, pat_res, pat_ty, segments); } pat_ty } @@ -876,16 +859,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { false } - fn emit_bad_pat_path<'b>( + fn emit_bad_pat_path( &self, mut e: DiagnosticBuilder<'_, ErrorGuaranteed>, - pat_span: Span, + pat: &hir::Pat<'tcx>, res: Res, pat_res: Res, pat_ty: Ty<'tcx>, - segments: &'b [hir::PathSegment<'b>], - parent_pat: Option<&Pat<'_>>, + segments: &'tcx [hir::PathSegment<'tcx>], ) { + let pat_span = pat.span; if let Some(span) = self.tcx.hir().res_span(pat_res) { e.span_label(span, &format!("{} defined here", res.descr())); if let [hir::PathSegment { ident, .. }] = &*segments { @@ -898,8 +881,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { res.descr(), ), ); - match parent_pat { - Some(Pat { kind: hir::PatKind::Struct(..), .. }) => { + match self.tcx.hir().get(self.tcx.hir().get_parent_node(pat.hir_id)) { + hir::Node::Pat(Pat { kind: hir::PatKind::Struct(..), .. }) => { e.span_suggestion_verbose( ident.span.shrink_to_hi(), "bind the struct field to a different name instead", @@ -960,9 +943,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { let tcx = self.tcx; let on_error = || { - let parent_pat = Some(pat); for pat in subpats { - self.check_pat(pat, tcx.ty_error(), def_bm, TopInfo { parent_pat, ..ti }); + self.check_pat(pat, tcx.ty_error(), def_bm, ti); } }; let report_unexpected_res = |res: Res| { @@ -1046,7 +1028,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) { let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs); - self.check_pat(subpat, field_ty, def_bm, TopInfo { parent_pat: Some(pat), ..ti }); + self.check_pat(subpat, field_ty, def_bm, ti); self.tcx.check_stability( variant.fields[i].did, @@ -1324,7 +1306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }; - self.check_pat(field.pat, field_ty, def_bm, TopInfo { parent_pat: Some(pat), ..ti }); + self.check_pat(field.pat, field_ty, def_bm, ti); } let mut unmentioned_fields = variant @@ -1936,7 +1918,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let err = tcx.ty_error(); (err, err) }; - self.check_pat(inner, inner_ty, def_bm, TopInfo { parent_pat: Some(pat), ..ti }); + self.check_pat(inner, inner_ty, def_bm, ti); rptr_ty } From 77f7a833dd93736e899786603bbee6d28056f184 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 29 Jul 2022 05:48:40 +0000 Subject: [PATCH 03/10] Do not allow bad projection term to leak into the type checker --- compiler/rustc_typeck/src/astconv/mod.rs | 18 ++++++++++---- .../assoc-const-ty-mismatch.rs | 4 ++-- .../assoc-const-ty-mismatch.stderr | 8 +++---- .../ui/associated-type-bounds/issue-99828.rs | 11 +++++++++ .../associated-type-bounds/issue-99828.stderr | 24 +++++++++++++++++++ 5 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/associated-type-bounds/issue-99828.rs create mode 100644 src/test/ui/associated-type-bounds/issue-99828.stderr diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 08e8e6f7d0f..444f0fdd45a 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -1234,7 +1234,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } match binding.kind { - ConvertedBindingKind::Equality(term) => { + ConvertedBindingKind::Equality(mut term) => { // "Desugar" a constraint like `T: Iterator` this to // the "projection predicate" for: // @@ -1245,18 +1245,28 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { (hir::def::DefKind::AssocTy, ty::Term::Ty(_)) | (hir::def::DefKind::AssocConst, ty::Term::Const(_)) => (), (_, _) => { - let got = if let ty::Term::Ty(_) = term { "type" } else { "const" }; + let got = if let ty::Term::Ty(_) = term { "type" } else { "constant" }; let expected = def_kind.descr(assoc_item_def_id); tcx.sess .struct_span_err( binding.span, - &format!("mismatch in bind of {expected}, got {got}"), + &format!("expected {expected} bound, found {got}"), ) .span_note( tcx.def_span(assoc_item_def_id), - &format!("{expected} defined here does not match {got}"), + &format!("{expected} defined here"), ) .emit(); + term = match def_kind { + hir::def::DefKind::AssocTy => tcx.ty_error().into(), + hir::def::DefKind::AssocConst => tcx + .const_error( + tcx.bound_type_of(assoc_item_def_id) + .subst(tcx, projection_ty.skip_binder().substs), + ) + .into(), + _ => unreachable!(), + }; } } bounds.projection_bounds.push(( diff --git a/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs b/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs index c3293156345..c5d78469e95 100644 --- a/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs +++ b/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs @@ -21,9 +21,9 @@ impl FooTy for Bar { fn foo>() {} -//~^ ERROR mismatch in +//~^ ERROR expected associated constant bound, found type fn foo2>() {} -//~^ ERROR mismatch in +//~^ ERROR expected associated type bound, found constant fn main() { foo::(); diff --git a/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr b/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr index 58a8aceca2f..11198729e38 100644 --- a/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr +++ b/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr @@ -1,22 +1,22 @@ -error: mismatch in bind of associated constant, got type +error: expected associated constant bound, found type --> $DIR/assoc-const-ty-mismatch.rs:23:15 | LL | fn foo>() {} | ^^^^^^^ | -note: associated constant defined here does not match type +note: associated constant defined here --> $DIR/assoc-const-ty-mismatch.rs:5:3 | LL | const N: usize; | ^^^^^^^^^^^^^^ -error: mismatch in bind of associated type, got const +error: expected associated type bound, found constant --> $DIR/assoc-const-ty-mismatch.rs:25:18 | LL | fn foo2>() {} | ^^^^^^^^ | -note: associated type defined here does not match const +note: associated type defined here --> $DIR/assoc-const-ty-mismatch.rs:9:3 | LL | type T; diff --git a/src/test/ui/associated-type-bounds/issue-99828.rs b/src/test/ui/associated-type-bounds/issue-99828.rs new file mode 100644 index 00000000000..7b711283f5b --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-99828.rs @@ -0,0 +1,11 @@ +fn get_iter(vec: &[i32]) -> impl Iterator + '_ { + //~^ ERROR expected associated type bound, found constant + //~| ERROR associated const equality is incomplete + vec.iter() +} + +fn main() { + let vec = Vec::new(); + let mut iter = get_iter(&vec); + iter.next(); +} diff --git a/src/test/ui/associated-type-bounds/issue-99828.stderr b/src/test/ui/associated-type-bounds/issue-99828.stderr new file mode 100644 index 00000000000..1c20ead0556 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-99828.stderr @@ -0,0 +1,24 @@ +error[E0658]: associated const equality is incomplete + --> $DIR/issue-99828.rs:1:43 + | +LL | fn get_iter(vec: &[i32]) -> impl Iterator + '_ { + | ^^^^^^^^^ + | + = note: see issue #92827 for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error: expected associated type bound, found constant + --> $DIR/issue-99828.rs:1:43 + | +LL | fn get_iter(vec: &[i32]) -> impl Iterator + '_ { + | ^^^^^^^^^ + | +note: associated type defined here + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | +LL | type Item; + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. From 2c70b6abf4d9d78556125a145bdce1bbacbda5b4 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 23 Jul 2022 14:47:05 -0500 Subject: [PATCH 04/10] Don't give a hard error for `x check --keep-stage 0` Stage 1 check has been supported since https://github.com/rust-lang/rust/pull/81064. #81064 changed the error message for this, but I don't think there's any reason we should prevent using it. I tested locally and `keep-stage` works fine. Don't give a hard error when trying to use it. --- src/bootstrap/flags.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 1822c2936b7..80b3bcce860 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -623,15 +623,6 @@ Arguments: } }; - if let Subcommand::Check { .. } = &cmd { - if matches.opt_str("keep-stage").is_some() - || matches.opt_str("keep-stage-std").is_some() - { - eprintln!("--keep-stage not yet supported for x.py check"); - crate::detail_exit(1); - } - } - Flags { verbose: matches.opt_count("verbose"), stage: matches.opt_str("stage").map(|j| j.parse().expect("`stage` should be a number")), From aac8a0a518048d6102c1342835904cfb2ebdab63 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 30 Jul 2022 05:28:38 +0100 Subject: [PATCH 05/10] Reset directory iteration in remove_dir_all --- library/std/src/sys/windows/fs.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 4d3162f1254..c96bcf41d51 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -1035,11 +1035,13 @@ fn remove_dir_all_iterative(f: &File, delete: fn(&File) -> io::Result<()>) -> io unsafe { mem::ManuallyDrop::new(File::from_raw_handle(f.as_raw_handle())) } } + let mut restart = true; while let Some(dir) = dirlist.last() { let dir = copy_handle(dir); // Fill the buffer and iterate the entries. - let more_data = dir.fill_dir_buff(&mut buffer, false)?; + let more_data = dir.fill_dir_buff(&mut buffer, restart)?; + restart = false; for (name, is_directory) in buffer.iter() { if is_directory { let child_dir = open_link_no_reparse( From 21c812aa7a1a51a9583d7d90954079e9a21bc571 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 30 Jul 2022 17:34:29 +0200 Subject: [PATCH 06/10] Remove Clean trait implementation for ty::VariantDef --- src/librustdoc/clean/inline.rs | 6 +++--- src/librustdoc/clean/mod.rs | 32 +++++++++++++++----------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 55d77a63f61..838283e32da 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -17,8 +17,8 @@ use rustc_span::symbol::{kw, sym, Symbol}; use crate::clean::{ self, clean_fn_decl_from_did_and_sig, clean_middle_field, clean_middle_ty, clean_ty, - clean_ty_generics, clean_visibility, utils, Attributes, AttributesExt, Clean, ImplKind, ItemId, - Type, Visibility, + clean_ty_generics, clean_variant_def, clean_visibility, utils, Attributes, AttributesExt, + Clean, ImplKind, ItemId, Type, Visibility, }; use crate::core::DocContext; use crate::formats::item_type::ItemType; @@ -236,7 +236,7 @@ fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum { clean::Enum { generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates), - variants: cx.tcx.adt_def(did).variants().iter().map(|v| v.clean(cx)).collect(), + variants: cx.tcx.adt_def(did).variants().iter().map(|v| clean_variant_def(v, cx)).collect(), } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 10676aca480..efd8cf5205b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1834,23 +1834,21 @@ fn clean_variant_data<'tcx>( } } -impl<'tcx> Clean<'tcx, Item> for ty::VariantDef { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { - let kind = match self.ctor_kind { - CtorKind::Const => Variant::CLike, - CtorKind::Fn => Variant::Tuple( - self.fields.iter().map(|field| clean_middle_field(field, cx)).collect(), - ), - CtorKind::Fictive => Variant::Struct(VariantStruct { - struct_type: CtorKind::Fictive, - fields: self.fields.iter().map(|field| clean_middle_field(field, cx)).collect(), - }), - }; - let what_rustc_thinks = - Item::from_def_id_and_parts(self.def_id, Some(self.name), VariantItem(kind), cx); - // don't show `pub` for variants, which always inherit visibility - Item { visibility: Inherited, ..what_rustc_thinks } - } +pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocContext<'tcx>) -> Item { + let kind = match variant.ctor_kind { + CtorKind::Const => Variant::CLike, + CtorKind::Fn => Variant::Tuple( + variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(), + ), + CtorKind::Fictive => Variant::Struct(VariantStruct { + struct_type: CtorKind::Fictive, + fields: variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(), + }), + }; + let what_rustc_thinks = + Item::from_def_id_and_parts(variant.def_id, Some(variant.name), VariantItem(kind), cx); + // don't show `pub` for variants, which always inherit visibility + Item { visibility: Inherited, ..what_rustc_thinks } } impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> { From c407ef0de06dcd3450df28eb2c0ea6396b97dcb0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 30 Jul 2022 17:48:06 +0200 Subject: [PATCH 07/10] Remove Clean trait implementation for hir::VariantData --- src/librustdoc/clean/mod.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index efd8cf5205b..4067cf8441b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1824,16 +1824,6 @@ pub(crate) fn clean_visibility(vis: ty::Visibility) -> Visibility { } } -fn clean_variant_data<'tcx>( - variant: &hir::VariantData<'tcx>, - cx: &mut DocContext<'tcx>, -) -> VariantStruct { - VariantStruct { - struct_type: CtorKind::from_hir(variant), - fields: variant.fields().iter().map(|x| clean_field(x, cx)).collect(), - } -} - pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocContext<'tcx>) -> Item { let kind = match variant.ctor_kind { CtorKind::Const => Variant::CLike, @@ -1851,15 +1841,19 @@ pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocCont Item { visibility: Inherited, ..what_rustc_thinks } } -impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Variant { - match self { - hir::VariantData::Struct(..) => Variant::Struct(clean_variant_data(self, cx)), - hir::VariantData::Tuple(..) => { - Variant::Tuple(self.fields().iter().map(|x| clean_field(x, cx)).collect()) - } - hir::VariantData::Unit(..) => Variant::CLike, +fn clean_variant_data<'tcx>( + variant: &hir::VariantData<'tcx>, + cx: &mut DocContext<'tcx>, +) -> Variant { + match variant { + hir::VariantData::Struct(..) => Variant::Struct(VariantStruct { + struct_type: CtorKind::from_hir(variant), + fields: variant.fields().iter().map(|x| clean_field(x, cx)).collect(), + }), + hir::VariantData::Tuple(..) => { + Variant::Tuple(variant.fields().iter().map(|x| clean_field(x, cx)).collect()) } + hir::VariantData::Unit(..) => Variant::CLike, } } @@ -2007,7 +2001,7 @@ fn clean_maybe_renamed_item<'tcx>( impl<'tcx> Clean<'tcx, Item> for hir::Variant<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { - let kind = VariantItem(self.data.clean(cx)); + let kind = VariantItem(clean_variant_data(&self.data, cx)); let what_rustc_thinks = Item::from_hir_id_and_parts(self.id, Some(self.ident.name), kind, cx); // don't show `pub` for variants, which are always public From ad197e414c7dee64287b7f59b7ee3567a7f05927 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 30 Jul 2022 09:02:05 -0700 Subject: [PATCH 08/10] Update src/librustdoc/passes/html_tags.rs Co-authored-by: Guillaume Gomez --- src/librustdoc/passes/html_tags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index d65e076b818..f3a3c853cac 100644 --- a/src/librustdoc/passes/html_tags.rs +++ b/src/librustdoc/passes/html_tags.rs @@ -99,7 +99,7 @@ fn is_valid_for_html_tag_name(c: char, is_empty: bool) -> bool { // // > A tag name consists of an ASCII letter followed by zero or more ASCII letters, digits, or // > hyphens (-). - c.is_ascii_alphabetic() || (c.is_ascii_digit() && !is_empty) || (c == '-' && !is_empty) + c.is_ascii_alphabetic() || !is_empty && (c == '-' || c.is_ascii_digit()) } fn extract_html_tag( From eca274a1f92925ebcf0db0e2ff9ab03000fd6c4c Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 30 Jul 2022 18:53:51 +0200 Subject: [PATCH 09/10] Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GE Fixes a warning: warning: llvm-wrapper/RustWrapper.cpp:159:11: warning: enumeration values 'AllocatedPointer' and 'AllocAlign' not handled in switch [-Wswitch] warning: switch (Kind) { warning: ^ Which was fall out from 130a1df71ea73ab9d66d3cb8fc9cdb43155d514b. --- compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h index 93f302b44e8..015c1c52bef 100644 --- a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h +++ b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h @@ -87,8 +87,10 @@ enum LLVMRustAttribute { NoCfCheck = 35, ShadowCallStack = 36, AllocSize = 37, +#if LLVM_VERSION_GE(15, 0) AllocatedPointer = 38, AllocAlign = 39, +#endif }; typedef struct OpaqueRustString *RustStringRef; From d63e982cd924ed4d4fbcbb42b9614fc24a91f211 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 30 Jul 2022 15:44:37 -0400 Subject: [PATCH 10/10] Discover channel for artifact download When we're downloading based on a CI commit, that can still be -beta- or even -stable-, so we should lookup the channel it was built with. --- src/bootstrap/config.rs | 16 +++++++++++----- src/bootstrap/native.rs | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index c7212ad2c21..4325a237c69 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1312,6 +1312,13 @@ impl Config { git } + pub(crate) fn artifact_channel(&self, commit: &str) -> String { + let mut channel = self.git(); + channel.arg("show").arg(format!("{}:src/ci/channel", commit)); + let channel = output(&mut channel); + channel.trim().to_owned() + } + /// Try to find the relative path of `bindir`, otherwise return it in full. pub fn bindir_relative(&self) -> &Path { let bindir = &self.bindir; @@ -1547,8 +1554,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option { fn download_ci_rustc(builder: &Builder<'_>, commit: &str) { builder.verbose(&format!("using downloaded stage2 artifacts from CI (commit {commit})")); - // FIXME: support downloading artifacts from the beta channel - const CHANNEL: &str = "nightly"; + let channel = builder.config.artifact_channel(commit); let host = builder.config.build.triple; let bin_root = builder.out.join(host).join("ci-rustc"); let rustc_stamp = bin_root.join(".rustc-stamp"); @@ -1557,13 +1563,13 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) { if bin_root.exists() { t!(fs::remove_dir_all(&bin_root)); } - let filename = format!("rust-std-{CHANNEL}-{host}.tar.xz"); + let filename = format!("rust-std-{channel}-{host}.tar.xz"); let pattern = format!("rust-std-{host}"); download_ci_component(builder, filename, &pattern, commit); - let filename = format!("rustc-{CHANNEL}-{host}.tar.xz"); + let filename = format!("rustc-{channel}-{host}.tar.xz"); download_ci_component(builder, filename, "rustc", commit); // download-rustc doesn't need its own cargo, it can just use beta's. - let filename = format!("rustc-dev-{CHANNEL}-{host}.tar.xz"); + let filename = format!("rustc-dev-{channel}-{host}.tar.xz"); download_ci_component(builder, filename, "rustc-dev", commit); builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc")); diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 01e70b3fb2d..3347246ea8f 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -189,7 +189,8 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) { } else { &builder.config.stage0_metadata.config.artifacts_server }; - let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple); + let channel = builder.config.artifact_channel(llvm_sha); + let filename = format!("rust-dev-{}-{}.tar.xz", channel, builder.build.build.triple); let tarball = rustc_cache.join(&filename); if !tarball.exists() { let help_on_error = "error: failed to download llvm from ci