Skip to content

Rollup of 8 pull requests #99964

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 18 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f5cd6b3
rustdoc: align invalid-html-tags lint with commonmark spec
notriddle Jul 28, 2022
940ec1e
Remove parent_pat from TopInfo
compiler-errors Jul 29, 2022
77f7a83
Do not allow bad projection term to leak into the type checker
compiler-errors Jul 29, 2022
2c70b6a
Don't give a hard error for `x check --keep-stage 0`
jyn514 Jul 23, 2022
aac8a0a
Reset directory iteration in remove_dir_all
ChrisDenton Jul 30, 2022
21c812a
Remove Clean trait implementation for ty::VariantDef
GuillaumeGomez Jul 30, 2022
c407ef0
Remove Clean trait implementation for hir::VariantData
GuillaumeGomez Jul 30, 2022
ad197e4
Update src/librustdoc/passes/html_tags.rs
notriddle Jul 30, 2022
eca274a
Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GE
est31 Jul 30, 2022
d63e982
Discover channel for artifact download
Mark-Simulacrum Jul 30, 2022
44c4b4a
Rollup merge of #99650 - jyn514:keep-stage-check, r=Mark-Simulacrum
matthiaskrgr Jul 30, 2022
852bf84
Rollup merge of #99873 - notriddle:notriddle/invalid-html-tags-webcom…
matthiaskrgr Jul 30, 2022
451349a
Rollup merge of #99889 - compiler-errors:cleanup-ti, r=cjgillot
matthiaskrgr Jul 30, 2022
686cb11
Rollup merge of #99890 - compiler-errors:issue-99828, r=lcnr
matthiaskrgr Jul 30, 2022
656cd3a
Rollup merge of #99937 - ChrisDenton:fix-remove-dir-all-win-7, r=josh…
matthiaskrgr Jul 30, 2022
55258de
Rollup merge of #99950 - GuillaumeGomez:rm-clean-impls, r=Dylan-DPC
matthiaskrgr Jul 30, 2022
b9ad36c
Rollup merge of #99956 - est31:fix_llvm_wrapper_warning, r=cuviper
matthiaskrgr Jul 30, 2022
f21a06f
Rollup merge of #99962 - Mark-Simulacrum:detect-ci-artifact-channel, …
matthiaskrgr Jul 30, 2022
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
2 changes: 2 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 14 additions & 4 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = u32>` this to
// the "projection predicate" for:
//
Expand All @@ -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((
Expand Down
54 changes: 18 additions & 36 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,6 @@ struct TopInfo<'tcx> {
/// found type `std::result::Result<_, _>`
/// ```
span: Option<Span>,
/// 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> {
Expand Down Expand Up @@ -147,7 +131,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span: Option<Span>,
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);
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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<Ty<'tcx>>, &'b [hir::PathSegment<'b>]),
path_resolution: (Res, Option<Ty<'tcx>>, &'tcx [hir::PathSegment<'tcx>]),
expected: Ty<'tcx>,
ti: TopInfo<'tcx>,
) -> Ty<'tcx> {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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",
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 3 additions & 1 deletion library/std/src/sys/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 11 additions & 5 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1547,8 +1554,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> {

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");
Expand All @@ -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"));
Expand Down
9 changes: 0 additions & 9 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
}
}

Expand Down
62 changes: 27 additions & 35 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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
Expand Down
Loading