Skip to content

Commit 38c560a

Browse files
committed
Auto merge of rust-lang#139881 - matthiaskrgr:rollup-7x6zcrc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#138455 (`librustdoc`: more `impl fmt::Display`) - rust-lang#139818 (Normalize ADT field in `find_tails_for_unsizing`) - rust-lang#139819 (Use `rust-cache` to speed-up `citool` compilation) - rust-lang#139824 (Remove safe remove) - rust-lang#139848 ( Reduce kw::Empty usage, part 5) - rust-lang#139859 (CI: rename MacOS runner) - rust-lang#139877 (Add warning comment to `Take::get_ref` and `Chain::get_ref`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 414da5b + ebaef46 commit 38c560a

File tree

17 files changed

+324
-350
lines changed

17 files changed

+324
-350
lines changed

.github/workflows/ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ jobs:
5353
steps:
5454
- name: Checkout the source code
5555
uses: actions/checkout@v4
56+
# Cache citool to make its build faster, as it's in the critical path.
57+
# The rust-cache doesn't bleed into the main `job`, so it should not affect any other
58+
# Rust compilation.
59+
- name: Cache citool
60+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
61+
with:
62+
workspaces: src/ci/citool
5663
- name: Calculate the CI job matrix
5764
env:
5865
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}

compiler/rustc_ast_lowering/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17651765
ident: Ident,
17661766
is_anon_in_path: IsAnonInPath,
17671767
) -> &'hir hir::Lifetime {
1768-
debug_assert_ne!(ident.name, kw::Empty);
17691768
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
17701769
let res = match res {
17711770
LifetimeRes::Param { param, .. } => hir::LifetimeName::Param(param),

compiler/rustc_hir_typeck/src/expr.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1600,11 +1600,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16001600
Ok(method)
16011601
}
16021602
Err(error) => {
1603-
if segment.ident.name == kw::Empty {
1604-
span_bug!(rcvr.span, "empty method name")
1605-
} else {
1606-
Err(self.report_method_error(expr.hir_id, rcvr_t, error, expected, false))
1607-
}
1603+
Err(self.report_method_error(expr.hir_id, rcvr_t, error, expected, false))
16081604
}
16091605
};
16101606

@@ -2941,9 +2937,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29412937
return Ty::new_error(self.tcx(), guar);
29422938
}
29432939

2944-
let guar = if field.name == kw::Empty {
2945-
self.dcx().span_bug(field.span, "field name with no name")
2946-
} else if self.method_exists_for_diagnostic(
2940+
let guar = if self.method_exists_for_diagnostic(
29472941
field,
29482942
base_ty,
29492943
expr.hir_id,

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ use rustc_middle::ty::{
2727
};
2828
use rustc_middle::{bug, span_bug};
2929
use rustc_session::lint;
30+
use rustc_span::Span;
3031
use rustc_span::def_id::LocalDefId;
3132
use rustc_span::hygiene::DesugaringKind;
32-
use rustc_span::{Span, kw};
3333
use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
3434
use rustc_trait_selection::traits::{
3535
self, NormalizeExt, ObligationCauseCode, StructurallyNormalizeExt,
@@ -833,7 +833,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
833833

834834
let trait_missing_method =
835835
matches!(error, method::MethodError::NoMatch(_)) && ty.normalized.is_trait();
836-
assert_ne!(item_name.name, kw::Empty);
837836
self.report_method_error(
838837
hir_id,
839838
ty.normalized,

compiler/rustc_incremental/src/persist/fs.rs

+6-28
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub(crate) fn prepare_session_directory(sess: &Session, crate_name: Symbol) {
290290

291291
// Try to remove the session directory we just allocated. We don't
292292
// know if there's any garbage in it from the failed copy action.
293-
if let Err(err) = safe_remove_dir_all(&session_dir) {
293+
if let Err(err) = std_fs::remove_dir_all(&session_dir) {
294294
sess.dcx().emit_warn(errors::DeletePartial { path: &session_dir, err });
295295
}
296296

@@ -324,7 +324,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
324324
incr_comp_session_dir.display()
325325
);
326326

327-
if let Err(err) = safe_remove_dir_all(&*incr_comp_session_dir) {
327+
if let Err(err) = std_fs::remove_dir_all(&*incr_comp_session_dir) {
328328
sess.dcx().emit_warn(errors::DeleteFull { path: &incr_comp_session_dir, err });
329329
}
330330

@@ -715,7 +715,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
715715
for directory_name in session_directories {
716716
if !lock_file_to_session_dir.items().any(|(_, dir)| *dir == directory_name) {
717717
let path = crate_directory.join(directory_name);
718-
if let Err(err) = safe_remove_dir_all(&path) {
718+
if let Err(err) = std_fs::remove_dir_all(&path) {
719719
sess.dcx().emit_warn(errors::InvalidGcFailed { path: &path, err });
720720
}
721721
}
@@ -821,7 +821,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
821821
all_except_most_recent(deletion_candidates).into_items().all(|(path, lock)| {
822822
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
823823

824-
if let Err(err) = safe_remove_dir_all(&path) {
824+
if let Err(err) = std_fs::remove_dir_all(&path) {
825825
sess.dcx().emit_warn(errors::FinalizedGcFailed { path: &path, err });
826826
} else {
827827
delete_session_dir_lock_file(sess, &lock_file_path(&path));
@@ -839,7 +839,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
839839
fn delete_old(sess: &Session, path: &Path) {
840840
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
841841

842-
if let Err(err) = safe_remove_dir_all(path) {
842+
if let Err(err) = std_fs::remove_dir_all(path) {
843843
sess.dcx().emit_warn(errors::SessionGcFailed { path, err });
844844
} else {
845845
delete_session_dir_lock_file(sess, &lock_file_path(path));
@@ -862,30 +862,8 @@ fn all_except_most_recent(
862862
}
863863
}
864864

865-
/// Since paths of artifacts within session directories can get quite long, we
866-
/// need to support deleting files with very long paths. The regular
867-
/// WinApi functions only support paths up to 260 characters, however. In order
868-
/// to circumvent this limitation, we canonicalize the path of the directory
869-
/// before passing it to std::fs::remove_dir_all(). This will convert the path
870-
/// into the '\\?\' format, which supports much longer paths.
871-
fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
872-
let canonicalized = match try_canonicalize(p) {
873-
Ok(canonicalized) => canonicalized,
874-
Err(err) if err.kind() == io::ErrorKind::NotFound => return Ok(()),
875-
Err(err) => return Err(err),
876-
};
877-
878-
std_fs::remove_dir_all(canonicalized)
879-
}
880-
881865
fn safe_remove_file(p: &Path) -> io::Result<()> {
882-
let canonicalized = match try_canonicalize(p) {
883-
Ok(canonicalized) => canonicalized,
884-
Err(err) if err.kind() == io::ErrorKind::NotFound => return Ok(()),
885-
Err(err) => return Err(err),
886-
};
887-
888-
match std_fs::remove_file(canonicalized) {
866+
match std_fs::remove_file(p) {
889867
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(()),
890868
result => result,
891869
}

compiler/rustc_monomorphize/src/collector.rs

+32-31
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
688688
let target_ty = self.monomorphize(target_ty);
689689
let source_ty = self.monomorphize(source_ty);
690690
let (source_ty, target_ty) =
691-
find_vtable_types_for_unsizing(self.tcx.at(span), source_ty, target_ty);
691+
find_tails_for_unsizing(self.tcx.at(span), source_ty, target_ty);
692692
// This could also be a different Unsize instruction, like
693693
// from a fixed sized array to a slice. But we are only
694694
// interested in things that produce a vtable.
@@ -1037,36 +1037,35 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) ->
10371037
///
10381038
/// Finally, there is also the case of custom unsizing coercions, e.g., for
10391039
/// smart pointers such as `Rc` and `Arc`.
1040-
fn find_vtable_types_for_unsizing<'tcx>(
1040+
fn find_tails_for_unsizing<'tcx>(
10411041
tcx: TyCtxtAt<'tcx>,
10421042
source_ty: Ty<'tcx>,
10431043
target_ty: Ty<'tcx>,
10441044
) -> (Ty<'tcx>, Ty<'tcx>) {
1045-
let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| {
1046-
let typing_env = ty::TypingEnv::fully_monomorphized();
1047-
if tcx.type_has_metadata(inner_source, typing_env) {
1048-
(inner_source, inner_target)
1049-
} else {
1050-
tcx.struct_lockstep_tails_for_codegen(inner_source, inner_target, typing_env)
1051-
}
1052-
};
1045+
let typing_env = ty::TypingEnv::fully_monomorphized();
1046+
debug_assert!(!source_ty.has_param(), "{source_ty} should be fully monomorphic");
1047+
debug_assert!(!target_ty.has_param(), "{target_ty} should be fully monomorphic");
10531048

10541049
match (source_ty.kind(), target_ty.kind()) {
1055-
(&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(b, _))
1056-
| (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => ptr_vtable(a, b),
1050+
(
1051+
&ty::Ref(_, source_pointee, _),
1052+
&ty::Ref(_, target_pointee, _) | &ty::RawPtr(target_pointee, _),
1053+
)
1054+
| (&ty::RawPtr(source_pointee, _), &ty::RawPtr(target_pointee, _)) => {
1055+
tcx.struct_lockstep_tails_for_codegen(source_pointee, target_pointee, typing_env)
1056+
}
1057+
1058+
// `Box<T>` could go through the ADT code below, b/c it'll unpeel to `Unique<T>`,
1059+
// and eventually bottom out in a raw ref, but we can micro-optimize it here.
10571060
(_, _)
10581061
if let Some(source_boxed) = source_ty.boxed_ty()
10591062
&& let Some(target_boxed) = target_ty.boxed_ty() =>
10601063
{
1061-
ptr_vtable(source_boxed, target_boxed)
1064+
tcx.struct_lockstep_tails_for_codegen(source_boxed, target_boxed, typing_env)
10621065
}
10631066

1064-
// T as dyn* Trait
1065-
(_, &ty::Dynamic(_, _, ty::DynStar)) => ptr_vtable(source_ty, target_ty),
1066-
10671067
(&ty::Adt(source_adt_def, source_args), &ty::Adt(target_adt_def, target_args)) => {
10681068
assert_eq!(source_adt_def, target_adt_def);
1069-
10701069
let CustomCoerceUnsized::Struct(coerce_index) =
10711070
match crate::custom_coerce_unsize_info(tcx, source_ty, target_ty) {
10721071
Ok(ccu) => ccu,
@@ -1075,21 +1074,23 @@ fn find_vtable_types_for_unsizing<'tcx>(
10751074
return (e, e);
10761075
}
10771076
};
1077+
let coerce_field = &source_adt_def.non_enum_variant().fields[coerce_index];
1078+
// We're getting a possibly unnormalized type, so normalize it.
1079+
let source_field =
1080+
tcx.normalize_erasing_regions(typing_env, coerce_field.ty(*tcx, source_args));
1081+
let target_field =
1082+
tcx.normalize_erasing_regions(typing_env, coerce_field.ty(*tcx, target_args));
1083+
find_tails_for_unsizing(tcx, source_field, target_field)
1084+
}
10781085

1079-
let source_fields = &source_adt_def.non_enum_variant().fields;
1080-
let target_fields = &target_adt_def.non_enum_variant().fields;
1081-
1082-
assert!(
1083-
coerce_index.index() < source_fields.len()
1084-
&& source_fields.len() == target_fields.len()
1085-
);
1086+
// `T` as `dyn* Trait` unsizes *directly*.
1087+
//
1088+
// FIXME(dyn_star): This case is a bit awkward, b/c we're not really computing
1089+
// a tail here. We probably should handle this separately in the *caller* of
1090+
// this function, rather than returning something that is semantically different
1091+
// than what we return above.
1092+
(_, &ty::Dynamic(_, _, ty::DynStar)) => (source_ty, target_ty),
10861093

1087-
find_vtable_types_for_unsizing(
1088-
tcx,
1089-
source_fields[coerce_index].ty(*tcx, source_args),
1090-
target_fields[coerce_index].ty(*tcx, target_args),
1091-
)
1092-
}
10931094
_ => bug!(
10941095
"find_vtable_types_for_unsizing: invalid coercion {:?} -> {:?}",
10951096
source_ty,
@@ -1308,7 +1309,7 @@ fn visit_mentioned_item<'tcx>(
13081309
}
13091310
MentionedItem::UnsizeCast { source_ty, target_ty } => {
13101311
let (source_ty, target_ty) =
1311-
find_vtable_types_for_unsizing(tcx.at(span), source_ty, target_ty);
1312+
find_tails_for_unsizing(tcx.at(span), source_ty, target_ty);
13121313
// This could also be a different Unsize instruction, like
13131314
// from a fixed sized array to a slice. But we are only
13141315
// interested in things that produce a vtable.

compiler/rustc_resolve/src/imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10121012
// HACK(eddyb) `lint_if_path_starts_with_module` needs at least
10131013
// 2 segments, so the `resolve_path` above won't trigger it.
10141014
let mut full_path = import.module_path.clone();
1015-
full_path.push(Segment::from_ident(Ident::empty()));
1015+
full_path.push(Segment::from_ident(Ident::dummy()));
10161016
self.lint_if_path_starts_with_module(Some(finalize), &full_path, None);
10171017
}
10181018

compiler/rustc_symbol_mangling/src/v0.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
776776
self.push_disambiguator(
777777
disambiguated_field.disambiguator as u64,
778778
);
779-
self.push_ident(field_name.unwrap_or(kw::Empty).as_str());
779+
self.push_ident(field_name.unwrap().as_str());
780780

781781
field.print(self)?;
782782
}

library/std/src/io/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,10 @@ impl<T, U> Chain<T, U> {
26582658

26592659
/// Gets references to the underlying readers in this `Chain`.
26602660
///
2661+
/// Care should be taken to avoid modifying the internal I/O state of the
2662+
/// underlying readers as doing so may corrupt the internal state of this
2663+
/// `Chain`.
2664+
///
26612665
/// # Examples
26622666
///
26632667
/// ```no_run
@@ -2915,6 +2919,10 @@ impl<T> Take<T> {
29152919

29162920
/// Gets a reference to the underlying reader.
29172921
///
2922+
/// Care should be taken to avoid modifying the internal I/O state of the
2923+
/// underlying reader as doing so may corrupt the internal limit of this
2924+
/// `Take`.
2925+
///
29182926
/// # Examples
29192927
///
29202928
/// ```no_run

src/ci/github-actions/jobs.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ runners:
2323
os: ubuntu-24.04-16core-64gb
2424
<<: *base-job
2525

26-
- &job-macos-xl
27-
os: macos-13 # We use the standard runner for now
26+
- &job-macos
27+
os: macos-13
2828
<<: *base-job
2929

3030
- &job-macos-m1
@@ -380,7 +380,7 @@ auto:
380380
NO_OVERFLOW_CHECKS: 1
381381
DIST_REQUIRE_ALL_TOOLS: 1
382382
CODEGEN_BACKENDS: llvm,cranelift
383-
<<: *job-macos-xl
383+
<<: *job-macos
384384

385385
- name: dist-apple-various
386386
env:
@@ -397,18 +397,18 @@ auto:
397397
NO_LLVM_ASSERTIONS: 1
398398
NO_DEBUG_ASSERTIONS: 1
399399
NO_OVERFLOW_CHECKS: 1
400-
<<: *job-macos-xl
400+
<<: *job-macos
401401

402402
- name: x86_64-apple-1
403403
env:
404404
<<: *env-x86_64-apple-tests
405-
<<: *job-macos-xl
405+
<<: *job-macos
406406

407407
- name: x86_64-apple-2
408408
env:
409409
SCRIPT: ./x.py --stage 2 test tests/ui tests/rustdoc
410410
<<: *env-x86_64-apple-tests
411-
<<: *job-macos-xl
411+
<<: *job-macos
412412

413413
- name: dist-aarch64-apple
414414
env:

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl Item {
517517
Some(RenderedLink {
518518
original_text: s.clone(),
519519
new_text: link_text.clone(),
520-
tooltip: link_tooltip(*id, fragment, cx),
520+
tooltip: link_tooltip(*id, fragment, cx).to_string(),
521521
href,
522522
})
523523
} else {

0 commit comments

Comments
 (0)