Skip to content

Commit 675ccc0

Browse files
committed
Auto merge of #158342 - jhpratt:rollup-TaDKE5Z, r=jhpratt
Rollup of 35 pull requests Successful merges: - #158315 (`rust-analyzer` subtree update) - #158336 (Stop excluding `stdarch` test crates from `rust-src`) - #155739 (Add temporary scope to assert_eq and assert_ne) - #156885 (Fix misattributed type inference error span for index expressions) - #157271 (simplify some `proc_macro` things) - #157419 (move rustc_type_ir Term things to term_kind.rs) - #157883 (Remove strict invariant node_type on hir_type during ty privacy visit) - #157921 (trait solver: Resolve region vars in max universe) - #157960 (delegation: add support for infers in generics) - #157983 (Lift the same-signature restriction for `extern "tail"`) - #158053 (Optimize network address parser) - #158105 (Extract all instance shim variants into new `ShimKind` enum) - #158207 (Resolver: local/external split of `resolve_ident_in_module_non_globs_unadjusted` ) - #158279 (Follow goto and drop when linting unreachable code) - #157527 (Move derive tests into their dedicated folder) - #157807 (don't ice on non-lifetime binders under `-Zassumptions-on-binders`) - #157939 (Reorganize `tests/ui/issues` [8/N]) - #157946 (Make `char::is_private_use` and `char::is_assigned` unstably public) - #158003 (Reorganize `tests/ui/issues` [9/N]) - #158020 (Update mingw-w64 C toolchain) - #158039 (c-variadic: test that we use equality up to free lifetimes) - #158060 (Reorganize `tests/ui/issues` [10/N]) - #158222 (format: ignore println newline in foreign format hints) - #158223 (Move target checking for #[lang] to the attribute parser) - #158252 (Use `cfg_select` in `std::os`) - #158263 (Only load the feature list once in the entire resolver) - #158267 (FromUtf8Error::into_utf8_lossy better example and suggest use) - #158272 (Reorganize `tests/ui/issues` [13/N]) - #158274 (triagebot: Stop pinging myself) - #158282 (slice_split_once: bounds check optimization note) - #158300 (Improve unknown crate_type diagnostic suggestions) - #158304 (mailmap: update mu001999) - #158309 (Update `rustc-literal-escaper` version to `0.0.8`) - #158314 (Fix incorrect unsafe debug assertion in unchecked_div_exact) - #158326 (Add `io::ErrorKind::TooManyOpenFiles`)
2 parents f28ac76 + 81526af commit 675ccc0

364 files changed

Lines changed: 7696 additions & 3819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ Milan Landaverde <milanlandaverde@gmail.com>
491491
mjptree <michael.prantl@hotmail.de>
492492
Ms2ger <ms2ger@gmail.com> <Ms2ger@gmail.com>
493493
msizanoen1 <qtmlabs@protonmail.com>
494-
mu001999 <mu001999@outlook.com> <rcu@live.com>
495494
Mukilan Thiagarajan <mukilanthiagarajan@gmail.com>
496495
Nadrieril Feneanar <Nadrieril@users.noreply.github.com>
497496
Nadrieril Feneanar <Nadrieril@users.noreply.github.com> <nadrieril+rust@gmail.com>
@@ -603,6 +602,7 @@ Robert Habermeier <rphmeier@gmail.com>
603602
Robert Millar <robert.millar@cantab.net>
604603
Roc Yu <rocyu@protonmail.com>
605604
Rohit Joshi <rohitjoshi@users.noreply.github.com> Rohit Joshi <rohit.joshi@capitalone.com>
605+
Roland Xu <rcu@live.com> <mu001999@outlook.com>
606606
Ross Smyth <18294397+RossSmyth@users.noreply.github.com>
607607
Ross Smyth <18294397+RossSmyth@users.noreply.github.com> <crs2017@gmail.com>
608608
Ross Smyth <18294397+RossSmyth@users.noreply.github.com> <rsmyth@electrocraft.com>

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3554,9 +3554,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
35543554

35553555
[[package]]
35563556
name = "rustc-literal-escaper"
3557-
version = "0.0.7"
3557+
version = "0.0.8"
35583558
source = "registry+https://github.com/rust-lang/crates.io-index"
3559-
checksum = "8be87abb9e40db7466e0681dc8ecd9dcfd40360cb10b4c8fe24a7c4c3669b198"
3559+
checksum = "bfe6f213fb658c8fb95baabd5420393438cf5a98d707f5dd701d9197c705f71e"
35603560

35613561
[[package]]
35623562
name = "rustc-main"

compiler/rustc_ast/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2024"
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
99
memchr = "2.7.6"
10-
rustc-literal-escaper = "0.0.7"
10+
rustc-literal-escaper = "0.0.8"
1111
rustc_ast_ir = { path = "../rustc_ast_ir" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_index = { path = "../rustc_index" }

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
194194
return self.generate_delegation_error(span, delegation);
195195
}
196196

197-
let mut generics = self.uplift_delegation_generics(delegation, sig_id, is_method);
197+
let mut generics = self.uplift_delegation_generics(delegation, sig_id);
198198

199199
let (body_id, call_expr_id, unused_target_expr) = self.lower_delegation_body(
200200
delegation,
@@ -404,10 +404,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
404404
hir::InferDelegationSig::Output(self.arena.alloc(hir::DelegationInfo {
405405
call_expr_id,
406406
call_path_res: self.get_resolution_id(call_path_node_id),
407-
child_args_segment_id: generics.child.args_segment_id,
408-
parent_args_segment_id: generics.parent.args_segment_id,
409-
self_ty_id: generics.self_ty_id,
410-
propagate_self_ty: generics.propagate_self_ty,
407+
child_seg_id: generics.child.args_segment_id,
408+
child_seg_id_for_sig: generics.child.segment_id_for_sig(),
409+
parent_seg_id_for_sig: generics.parent.segment_id_for_sig(),
410+
self_ty_propagation_kind: generics.self_ty_propagation_kind,
411411
group_id: {
412412
let id = match source {
413413
DelegationSource::Single => None,
@@ -625,20 +625,40 @@ impl<'hir> LoweringContext<'_, 'hir> {
625625
}),
626626
);
627627

628-
hir::QPath::Resolved(ty, self.arena.alloc(new_path))
629-
}
630-
hir::QPath::TypeRelative(ty, segment) => {
631-
let segment = self.process_segment(span, segment, &mut generics.child);
628+
// Explicitly create `Self` self-type in case of infers or static
629+
// free-to-trait reuses.
630+
let ty = match generics.self_ty_propagation_kind {
631+
Some(hir::DelegationSelfTyPropagationKind::SelfParam) => {
632+
let self_param = generics.parent.generics.find_self_param();
633+
let path = self.create_generic_arg_path(self_param);
634+
let kind = hir::TyKind::Path(path);
635+
636+
let ty = match ty {
637+
Some(ty) => hir::Ty { kind, ..ty.clone() },
638+
None => hir::Ty { kind, hir_id: self.next_id(), span },
639+
};
640+
641+
Some(&*self.arena.alloc(ty))
642+
}
643+
_ => ty,
644+
};
632645

633-
hir::QPath::TypeRelative(ty, self.arena.alloc(segment))
646+
hir::QPath::Resolved(ty, self.arena.alloc(new_path))
634647
}
648+
hir::QPath::TypeRelative(..) => unreachable!("until inherent methods are supported"),
635649
};
636650

637-
generics.self_ty_id = match new_path {
638-
hir::QPath::Resolved(ty, _) => ty,
639-
hir::QPath::TypeRelative(ty, _) => Some(ty),
651+
if let Some(hir::DelegationSelfTyPropagationKind::SelfTy(id)) =
652+
generics.self_ty_propagation_kind.as_mut()
653+
{
654+
*id = match new_path {
655+
hir::QPath::Resolved(ty, _) => {
656+
ty.expect("must contain self type as `SelfTy` propagation kind is specified")
657+
}
658+
hir::QPath::TypeRelative(ty, _) => ty,
659+
}
660+
.hir_id;
640661
}
641-
.map(|ty| ty.hir_id);
642662

643663
let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span));
644664
let args = self.arena.alloc_from_iter(args);
@@ -662,25 +682,38 @@ impl<'hir> LoweringContext<'_, 'hir> {
662682
segment: &hir::PathSegment<'hir>,
663683
result: &mut GenericsGenerationResult<'hir>,
664684
) -> hir::PathSegment<'hir> {
665-
let details = result.generics.args_propagation_details();
666-
667-
// Always uplift generic params, because if they are not empty then they
668-
// should be generated in delegation.
669-
let generics = result.generics.into_hir_generics(self, span);
670-
let segment = if details.should_propagate {
671-
let args = generics.into_generic_args(self, span);
672-
673-
// Needed for better error messages (`trait-impl-wrong-args-count.rs` test).
674-
let args = if args.is_empty() { None } else { Some(args) };
675-
676-
hir::PathSegment { args, ..segment.clone() }
677-
} else {
678-
segment.clone()
679-
};
685+
let infer_indices = result.generics.infer_indices();
686+
result.generics.into_hir_generics(self, span);
687+
688+
let mut segment = segment.clone();
689+
let mut args_iter = result.generics.create_args_iterator();
690+
691+
let new_args = segment
692+
.args
693+
.filter(|args| !args.is_empty())
694+
.map(|args| {
695+
self.arena.alloc_from_iter(args.args.iter().enumerate().map(|(idx, arg)| {
696+
if infer_indices.contains(&idx) {
697+
args_iter.next(self, |_| arg.hir_id()).expect("arg must exist for infer")
698+
} else {
699+
*arg
700+
}
701+
}))
702+
})
703+
.unwrap_or_else(|| self.arena.alloc_from_iter(args_iter.consume_all(self)));
704+
705+
// Needed for better error messages (`trait-impl-wrong-args-count.rs` test).
706+
segment.args = (!new_args.is_empty()).then(|| {
707+
&*self.arena.alloc(hir::GenericArgs {
708+
args: new_args,
709+
constraints: &[],
710+
parenthesized: hir::GenericArgsParentheses::No,
711+
span_ext: segment.args.map_or(span, |args| args.span_ext),
712+
})
713+
});
680714

681-
if details.use_args_in_sig_inheritance {
682-
result.args_segment_id = Some(segment.hir_id);
683-
}
715+
result.args_segment_id = segment.hir_id;
716+
result.use_for_sig_inheritance = !result.generics.is_trait_impl();
684717

685718
segment
686719
}

0 commit comments

Comments
 (0)