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; 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/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 } 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( 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/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")), 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 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..4067cf8441b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1824,44 +1824,36 @@ pub(crate) fn clean_visibility(vis: ty::Visibility) -> Visibility { } } +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 } +} + 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(), - } -} - -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 } - } -} - -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, +) -> 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, } } @@ -2009,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 diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index d8ad299c3d3..f3a3c853cac 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() || !is_empty && (c == '-' || c.is_ascii_digit()) +} + 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 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`.