Skip to content

Commit 0f4bcad

Browse files
committed
Auto merge of #99964 - matthiaskrgr:rollup-jr836e2, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #99650 (Support `x --keep-stage 0 check`) - #99873 (rustdoc: align invalid-html-tags lint with commonmark spec) - #99889 (Remove `parent_pat` from `TopInfo`) - #99890 (Do not allow bad projection term to leak into the type checker) - #99937 (Reset directory iteration in remove_dir_all) - #99950 (Remove more Clean trait implementations) - #99956 (Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GE) - #99962 (Discover channel for LLVM download) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 038f9e6 + f21a06f commit 0f4bcad

File tree

16 files changed

+149
-102
lines changed

16 files changed

+149
-102
lines changed

compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h

+2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ enum LLVMRustAttribute {
8787
NoCfCheck = 35,
8888
ShadowCallStack = 36,
8989
AllocSize = 37,
90+
#if LLVM_VERSION_GE(15, 0)
9091
AllocatedPointer = 38,
9192
AllocAlign = 39,
93+
#endif
9294
};
9395

9496
typedef struct OpaqueRustString *RustStringRef;

compiler/rustc_typeck/src/astconv/mod.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12341234
}
12351235

12361236
match binding.kind {
1237-
ConvertedBindingKind::Equality(term) => {
1237+
ConvertedBindingKind::Equality(mut term) => {
12381238
// "Desugar" a constraint like `T: Iterator<Item = u32>` this to
12391239
// the "projection predicate" for:
12401240
//
@@ -1245,18 +1245,28 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12451245
(hir::def::DefKind::AssocTy, ty::Term::Ty(_))
12461246
| (hir::def::DefKind::AssocConst, ty::Term::Const(_)) => (),
12471247
(_, _) => {
1248-
let got = if let ty::Term::Ty(_) = term { "type" } else { "const" };
1248+
let got = if let ty::Term::Ty(_) = term { "type" } else { "constant" };
12491249
let expected = def_kind.descr(assoc_item_def_id);
12501250
tcx.sess
12511251
.struct_span_err(
12521252
binding.span,
1253-
&format!("mismatch in bind of {expected}, got {got}"),
1253+
&format!("expected {expected} bound, found {got}"),
12541254
)
12551255
.span_note(
12561256
tcx.def_span(assoc_item_def_id),
1257-
&format!("{expected} defined here does not match {got}"),
1257+
&format!("{expected} defined here"),
12581258
)
12591259
.emit();
1260+
term = match def_kind {
1261+
hir::def::DefKind::AssocTy => tcx.ty_error().into(),
1262+
hir::def::DefKind::AssocConst => tcx
1263+
.const_error(
1264+
tcx.bound_type_of(assoc_item_def_id)
1265+
.subst(tcx, projection_ty.skip_binder().substs),
1266+
)
1267+
.into(),
1268+
_ => unreachable!(),
1269+
};
12601270
}
12611271
}
12621272
bounds.projection_bounds.push((

compiler/rustc_typeck/src/check/pat.rs

+18-36
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,6 @@ struct TopInfo<'tcx> {
7272
/// found type `std::result::Result<_, _>`
7373
/// ```
7474
span: Option<Span>,
75-
/// This refers to the parent pattern. Used to provide extra diagnostic information on errors.
76-
/// ```text
77-
/// error[E0308]: mismatched types
78-
/// --> $DIR/const-in-struct-pat.rs:8:17
79-
/// |
80-
/// L | struct f;
81-
/// | --------- unit struct defined here
82-
/// ...
83-
/// L | let Thing { f } = t;
84-
/// | ^
85-
/// | |
86-
/// | expected struct `std::string::String`, found struct `f`
87-
/// | `f` is interpreted as a unit struct, not a new binding
88-
/// | help: bind the struct field to a different name instead: `f: other_f`
89-
/// ```
90-
parent_pat: Option<&'tcx Pat<'tcx>>,
9175
}
9276

9377
impl<'tcx> FnCtxt<'_, 'tcx> {
@@ -147,7 +131,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
147131
span: Option<Span>,
148132
origin_expr: bool,
149133
) {
150-
let info = TopInfo { expected, origin_expr, span, parent_pat: None };
134+
let info = TopInfo { expected, origin_expr, span };
151135
self.check_pat(pat, expected, INITIAL_BM, info);
152136
}
153137

@@ -190,9 +174,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
190174
self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, def_bm, ti)
191175
}
192176
PatKind::Or(pats) => {
193-
let parent_pat = Some(pat);
194177
for pat in pats {
195-
self.check_pat(pat, expected, def_bm, TopInfo { parent_pat, ..ti });
178+
self.check_pat(pat, expected, def_bm, ti);
196179
}
197180
expected
198181
}
@@ -621,7 +604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
621604
}
622605

623606
if let Some(p) = sub {
624-
self.check_pat(p, expected, def_bm, TopInfo { parent_pat: Some(pat), ..ti });
607+
self.check_pat(p, expected, def_bm, ti);
625608
}
626609

627610
local_ty
@@ -782,7 +765,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
782765
let Some((variant, pat_ty)) = self.check_struct_path(qpath, pat.hir_id) else {
783766
let err = self.tcx.ty_error();
784767
for field in fields {
785-
let ti = TopInfo { parent_pat: Some(pat), ..ti };
768+
let ti = ti;
786769
self.check_pat(field.pat, err, def_bm, ti);
787770
}
788771
return err;
@@ -799,11 +782,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
799782
}
800783
}
801784

802-
fn check_pat_path<'b>(
785+
fn check_pat_path(
803786
&self,
804-
pat: &Pat<'_>,
787+
pat: &Pat<'tcx>,
805788
qpath: &hir::QPath<'_>,
806-
path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment<'b>]),
789+
path_resolution: (Res, Option<Ty<'tcx>>, &'tcx [hir::PathSegment<'tcx>]),
807790
expected: Ty<'tcx>,
808791
ti: TopInfo<'tcx>,
809792
) -> Ty<'tcx> {
@@ -837,7 +820,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
837820
if let Some(err) =
838821
self.demand_suptype_with_origin(&self.pattern_cause(ti, pat.span), expected, pat_ty)
839822
{
840-
self.emit_bad_pat_path(err, pat.span, res, pat_res, pat_ty, segments, ti.parent_pat);
823+
self.emit_bad_pat_path(err, pat, res, pat_res, pat_ty, segments);
841824
}
842825
pat_ty
843826
}
@@ -876,16 +859,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
876859
false
877860
}
878861

879-
fn emit_bad_pat_path<'b>(
862+
fn emit_bad_pat_path(
880863
&self,
881864
mut e: DiagnosticBuilder<'_, ErrorGuaranteed>,
882-
pat_span: Span,
865+
pat: &hir::Pat<'tcx>,
883866
res: Res,
884867
pat_res: Res,
885868
pat_ty: Ty<'tcx>,
886-
segments: &'b [hir::PathSegment<'b>],
887-
parent_pat: Option<&Pat<'_>>,
869+
segments: &'tcx [hir::PathSegment<'tcx>],
888870
) {
871+
let pat_span = pat.span;
889872
if let Some(span) = self.tcx.hir().res_span(pat_res) {
890873
e.span_label(span, &format!("{} defined here", res.descr()));
891874
if let [hir::PathSegment { ident, .. }] = &*segments {
@@ -898,8 +881,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
898881
res.descr(),
899882
),
900883
);
901-
match parent_pat {
902-
Some(Pat { kind: hir::PatKind::Struct(..), .. }) => {
884+
match self.tcx.hir().get(self.tcx.hir().get_parent_node(pat.hir_id)) {
885+
hir::Node::Pat(Pat { kind: hir::PatKind::Struct(..), .. }) => {
903886
e.span_suggestion_verbose(
904887
ident.span.shrink_to_hi(),
905888
"bind the struct field to a different name instead",
@@ -960,9 +943,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
960943
) -> Ty<'tcx> {
961944
let tcx = self.tcx;
962945
let on_error = || {
963-
let parent_pat = Some(pat);
964946
for pat in subpats {
965-
self.check_pat(pat, tcx.ty_error(), def_bm, TopInfo { parent_pat, ..ti });
947+
self.check_pat(pat, tcx.ty_error(), def_bm, ti);
966948
}
967949
};
968950
let report_unexpected_res = |res: Res| {
@@ -1046,7 +1028,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10461028
};
10471029
for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) {
10481030
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
1049-
self.check_pat(subpat, field_ty, def_bm, TopInfo { parent_pat: Some(pat), ..ti });
1031+
self.check_pat(subpat, field_ty, def_bm, ti);
10501032

10511033
self.tcx.check_stability(
10521034
variant.fields[i].did,
@@ -1324,7 +1306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13241306
}
13251307
};
13261308

1327-
self.check_pat(field.pat, field_ty, def_bm, TopInfo { parent_pat: Some(pat), ..ti });
1309+
self.check_pat(field.pat, field_ty, def_bm, ti);
13281310
}
13291311

13301312
let mut unmentioned_fields = variant
@@ -1936,7 +1918,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19361918
let err = tcx.ty_error();
19371919
(err, err)
19381920
};
1939-
self.check_pat(inner, inner_ty, def_bm, TopInfo { parent_pat: Some(pat), ..ti });
1921+
self.check_pat(inner, inner_ty, def_bm, ti);
19401922
rptr_ty
19411923
}
19421924

library/std/src/sys/windows/fs.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1035,11 +1035,13 @@ fn remove_dir_all_iterative(f: &File, delete: fn(&File) -> io::Result<()>) -> io
10351035
unsafe { mem::ManuallyDrop::new(File::from_raw_handle(f.as_raw_handle())) }
10361036
}
10371037

1038+
let mut restart = true;
10381039
while let Some(dir) = dirlist.last() {
10391040
let dir = copy_handle(dir);
10401041

10411042
// Fill the buffer and iterate the entries.
1042-
let more_data = dir.fill_dir_buff(&mut buffer, false)?;
1043+
let more_data = dir.fill_dir_buff(&mut buffer, restart)?;
1044+
restart = false;
10431045
for (name, is_directory) in buffer.iter() {
10441046
if is_directory {
10451047
let child_dir = open_link_no_reparse(

src/bootstrap/config.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,13 @@ impl Config {
13121312
git
13131313
}
13141314

1315+
pub(crate) fn artifact_channel(&self, commit: &str) -> String {
1316+
let mut channel = self.git();
1317+
channel.arg("show").arg(format!("{}:src/ci/channel", commit));
1318+
let channel = output(&mut channel);
1319+
channel.trim().to_owned()
1320+
}
1321+
13151322
/// Try to find the relative path of `bindir`, otherwise return it in full.
13161323
pub fn bindir_relative(&self) -> &Path {
13171324
let bindir = &self.bindir;
@@ -1547,8 +1554,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> {
15471554

15481555
fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
15491556
builder.verbose(&format!("using downloaded stage2 artifacts from CI (commit {commit})"));
1550-
// FIXME: support downloading artifacts from the beta channel
1551-
const CHANNEL: &str = "nightly";
1557+
let channel = builder.config.artifact_channel(commit);
15521558
let host = builder.config.build.triple;
15531559
let bin_root = builder.out.join(host).join("ci-rustc");
15541560
let rustc_stamp = bin_root.join(".rustc-stamp");
@@ -1557,13 +1563,13 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
15571563
if bin_root.exists() {
15581564
t!(fs::remove_dir_all(&bin_root));
15591565
}
1560-
let filename = format!("rust-std-{CHANNEL}-{host}.tar.xz");
1566+
let filename = format!("rust-std-{channel}-{host}.tar.xz");
15611567
let pattern = format!("rust-std-{host}");
15621568
download_ci_component(builder, filename, &pattern, commit);
1563-
let filename = format!("rustc-{CHANNEL}-{host}.tar.xz");
1569+
let filename = format!("rustc-{channel}-{host}.tar.xz");
15641570
download_ci_component(builder, filename, "rustc", commit);
15651571
// download-rustc doesn't need its own cargo, it can just use beta's.
1566-
let filename = format!("rustc-dev-{CHANNEL}-{host}.tar.xz");
1572+
let filename = format!("rustc-dev-{channel}-{host}.tar.xz");
15671573
download_ci_component(builder, filename, "rustc-dev", commit);
15681574

15691575
builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));

src/bootstrap/flags.rs

-9
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,6 @@ Arguments:
623623
}
624624
};
625625

626-
if let Subcommand::Check { .. } = &cmd {
627-
if matches.opt_str("keep-stage").is_some()
628-
|| matches.opt_str("keep-stage-std").is_some()
629-
{
630-
eprintln!("--keep-stage not yet supported for x.py check");
631-
crate::detail_exit(1);
632-
}
633-
}
634-
635626
Flags {
636627
verbose: matches.opt_count("verbose"),
637628
stage: matches.opt_str("stage").map(|j| j.parse().expect("`stage` should be a number")),

src/bootstrap/native.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) {
189189
} else {
190190
&builder.config.stage0_metadata.config.artifacts_server
191191
};
192-
let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple);
192+
let channel = builder.config.artifact_channel(llvm_sha);
193+
let filename = format!("rust-dev-{}-{}.tar.xz", channel, builder.build.build.triple);
193194
let tarball = rustc_cache.join(&filename);
194195
if !tarball.exists() {
195196
let help_on_error = "error: failed to download llvm from ci

src/librustdoc/clean/inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
1717

1818
use crate::clean::{
1919
self, clean_fn_decl_from_did_and_sig, clean_middle_field, clean_middle_ty, clean_ty,
20-
clean_ty_generics, clean_visibility, utils, Attributes, AttributesExt, Clean, ImplKind, ItemId,
21-
Type, Visibility,
20+
clean_ty_generics, clean_variant_def, clean_visibility, utils, Attributes, AttributesExt,
21+
Clean, ImplKind, ItemId, Type, Visibility,
2222
};
2323
use crate::core::DocContext;
2424
use crate::formats::item_type::ItemType;
@@ -236,7 +236,7 @@ fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum {
236236

237237
clean::Enum {
238238
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
239-
variants: cx.tcx.adt_def(did).variants().iter().map(|v| v.clean(cx)).collect(),
239+
variants: cx.tcx.adt_def(did).variants().iter().map(|v| clean_variant_def(v, cx)).collect(),
240240
}
241241
}
242242

src/librustdoc/clean/mod.rs

+27-35
Original file line numberDiff line numberDiff line change
@@ -1824,44 +1824,36 @@ pub(crate) fn clean_visibility(vis: ty::Visibility) -> Visibility {
18241824
}
18251825
}
18261826

1827+
pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocContext<'tcx>) -> Item {
1828+
let kind = match variant.ctor_kind {
1829+
CtorKind::Const => Variant::CLike,
1830+
CtorKind::Fn => Variant::Tuple(
1831+
variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
1832+
),
1833+
CtorKind::Fictive => Variant::Struct(VariantStruct {
1834+
struct_type: CtorKind::Fictive,
1835+
fields: variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
1836+
}),
1837+
};
1838+
let what_rustc_thinks =
1839+
Item::from_def_id_and_parts(variant.def_id, Some(variant.name), VariantItem(kind), cx);
1840+
// don't show `pub` for variants, which always inherit visibility
1841+
Item { visibility: Inherited, ..what_rustc_thinks }
1842+
}
1843+
18271844
fn clean_variant_data<'tcx>(
18281845
variant: &hir::VariantData<'tcx>,
18291846
cx: &mut DocContext<'tcx>,
1830-
) -> VariantStruct {
1831-
VariantStruct {
1832-
struct_type: CtorKind::from_hir(variant),
1833-
fields: variant.fields().iter().map(|x| clean_field(x, cx)).collect(),
1834-
}
1835-
}
1836-
1837-
impl<'tcx> Clean<'tcx, Item> for ty::VariantDef {
1838-
fn clean(&self, cx: &mut DocContext<'tcx>) -> Item {
1839-
let kind = match self.ctor_kind {
1840-
CtorKind::Const => Variant::CLike,
1841-
CtorKind::Fn => Variant::Tuple(
1842-
self.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
1843-
),
1844-
CtorKind::Fictive => Variant::Struct(VariantStruct {
1845-
struct_type: CtorKind::Fictive,
1846-
fields: self.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
1847-
}),
1848-
};
1849-
let what_rustc_thinks =
1850-
Item::from_def_id_and_parts(self.def_id, Some(self.name), VariantItem(kind), cx);
1851-
// don't show `pub` for variants, which always inherit visibility
1852-
Item { visibility: Inherited, ..what_rustc_thinks }
1853-
}
1854-
}
1855-
1856-
impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> {
1857-
fn clean(&self, cx: &mut DocContext<'tcx>) -> Variant {
1858-
match self {
1859-
hir::VariantData::Struct(..) => Variant::Struct(clean_variant_data(self, cx)),
1860-
hir::VariantData::Tuple(..) => {
1861-
Variant::Tuple(self.fields().iter().map(|x| clean_field(x, cx)).collect())
1862-
}
1863-
hir::VariantData::Unit(..) => Variant::CLike,
1847+
) -> Variant {
1848+
match variant {
1849+
hir::VariantData::Struct(..) => Variant::Struct(VariantStruct {
1850+
struct_type: CtorKind::from_hir(variant),
1851+
fields: variant.fields().iter().map(|x| clean_field(x, cx)).collect(),
1852+
}),
1853+
hir::VariantData::Tuple(..) => {
1854+
Variant::Tuple(variant.fields().iter().map(|x| clean_field(x, cx)).collect())
18641855
}
1856+
hir::VariantData::Unit(..) => Variant::CLike,
18651857
}
18661858
}
18671859

@@ -2009,7 +2001,7 @@ fn clean_maybe_renamed_item<'tcx>(
20092001

20102002
impl<'tcx> Clean<'tcx, Item> for hir::Variant<'tcx> {
20112003
fn clean(&self, cx: &mut DocContext<'tcx>) -> Item {
2012-
let kind = VariantItem(self.data.clean(cx));
2004+
let kind = VariantItem(clean_variant_data(&self.data, cx));
20132005
let what_rustc_thinks =
20142006
Item::from_hir_id_and_parts(self.id, Some(self.ident.name), kind, cx);
20152007
// don't show `pub` for variants, which are always public

0 commit comments

Comments
 (0)