Skip to content

Commit 34d481e

Browse files
committed
Auto merge of rust-lang#138326 - jieyouxu:rollup-8p6psb1, r=jieyouxu
Rollup of 16 pull requests Successful merges: - rust-lang#126856 (remove deprecated tool `rls`) - rust-lang#136932 (Reduce formatting `width` and `precision` to 16 bits) - rust-lang#137314 (change definitely unproductive cycles to error) - rust-lang#137612 (Update bootstrap to edition 2024) - rust-lang#138002 (Disable CFI for weakly linked syscalls) - rust-lang#138052 (strip `-Wlinker-messages` wrappers from `rust-lld` rmake test) - rust-lang#138063 (Improve `-Zunpretty=hir` for parsed attrs) - rust-lang#138109 (make precise capturing args in rustdoc Json typed) - rust-lang#138147 (Add maintainers for powerpc64le-unknown-linux-gnu) - rust-lang#138245 (stabilize `ci_rustc_if_unchanged_logic` test for local environments) - rust-lang#138296 (Remove `AdtFlags::IS_ANONYMOUS` and `Copy`/`Clone` condition for anonymous ADT) - rust-lang#138300 (add tracking issue for unqualified_local_imports) - rust-lang#138307 (Allow specifying glob patterns for try jobs) - rust-lang#138313 (Update books) - rust-lang#138315 (use next_back() instead of last() on DoubleEndedIterator) - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9038494 + 3ece708 commit 34d481e

File tree

112 files changed

+1552
-880
lines changed

Some content is hidden

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

112 files changed

+1552
-880
lines changed

Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -3044,13 +3044,6 @@ dependencies = [
30443044
"serde",
30453045
]
30463046

3047-
[[package]]
3048-
name = "rls"
3049-
version = "2.0.0"
3050-
dependencies = [
3051-
"serde_json",
3052-
]
3053-
30543047
[[package]]
30553048
name = "run_make_support"
30563049
version = "0.2.0"

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ members = [
2424
"src/tools/remote-test-server",
2525
"src/tools/rust-installer",
2626
"src/tools/rustdoc",
27-
"src/tools/rls",
2827
"src/tools/rustfmt",
2928
"src/tools/miri",
3029
"src/tools/miri/cargo-miri",

compiler/rustc_ast/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub enum FormatAlignment {
266266
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
267267
pub enum FormatCount {
268268
/// `{:5}` or `{:.5}`
269-
Literal(usize),
269+
Literal(u16),
270270
/// `{:.*}`, `{:.5$}`, or `{:a$}`, etc.
271271
Argument(FormatArgPosition),
272272
}

compiler/rustc_ast_lowering/src/expr.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -2130,26 +2130,24 @@ impl<'hir> LoweringContext<'_, 'hir> {
21302130
self.arena.alloc(self.expr(sp, hir::ExprKind::Tup(&[])))
21312131
}
21322132

2133-
pub(super) fn expr_usize(&mut self, sp: Span, value: usize) -> hir::Expr<'hir> {
2133+
fn expr_uint(&mut self, sp: Span, ty: ast::UintTy, value: u128) -> hir::Expr<'hir> {
21342134
let lit = self.arena.alloc(hir::Lit {
21352135
span: sp,
2136-
node: ast::LitKind::Int(
2137-
(value as u128).into(),
2138-
ast::LitIntType::Unsigned(ast::UintTy::Usize),
2139-
),
2136+
node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ty)),
21402137
});
21412138
self.expr(sp, hir::ExprKind::Lit(lit))
21422139
}
21432140

2141+
pub(super) fn expr_usize(&mut self, sp: Span, value: usize) -> hir::Expr<'hir> {
2142+
self.expr_uint(sp, ast::UintTy::Usize, value as u128)
2143+
}
2144+
21442145
pub(super) fn expr_u32(&mut self, sp: Span, value: u32) -> hir::Expr<'hir> {
2145-
let lit = self.arena.alloc(hir::Lit {
2146-
span: sp,
2147-
node: ast::LitKind::Int(
2148-
u128::from(value).into(),
2149-
ast::LitIntType::Unsigned(ast::UintTy::U32),
2150-
),
2151-
});
2152-
self.expr(sp, hir::ExprKind::Lit(lit))
2146+
self.expr_uint(sp, ast::UintTy::U32, value as u128)
2147+
}
2148+
2149+
pub(super) fn expr_u16(&mut self, sp: Span, value: u16) -> hir::Expr<'hir> {
2150+
self.expr_uint(sp, ast::UintTy::U16, value as u128)
21532151
}
21542152

21552153
pub(super) fn expr_char(&mut self, sp: Span, value: char) -> hir::Expr<'hir> {

compiler/rustc_ast_lowering/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn make_count<'hir>(
292292
hir::LangItem::FormatCount,
293293
sym::Is,
294294
));
295-
let value = ctx.arena.alloc_from_iter([ctx.expr_usize(sp, *n)]);
295+
let value = ctx.arena.alloc_from_iter([ctx.expr_u16(sp, *n)]);
296296
ctx.expr_call_mut(sp, count_is, value)
297297
}
298298
Some(FormatCount::Argument(arg)) => {

compiler/rustc_attr_data_structures/src/lib.rs

+30-22
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,39 @@ pub trait HashStableContext: rustc_ast::HashStableContext + rustc_abi::HashStabl
3535
/// like [`Span`]s and empty tuples, are gracefully skipped so they don't clutter the
3636
/// representation much.
3737
pub trait PrintAttribute {
38-
fn print_something(&self) -> bool;
38+
/// Whether or not this will render as something meaningful, or if it's skipped
39+
/// (which will force the containing struct to also skip printing a comma
40+
/// and the field name).
41+
fn should_render(&self) -> bool;
42+
3943
fn print_attribute(&self, p: &mut Printer);
4044
}
4145

4246
impl<T: PrintAttribute> PrintAttribute for &T {
43-
fn print_something(&self) -> bool {
44-
T::print_something(self)
47+
fn should_render(&self) -> bool {
48+
T::should_render(self)
4549
}
4650

4751
fn print_attribute(&self, p: &mut Printer) {
4852
T::print_attribute(self, p)
4953
}
5054
}
5155
impl<T: PrintAttribute> PrintAttribute for Option<T> {
52-
fn print_something(&self) -> bool {
53-
self.as_ref().is_some_and(|x| x.print_something())
56+
fn should_render(&self) -> bool {
57+
self.as_ref().is_some_and(|x| x.should_render())
5458
}
59+
5560
fn print_attribute(&self, p: &mut Printer) {
5661
if let Some(i) = self {
5762
T::print_attribute(i, p)
5863
}
5964
}
6065
}
6166
impl<T: PrintAttribute> PrintAttribute for ThinVec<T> {
62-
fn print_something(&self) -> bool {
63-
self.is_empty() || self[0].print_something()
67+
fn should_render(&self) -> bool {
68+
self.is_empty() || self[0].should_render()
6469
}
70+
6571
fn print_attribute(&self, p: &mut Printer) {
6672
let mut last_printed = false;
6773
p.word("[");
@@ -70,15 +76,15 @@ impl<T: PrintAttribute> PrintAttribute for ThinVec<T> {
7076
p.word_space(",");
7177
}
7278
i.print_attribute(p);
73-
last_printed = i.print_something();
79+
last_printed = i.should_render();
7480
}
7581
p.word("]");
7682
}
7783
}
7884
macro_rules! print_skip {
7985
($($t: ty),* $(,)?) => {$(
8086
impl PrintAttribute for $t {
81-
fn print_something(&self) -> bool { false }
87+
fn should_render(&self) -> bool { false }
8288
fn print_attribute(&self, _: &mut Printer) { }
8389
})*
8490
};
@@ -87,7 +93,7 @@ macro_rules! print_skip {
8793
macro_rules! print_disp {
8894
($($t: ty),* $(,)?) => {$(
8995
impl PrintAttribute for $t {
90-
fn print_something(&self) -> bool { true }
96+
fn should_render(&self) -> bool { true }
9197
fn print_attribute(&self, p: &mut Printer) {
9298
p.word(format!("{}", self));
9399
}
@@ -97,7 +103,7 @@ macro_rules! print_disp {
97103
macro_rules! print_debug {
98104
($($t: ty),* $(,)?) => {$(
99105
impl PrintAttribute for $t {
100-
fn print_something(&self) -> bool { true }
106+
fn should_render(&self) -> bool { true }
101107
fn print_attribute(&self, p: &mut Printer) {
102108
p.word(format!("{:?}", self));
103109
}
@@ -106,37 +112,39 @@ macro_rules! print_debug {
106112
}
107113

108114
macro_rules! print_tup {
109-
(num_print_something $($ts: ident)*) => { 0 $(+ $ts.print_something() as usize)* };
115+
(num_should_render $($ts: ident)*) => { 0 $(+ $ts.should_render() as usize)* };
110116
() => {};
111117
($t: ident $($ts: ident)*) => {
112118
#[allow(non_snake_case, unused)]
113119
impl<$t: PrintAttribute, $($ts: PrintAttribute),*> PrintAttribute for ($t, $($ts),*) {
114-
fn print_something(&self) -> bool {
120+
fn should_render(&self) -> bool {
115121
let ($t, $($ts),*) = self;
116-
print_tup!(num_print_something $t $($ts)*) != 0
122+
print_tup!(num_should_render $t $($ts)*) != 0
117123
}
118124

119125
fn print_attribute(&self, p: &mut Printer) {
120126
let ($t, $($ts),*) = self;
121-
let parens = print_tup!(num_print_something $t $($ts)*) > 1;
127+
let parens = print_tup!(num_should_render $t $($ts)*) > 1;
122128
if parens {
123-
p.word("(");
129+
p.popen();
124130
}
125131

126-
let mut printed_anything = $t.print_something();
132+
let mut printed_anything = $t.should_render();
127133

128134
$t.print_attribute(p);
129135

130136
$(
131-
if printed_anything && $ts.print_something() {
132-
p.word_space(",");
137+
if $ts.should_render() {
138+
if printed_anything {
139+
p.word_space(",");
140+
}
133141
printed_anything = true;
134142
}
135143
$ts.print_attribute(p);
136144
)*
137145

138146
if parens {
139-
p.word(")");
147+
p.pclose();
140148
}
141149
}
142150
}
@@ -147,8 +155,8 @@ macro_rules! print_tup {
147155

148156
print_tup!(A B C D E F G H);
149157
print_skip!(Span, ());
150-
print_disp!(Symbol, u16, bool, NonZero<u32>);
151-
print_debug!(UintTy, IntTy, Align, AttrStyle, CommentKind, Transparency);
158+
print_disp!(u16, bool, NonZero<u32>);
159+
print_debug!(Symbol, UintTy, IntTy, Align, AttrStyle, CommentKind, Transparency);
152160

153161
/// Finds attributes in sequences of attributes by pattern matching.
154162
///

compiler/rustc_feature/src/unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ declare_features! (
240240
/// Added for testing unstable lints; perma-unstable.
241241
(internal, test_unstable_lint, "1.60.0", None),
242242
/// Helps with formatting for `group_imports = "StdExternalCrate"`.
243-
(unstable, unqualified_local_imports, "1.83.0", None),
243+
(unstable, unqualified_local_imports, "1.83.0", Some(138299)),
244244
/// Use for stable + negative coherence and strict coherence depending on trait's
245245
/// rustc_strict_coherence value.
246246
(unstable, with_negative_coherence, "1.60.0", None),

compiler/rustc_hir/src/hir.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -3368,13 +3368,16 @@ pub struct OpaqueTy<'hir> {
33683368
pub span: Span,
33693369
}
33703370

3371-
#[derive(Debug, Clone, Copy, HashStable_Generic)]
3372-
pub enum PreciseCapturingArg<'hir> {
3373-
Lifetime(&'hir Lifetime),
3371+
#[derive(Debug, Clone, Copy, HashStable_Generic, Encodable, Decodable)]
3372+
pub enum PreciseCapturingArgKind<T, U> {
3373+
Lifetime(T),
33743374
/// Non-lifetime argument (type or const)
3375-
Param(PreciseCapturingNonLifetimeArg),
3375+
Param(U),
33763376
}
33773377

3378+
pub type PreciseCapturingArg<'hir> =
3379+
PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3380+
33783381
impl PreciseCapturingArg<'_> {
33793382
pub fn hir_id(self) -> HirId {
33803383
match self {

compiler/rustc_hir_analysis/src/collect.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_errors::{
2828
use rustc_hir::def::DefKind;
2929
use rustc_hir::def_id::{DefId, LocalDefId};
3030
use rustc_hir::intravisit::{self, InferKind, Visitor, VisitorExt, walk_generics};
31-
use rustc_hir::{self as hir, GenericParamKind, HirId, Node};
31+
use rustc_hir::{self as hir, GenericParamKind, HirId, Node, PreciseCapturingArgKind};
3232
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
3333
use rustc_infer::traits::ObligationCause;
3434
use rustc_middle::hir::nested_filter;
@@ -1792,7 +1792,7 @@ fn opaque_ty_origin<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> hir::OpaqueT
17921792
fn rendered_precise_capturing_args<'tcx>(
17931793
tcx: TyCtxt<'tcx>,
17941794
def_id: LocalDefId,
1795-
) -> Option<&'tcx [Symbol]> {
1795+
) -> Option<&'tcx [PreciseCapturingArgKind<Symbol, Symbol>]> {
17961796
if let Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) =
17971797
tcx.opt_rpitit_info(def_id.to_def_id())
17981798
{
@@ -1801,7 +1801,12 @@ fn rendered_precise_capturing_args<'tcx>(
18011801

18021802
tcx.hir_node_by_def_id(def_id).expect_opaque_ty().bounds.iter().find_map(|bound| match bound {
18031803
hir::GenericBound::Use(args, ..) => {
1804-
Some(&*tcx.arena.alloc_from_iter(args.iter().map(|arg| arg.name())))
1804+
Some(&*tcx.arena.alloc_from_iter(args.iter().map(|arg| match arg {
1805+
PreciseCapturingArgKind::Lifetime(_) => {
1806+
PreciseCapturingArgKind::Lifetime(arg.name())
1807+
}
1808+
PreciseCapturingArgKind::Param(_) => PreciseCapturingArgKind::Param(arg.name()),
1809+
})))
18051810
}
18061811
_ => None,
18071812
})

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ fn generics_args_err_extend<'a>(
15201520
})
15211521
.collect();
15221522
if args.len() > 1
1523-
&& let Some(span) = args.into_iter().last()
1523+
&& let Some(span) = args.into_iter().next_back()
15241524
{
15251525
err.note(
15261526
"generic arguments are not allowed on both an enum and its variant's path \

compiler/rustc_hir_pretty/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ impl<'a> State<'a> {
118118
self.hardbreak()
119119
}
120120
hir::Attribute::Parsed(pa) => {
121-
self.word("#[attr=\"");
121+
self.word("#[attr = ");
122122
pa.print_attribute(self);
123-
self.word("\")]");
123+
self.word("]");
124124
self.hardbreak()
125125
}
126126
}

compiler/rustc_macros/src/print_attribute.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, Tok
1616
let name = field.ident.as_ref().unwrap();
1717
let string_name = name.to_string();
1818
disps.push(quote! {
19-
if __printed_anything && #name.print_something() {
20-
__p.word_space(",");
19+
if #name.should_render() {
20+
if __printed_anything {
21+
__p.word_space(",");
22+
}
23+
__p.word(#string_name);
24+
__p.word_space(":");
2125
__printed_anything = true;
2226
}
23-
__p.word(#string_name);
24-
__p.word_space(":");
2527
#name.print_attribute(__p);
2628
});
2729
field_names.push(name);
@@ -31,10 +33,11 @@ fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, Tok
3133
quote! { {#(#field_names),*} },
3234
quote! {
3335
__p.word(#string_name);
34-
if true #(&& !#field_names.print_something())* {
36+
if true #(&& !#field_names.should_render())* {
3537
return;
3638
}
3739

40+
__p.nbsp();
3841
__p.word("{");
3942
#(#disps)*
4043
__p.word("}");
@@ -48,8 +51,10 @@ fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, Tok
4851
for idx in 0..fields_unnamed.unnamed.len() {
4952
let name = format_ident!("f{idx}");
5053
disps.push(quote! {
51-
if __printed_anything && #name.print_something() {
52-
__p.word_space(",");
54+
if #name.should_render() {
55+
if __printed_anything {
56+
__p.word_space(",");
57+
}
5358
__printed_anything = true;
5459
}
5560
#name.print_attribute(__p);
@@ -62,13 +67,13 @@ fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, Tok
6267
quote! {
6368
__p.word(#string_name);
6469

65-
if true #(&& !#field_names.print_something())* {
70+
if true #(&& !#field_names.should_render())* {
6671
return;
6772
}
6873

69-
__p.word("(");
74+
__p.popen();
7075
#(#disps)*
71-
__p.word(")");
76+
__p.pclose();
7277
},
7378
quote! { true },
7479
)
@@ -138,7 +143,7 @@ pub(crate) fn print_attribute(input: Structure<'_>) -> TokenStream {
138143
input.gen_impl(quote! {
139144
#[allow(unused)]
140145
gen impl PrintAttribute for @Self {
141-
fn print_something(&self) -> bool { #printed }
146+
fn should_render(&self) -> bool { #printed }
142147
fn print_attribute(&self, __p: &mut rustc_ast_pretty::pp::Printer) { #code }
143148
}
144149
})

compiler/rustc_metadata/src/rmeta/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_abi::{FieldIdx, ReprOptions, VariantIdx};
1010
use rustc_ast::expand::StrippedCfgItem;
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_data_structures::svh::Svh;
13+
use rustc_hir::PreciseCapturingArgKind;
1314
use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap};
1415
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIndex, DefPathHash, StableCrateId};
1516
use rustc_hir::definitions::DefKey;
@@ -440,7 +441,7 @@ define_tables! {
440441
coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
441442
mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
442443
rendered_const: Table<DefIndex, LazyValue<String>>,
443-
rendered_precise_capturing_args: Table<DefIndex, LazyArray<Symbol>>,
444+
rendered_precise_capturing_args: Table<DefIndex, LazyArray<PreciseCapturingArgKind<Symbol, Symbol>>>,
444445
asyncness: Table<DefIndex, ty::Asyncness>,
445446
fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
446447
coroutine_kind: Table<DefIndex, hir::CoroutineKind>,

0 commit comments

Comments
 (0)