Skip to content

Commit ec1393f

Browse files
committed
Auto merge of #118294 - GuillaumeGomez:rollup-ij2bzwt, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #116446 (Yeet `mir::Const::from_anon_const`) - #117871 (remove unused pub fns) - #118017 (rustc_lint: address latent TODO) - #118199 (Remove `HirId` from `QPath::LangItem`) - #118272 (resolve: Avoid clones of `MacroData`) - #118291 (rustdoc-search: clean up some DOM code) Failed merges: - #118201 (Miscellaneous `ObligationCauseCode` cleanups) - #118256 (rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 16087ee + e698de9 commit ec1393f

File tree

46 files changed

+171
-500
lines changed

Some content is hidden

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

46 files changed

+171
-500
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+11-39
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
560560
expr: &'hir hir::Expr<'hir>,
561561
overall_span: Span,
562562
) -> &'hir hir::Expr<'hir> {
563-
let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item, None));
563+
let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item));
564564
self.expr_call(overall_span, constructor, std::slice::from_ref(expr))
565565
}
566566

@@ -614,7 +614,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
614614
// Resume argument type: `ResumeTy`
615615
let unstable_span =
616616
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
617-
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span, None);
617+
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span);
618618
let input_ty = hir::Ty {
619619
hir_id: self.next_id(),
620620
kind: hir::TyKind::Path(resume_ty),
@@ -818,19 +818,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
818818
span,
819819
hir::LangItem::PinNewUnchecked,
820820
arena_vec![self; ref_mut_awaitee],
821-
Some(expr_hir_id),
822821
);
823822
let get_context = self.expr_call_lang_item_fn_mut(
824823
gen_future_span,
825824
hir::LangItem::GetContext,
826825
arena_vec![self; task_context],
827-
Some(expr_hir_id),
828826
);
829827
let call = self.expr_call_lang_item_fn(
830828
span,
831829
hir::LangItem::FuturePoll,
832830
arena_vec![self; new_unchecked, get_context],
833-
Some(expr_hir_id),
834831
);
835832
self.arena.alloc(self.expr_unsafe(call))
836833
};
@@ -843,12 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
843840
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
844841
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
845842
let ready_field = self.single_pat_field(gen_future_span, x_pat);
846-
let ready_pat = self.pat_lang_item_variant(
847-
span,
848-
hir::LangItem::PollReady,
849-
ready_field,
850-
Some(expr_hir_id),
851-
);
843+
let ready_pat = self.pat_lang_item_variant(span, hir::LangItem::PollReady, ready_field);
852844
let break_x = self.with_loop_scope(loop_node_id, move |this| {
853845
let expr_break =
854846
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
@@ -859,12 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
859851

860852
// `::std::task::Poll::Pending => {}`
861853
let pending_arm = {
862-
let pending_pat = self.pat_lang_item_variant(
863-
span,
864-
hir::LangItem::PollPending,
865-
&[],
866-
Some(expr_hir_id),
867-
);
854+
let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
868855
let empty_block = self.expr_block_empty(span);
869856
self.arm(pending_pat, empty_block)
870857
};
@@ -922,7 +909,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
922909
span,
923910
hir::LangItem::IntoFutureIntoFuture,
924911
arena_vec![self; expr],
925-
Some(expr_hir_id),
926912
);
927913

928914
// match <into_future_expr> {
@@ -1379,8 +1365,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13791365
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
13801366
let e1 = self.lower_expr_mut(e1);
13811367
let e2 = self.lower_expr_mut(e2);
1382-
let fn_path =
1383-
hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span), None);
1368+
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
13841369
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
13851370
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
13861371
}
@@ -1421,7 +1406,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14211406
);
14221407

14231408
hir::ExprKind::Struct(
1424-
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span), None)),
1409+
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
14251410
fields,
14261411
None,
14271412
)
@@ -1590,7 +1575,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
15901575
head_span,
15911576
hir::LangItem::IteratorNext,
15921577
arena_vec![self; ref_mut_iter],
1593-
None,
15941578
);
15951579
let arms = arena_vec![self; none_arm, some_arm];
15961580

@@ -1619,7 +1603,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
16191603
head_span,
16201604
hir::LangItem::IntoIterIntoIter,
16211605
arena_vec![self; head],
1622-
None,
16231606
)
16241607
};
16251608

@@ -1675,7 +1658,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
16751658
unstable_span,
16761659
hir::LangItem::TryTraitBranch,
16771660
arena_vec![self; sub_expr],
1678-
None,
16791661
)
16801662
};
16811663

@@ -1880,9 +1862,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
18801862
span: Span,
18811863
lang_item: hir::LangItem,
18821864
args: &'hir [hir::Expr<'hir>],
1883-
hir_id: Option<hir::HirId>,
18841865
) -> hir::Expr<'hir> {
1885-
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item, hir_id));
1866+
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item));
18861867
self.expr_call_mut(span, path, args)
18871868
}
18881869

@@ -1891,21 +1872,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
18911872
span: Span,
18921873
lang_item: hir::LangItem,
18931874
args: &'hir [hir::Expr<'hir>],
1894-
hir_id: Option<hir::HirId>,
18951875
) -> &'hir hir::Expr<'hir> {
1896-
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args, hir_id))
1876+
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args))
18971877
}
18981878

1899-
fn expr_lang_item_path(
1900-
&mut self,
1901-
span: Span,
1902-
lang_item: hir::LangItem,
1903-
hir_id: Option<hir::HirId>,
1904-
) -> hir::Expr<'hir> {
1905-
self.expr(
1906-
span,
1907-
hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id)),
1908-
)
1879+
fn expr_lang_item_path(&mut self, span: Span, lang_item: hir::LangItem) -> hir::Expr<'hir> {
1880+
self.expr(span, hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))))
19091881
}
19101882

19111883
/// `<LangItem>::name`
@@ -1918,7 +1890,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19181890
let path = hir::ExprKind::Path(hir::QPath::TypeRelative(
19191891
self.arena.alloc(self.ty(
19201892
span,
1921-
hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), None)),
1893+
hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))),
19221894
)),
19231895
self.arena.alloc(hir::PathSegment::new(
19241896
Ident::new(name, span),

compiler/rustc_ast_lowering/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2304,21 +2304,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23042304

23052305
fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
23062306
let field = self.single_pat_field(span, pat);
2307-
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field, None)
2307+
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field)
23082308
}
23092309

23102310
fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
23112311
let field = self.single_pat_field(span, pat);
2312-
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field, None)
2312+
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field)
23132313
}
23142314

23152315
fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
23162316
let field = self.single_pat_field(span, pat);
2317-
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field, None)
2317+
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field)
23182318
}
23192319

23202320
fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
2321-
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[], None)
2321+
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[])
23222322
}
23232323

23242324
fn single_pat_field(
@@ -2341,9 +2341,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23412341
span: Span,
23422342
lang_item: hir::LangItem,
23432343
fields: &'hir [hir::PatField<'hir>],
2344-
hir_id: Option<hir::HirId>,
23452344
) -> &'hir hir::Pat<'hir> {
2346-
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id);
2345+
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span));
23472346
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
23482347
}
23492348

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
445445
&& let hir::ExprKind::Path(hir::QPath::LangItem(
446446
LangItem::IntoIterIntoIter,
447447
_,
448-
_,
449448
)) = call_expr.kind
450449
{
451450
// Do not suggest `.clone()` in a `for` loop, we already suggest borrowing.
@@ -1346,11 +1345,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13461345
// };
13471346
// corresponding to the desugaring of a for loop `for <pat> in <head> { <body> }`.
13481347
if let hir::ExprKind::Call(path, [arg]) = ex.kind
1349-
&& let hir::ExprKind::Path(hir::QPath::LangItem(
1350-
LangItem::IntoIterIntoIter,
1351-
_,
1352-
_,
1353-
)) = path.kind
1348+
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IntoIterIntoIter, _)) =
1349+
path.kind
13541350
&& arg.span.contains(self.issue_span)
13551351
{
13561352
// Find `IntoIterator::into_iter(<head>)`
@@ -1368,10 +1364,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13681364
..
13691365
}) = stmt.kind
13701366
&& let hir::ExprKind::Call(path, _args) = call.kind
1371-
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _, _)) =
1367+
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _)) =
13721368
path.kind
13731369
&& let hir::PatKind::Struct(path, [field, ..], _) = bind.pat.kind
1374-
&& let hir::QPath::LangItem(LangItem::OptionSome, pat_span, _) = path
1370+
&& let hir::QPath::LangItem(LangItem::OptionSome, pat_span) = path
13751371
&& call.span.contains(self.issue_span)
13761372
{
13771373
// Find `<pat>` and the span for the whole `for` loop.

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-7
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,6 @@ extern "C" {
891891
pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
892892
pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
893893
pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
894-
pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
895894

896895
// Operations on constants of any type
897896
pub fn LLVMConstNull(Ty: &Type) -> &Value;
@@ -955,7 +954,6 @@ extern "C" {
955954
pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
956955
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
957956
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
958-
pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
959957
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
960958

961959
// Operations on global variables, functions, and aliases (globals)
@@ -2346,11 +2344,6 @@ extern "C" {
23462344
len: usize,
23472345
Identifier: *const c_char,
23482346
) -> Option<&Module>;
2349-
pub fn LLVMRustGetBitcodeSliceFromObjectData(
2350-
Data: *const u8,
2351-
len: usize,
2352-
out_len: &mut usize,
2353-
) -> *const u8;
23542347
pub fn LLVMRustGetSliceFromObjectDataByName(
23552348
data: *const u8,
23562349
len: usize,

compiler/rustc_codegen_llvm/src/type_.rs

-4
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
227227
}
228228

229229
impl Type {
230-
pub fn i8_llcx(llcx: &llvm::Context) -> &Type {
231-
unsafe { llvm::LLVMInt8TypeInContext(llcx) }
232-
}
233-
234230
/// Creates an integer type with the given number of bits, e.g., i24
235231
pub fn ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type {
236232
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }

compiler/rustc_const_eval/src/interpret/projection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ where
256256
}
257257

258258
/// Iterates over all fields of an array. Much more efficient than doing the
259-
/// same by repeatedly calling `operand_index`.
259+
/// same by repeatedly calling `project_index`.
260260
pub fn project_array_fields<'a, P: Projectable<'tcx, M::Provenance>>(
261261
&self,
262262
base: &'a P,
263263
) -> InterpResult<'tcx, ArrayIterator<'tcx, 'a, M::Provenance, P>> {
264264
let abi::FieldsShape::Array { stride, .. } = base.layout().fields else {
265-
span_bug!(self.cur_span(), "operand_array_fields: expected an array layout");
265+
span_bug!(self.cur_span(), "project_array_fields: expected an array layout");
266266
};
267267
let len = base.len(self)?;
268268
let field_layout = base.layout().field(self, 0);

compiler/rustc_const_eval/src/transform/promote_consts.rs

-33
Original file line numberDiff line numberDiff line change
@@ -1023,36 +1023,3 @@ pub fn promote_candidates<'tcx>(
10231023

10241024
promotions
10251025
}
1026-
1027-
/// This function returns `true` if the function being called in the array
1028-
/// repeat expression is a `const` function.
1029-
pub fn is_const_fn_in_array_repeat_expression<'tcx>(
1030-
ccx: &ConstCx<'_, 'tcx>,
1031-
place: &Place<'tcx>,
1032-
body: &Body<'tcx>,
1033-
) -> bool {
1034-
match place.as_local() {
1035-
// rule out cases such as: `let my_var = some_fn(); [my_var; N]`
1036-
Some(local) if body.local_decls[local].is_user_variable() => return false,
1037-
None => return false,
1038-
_ => {}
1039-
}
1040-
1041-
for block in body.basic_blocks.iter() {
1042-
if let Some(Terminator { kind: TerminatorKind::Call { func, destination, .. }, .. }) =
1043-
&block.terminator
1044-
{
1045-
if let Operand::Constant(box ConstOperand { const_, .. }) = func {
1046-
if let ty::FnDef(def_id, _) = *const_.ty().kind() {
1047-
if destination == place {
1048-
if ccx.tcx.is_const_fn(def_id) {
1049-
return true;
1050-
}
1051-
}
1052-
}
1053-
}
1054-
}
1055-
}
1056-
1057-
false
1058-
}

compiler/rustc_graphviz/src/lib.rs

-27
Original file line numberDiff line numberDiff line change
@@ -522,33 +522,6 @@ impl<'a> LabelText<'a> {
522522
HtmlStr(ref s) => format!("<{s}>"),
523523
}
524524
}
525-
526-
/// Decomposes content into string suitable for making EscStr that
527-
/// yields same content as self. The result obeys the law
528-
/// render(`lt`) == render(`EscStr(lt.pre_escaped_content())`) for
529-
/// all `lt: LabelText`.
530-
fn pre_escaped_content(self) -> Cow<'a, str> {
531-
match self {
532-
EscStr(s) => s,
533-
LabelStr(s) => {
534-
if s.contains('\\') {
535-
s.escape_default().to_string().into()
536-
} else {
537-
s
538-
}
539-
}
540-
HtmlStr(s) => s,
541-
}
542-
}
543-
544-
/// Puts `suffix` on a line below this label, with a blank line separator.
545-
pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> {
546-
let mut prefix = self.pre_escaped_content().into_owned();
547-
let suffix = suffix.pre_escaped_content();
548-
prefix.push_str(r"\n\n");
549-
prefix.push_str(&suffix);
550-
EscStr(prefix.into())
551-
}
552525
}
553526

554527
pub type Nodes<'a, N> = Cow<'a, [N]>;

compiler/rustc_hir/src/hir.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2058,8 +2058,8 @@ pub enum QPath<'hir> {
20582058
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
20592059
TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
20602060

2061-
/// Reference to a `#[lang = "foo"]` item. `HirId` of the inner expr.
2062-
LangItem(LangItem, Span, Option<HirId>),
2061+
/// Reference to a `#[lang = "foo"]` item.
2062+
LangItem(LangItem, Span),
20632063
}
20642064

20652065
impl<'hir> QPath<'hir> {
@@ -2068,7 +2068,7 @@ impl<'hir> QPath<'hir> {
20682068
match *self {
20692069
QPath::Resolved(_, path) => path.span,
20702070
QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
2071-
QPath::LangItem(_, span, _) => span,
2071+
QPath::LangItem(_, span) => span,
20722072
}
20732073
}
20742074

@@ -2078,7 +2078,7 @@ impl<'hir> QPath<'hir> {
20782078
match *self {
20792079
QPath::Resolved(_, path) => path.span,
20802080
QPath::TypeRelative(qself, _) => qself.span,
2081-
QPath::LangItem(_, span, _) => span,
2081+
QPath::LangItem(_, span) => span,
20822082
}
20832083
}
20842084
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25462546
.map(|(ty, _, _)| ty)
25472547
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
25482548
}
2549-
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
2549+
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span)) => {
25502550
let def_id = tcx.require_lang_item(lang_item, Some(span));
25512551
let (args, _) = self.create_args_for_ast_path(
25522552
span,

0 commit comments

Comments
 (0)