Skip to content

Commit c7bc6b5

Browse files
Make some non-diagnostic-affecting QPath::LangItem into regular qpaths
1 parent d6d7a93 commit c7bc6b5

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
639639
self.lower_span(span),
640640
Some(self.allow_gen_future.clone()),
641641
);
642-
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span);
642+
let resume_ty = self.make_lang_item_qpath(hir::LangItem::ResumeTy, unstable_span);
643643
let input_ty = hir::Ty {
644644
hir_id: self.next_id(),
645645
kind: hir::TyKind::Path(resume_ty),
@@ -771,7 +771,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
771771
self.lower_span(span),
772772
Some(self.allow_gen_future.clone()),
773773
);
774-
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span);
774+
let resume_ty = self.make_lang_item_qpath(hir::LangItem::ResumeTy, unstable_span);
775775
let input_ty = hir::Ty {
776776
hir_id: self.next_id(),
777777
kind: hir::TyKind::Path(resume_ty),
@@ -2087,11 +2087,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
20872087
lang_item: hir::LangItem,
20882088
name: Symbol,
20892089
) -> hir::Expr<'hir> {
2090+
let qpath = self.make_lang_item_qpath(lang_item, self.lower_span(span));
20902091
let path = hir::ExprKind::Path(hir::QPath::TypeRelative(
2091-
self.arena.alloc(self.ty(
2092-
span,
2093-
hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))),
2094-
)),
2092+
self.arena.alloc(self.ty(span, hir::TyKind::Path(qpath))),
20952093
self.arena.alloc(hir::PathSegment::new(
20962094
Ident::new(name, span),
20972095
self.next_id(),

compiler/rustc_ast_lowering/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
766766
self.resolver.get_import_res(id).present_items()
767767
}
768768

769+
fn make_lang_item_qpath(&mut self, lang_item: hir::LangItem, span: Span) -> hir::QPath<'hir> {
770+
hir::QPath::Resolved(None, self.make_lang_item_path(lang_item, span, None))
771+
}
772+
769773
fn make_lang_item_path(
770774
&mut self,
771775
lang_item: hir::LangItem,
@@ -783,7 +787,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
783787
hir_id: self.next_id(),
784788
res,
785789
args,
786-
infer_args: false,
790+
infer_args: args.is_none(),
787791
}]),
788792
})
789793
}

tests/ui/unpretty/flattened-format-args.stdout

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ fn main() {
99
let x = 1;
1010
// Should flatten to println!("a 123 b {x} xyz\n"):
1111
{
12-
::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["a 123 b ",
13-
" xyz\n"],
14-
&[<#[lang = "format_argument"]>::new_display(&x)]));
12+
::std::io::_print(format_arguments::new_v1(&["a 123 b ",
13+
" xyz\n"], &[format_argument::new_display(&x)]));
1514
};
1615
}

0 commit comments

Comments
 (0)