Skip to content

Commit d6dd2be

Browse files
committed
Remove error recreation
1 parent a561c6a commit d6dd2be

3 files changed

Lines changed: 9 additions & 24 deletions

File tree

compiler/rustc_ast_lowering/src/delegation/mod.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,16 @@ pub(crate) struct DelegationResults<'hir> {
7171
}
7272

7373
impl<'hir> LoweringContext<'_, 'hir> {
74-
pub(crate) fn lower_delegation(
75-
&mut self,
76-
delegation: &Delegation,
77-
item_id: NodeId,
78-
) -> DelegationResults<'hir> {
74+
pub(crate) fn lower_delegation(&mut self, delegation: &Delegation) -> DelegationResults<'hir> {
7975
// Prevent some query cycles with it (`tests\ui\delegation\ice-issue-150673.rs`).
80-
with_no_trimmed_paths!(self.lower_delegation_internal(delegation, item_id))
76+
with_no_trimmed_paths!(self.lower_delegation_internal(delegation))
8177
}
8278

83-
fn lower_delegation_internal(
84-
&mut self,
85-
delegation: &Delegation,
86-
item_id: NodeId,
87-
) -> DelegationResults<'hir> {
79+
fn lower_delegation_internal(&mut self, delegation: &Delegation) -> DelegationResults<'hir> {
8880
let span = self.lower_span(delegation.last_segment_span());
8981

9082
let resolver = DelegationResolverForLowering(self);
91-
let Ok((res, mut generics)) = resolver.resolve_delegation(delegation, span, item_id) else {
83+
let Ok((res, mut generics)) = resolver.resolve_delegation(delegation, span) else {
9284
return self.generate_delegation_error(span, delegation);
9385
};
9486

compiler/rustc_ast_lowering/src/delegation/resolution.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ impl<'tcx, T: LoweringContextForResolution<'tcx>> DelegationResolverForLowering<
9090
&self,
9191
delegation: &Delegation,
9292
span: Span,
93-
item_id: NodeId,
9493
) -> Result<(DelegationResolution<'tcx>, GenericsGenerationResults<'tcx>), ErrorGuaranteed>
9594
{
9695
let tcx = self.0.tcx();
@@ -103,16 +102,10 @@ impl<'tcx, T: LoweringContextForResolution<'tcx>> DelegationResolverForLowering<
103102
));
104103
};
105104

106-
let sig_id = info.resolution_id.and_then(|id| self.check_for_cycles(id, span).map(|_| id));
107-
108105
// Delegation can be missing from the `delegations_resolutions` table
109106
// in illegal places such as function bodies in extern blocks (see #151356).
110-
let Ok(sig_id) = sig_id else {
111-
return Err(tcx.dcx().span_delayed_bug(
112-
span,
113-
format!("LoweringContext: the delegation {:?} is unresolved", item_id),
114-
));
115-
};
107+
let sig_id =
108+
info.resolution_id.and_then(|id| self.check_for_cycles(id, span).map(|_| id))?;
116109

117110
let is_method = match tcx.def_kind(sig_id) {
118111
DefKind::Fn => false,

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
567567
hir::ItemKind::Macro(ident, macro_def, macro_kinds)
568568
}
569569
ItemKind::Delegation(delegation) => {
570-
let delegation_results = self.lower_delegation(delegation, id);
570+
let delegation_results = self.lower_delegation(delegation);
571571
hir::ItemKind::Fn {
572572
sig: delegation_results.sig,
573573
ident: delegation_results.ident,
@@ -1052,7 +1052,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10521052
(*ident, generics, kind, ty.is_some())
10531053
}
10541054
AssocItemKind::Delegation(delegation) => {
1055-
let delegation_results = self.lower_delegation(delegation, i.id);
1055+
let delegation_results = self.lower_delegation(delegation);
10561056
let item_kind = hir::TraitItemKind::Fn(
10571057
delegation_results.sig,
10581058
hir::TraitFn::Provided(delegation_results.body_id),
@@ -1264,7 +1264,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12641264
)
12651265
}
12661266
AssocItemKind::Delegation(delegation) => {
1267-
let delegation_results = self.lower_delegation(delegation, i.id);
1267+
let delegation_results = self.lower_delegation(delegation);
12681268
(
12691269
delegation.ident,
12701270
(

0 commit comments

Comments
 (0)