Skip to content

Commit 398b876

Browse files
committed
Auto merge of rust-lang#138348 - Kobzol:rollup-g3yc3vi, r=Kobzol
Rollup of 11 pull requests Successful merges: - rust-lang#135987 (Clarify iterator by_ref docs) - rust-lang#137967 ([AIX] Fix hangs during testing) - rust-lang#138063 (Improve `-Zunpretty=hir` for parsed attrs) - rust-lang#138147 (Add maintainers for powerpc64le-unknown-linux-gnu) - rust-lang#138288 (Document -Z crate-attr) - rust-lang#138300 (add tracking issue for unqualified_local_imports) - rust-lang#138307 (Allow specifying glob patterns for try jobs) - rust-lang#138315 (use next_back() instead of last() on DoubleEndedIterator) - rust-lang#138330 (Remove unnecessary `[lints.rust]` sections.) - rust-lang#138335 (Fix post-merge workflow) - rust-lang#138343 (Enable `f16` tests for `powf`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 705421b + a9760f4 commit 398b876

Some content is hidden

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

52 files changed

+683
-359
lines changed

.github/workflows/post-merge.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cd src/ci/citool
3737
3838
echo "Post-merge analysis result" > output.log
39-
cargo run --release post-merge-analysis ${PARENT_COMMIT} ${{ github.sha }} >> output.log
39+
cargo run --release post-merge-report ${PARENT_COMMIT} ${{ github.sha }} >> output.log
4040
cat output.log
4141
4242
gh pr comment ${HEAD_PR} -F output.log

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_builtin_macros/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name = "rustc_builtin_macros"
33
version = "0.0.0"
44
edition = "2024"
55

6-
7-
[lints.rust]
8-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(llvm_enzyme)'] }
9-
106
[lib]
117
doctest = false
128

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_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_parse/src/parser/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,7 @@ impl<'a> Parser<'a> {
21072107
ast::GenericBound::Trait(poly) => Some(poly),
21082108
_ => None,
21092109
})
2110-
.last()
2110+
.next_back()
21112111
{
21122112
err.span_suggestion_verbose(
21132113
poly.span.shrink_to_hi(),

compiler/rustc_type_ir/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,3 @@ nightly = [
3333
"rustc_index/nightly",
3434
"rustc_ast_ir/nightly",
3535
]
36-
37-
[lints.rust]
38-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)'] }

library/core/src/iter/traits/iterator.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1825,10 +1825,19 @@ pub trait Iterator {
18251825
Inspect::new(self, f)
18261826
}
18271827

1828-
/// Borrows an iterator, rather than consuming it.
1828+
/// Creates a "by reference" adapter for this instance of `Iterator`.
18291829
///
1830-
/// This is useful to allow applying iterator adapters while still
1831-
/// retaining ownership of the original iterator.
1830+
/// Consuming method calls (direct or indirect calls to `next`)
1831+
/// on the "by reference" adapter will consume the original iterator,
1832+
/// but ownership-taking methods (those with a `self` parameter)
1833+
/// only take ownership of the "by reference" iterator.
1834+
///
1835+
/// This is useful for applying ownership-taking methods
1836+
/// (such as `take` in the example below)
1837+
/// without giving up ownership of the original iterator,
1838+
/// so you can use the original iterator afterwards.
1839+
///
1840+
/// Uses [impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#impl-Iterator-for-%26mut+I).
18321841
///
18331842
/// # Examples
18341843
///
@@ -4024,6 +4033,9 @@ where
40244033
}
40254034
}
40264035

4036+
/// Implements `Iterator` for mutable references to iterators, such as those produced by [`Iterator::by_ref`].
4037+
///
4038+
/// This implementation passes all method calls on to the original iterator.
40274039
#[stable(feature = "rust1", since = "1.0.0")]
40284040
impl<I: Iterator + ?Sized> Iterator for &mut I {
40294041
type Item = I::Item;

library/std/src/net/test.rs

+11
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ pub fn tsa<A: ToSocketAddrs>(a: A) -> Result<Vec<SocketAddr>, String> {
3131
Err(e) => Err(e.to_string()),
3232
}
3333
}
34+
35+
pub fn compare_ignore_zoneid(a: &SocketAddr, b: &SocketAddr) -> bool {
36+
match (a, b) {
37+
(SocketAddr::V6(a), SocketAddr::V6(b)) => {
38+
a.ip().segments() == b.ip().segments()
39+
&& a.flowinfo() == b.flowinfo()
40+
&& a.port() == b.port()
41+
}
42+
_ => a == b,
43+
}
44+
}

library/std/src/net/udp/tests.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::net::test::{next_test_ip4, next_test_ip6};
1+
use crate::net::test::{compare_ignore_zoneid, next_test_ip4, next_test_ip6};
22
use crate::net::*;
33
use crate::sync::mpsc::channel;
44
use crate::thread;
@@ -46,7 +46,7 @@ fn socket_smoke_test_ip4() {
4646
let (nread, src) = t!(server.recv_from(&mut buf));
4747
assert_eq!(nread, 1);
4848
assert_eq!(buf[0], 99);
49-
assert_eq!(src, client_ip);
49+
assert_eq!(compare_ignore_zoneid(&src, &client_ip), true);
5050
rx2.recv().unwrap();
5151
})
5252
}
@@ -78,7 +78,9 @@ fn udp_clone_smoke() {
7878

7979
let _t = thread::spawn(move || {
8080
let mut buf = [0, 0];
81-
assert_eq!(sock2.recv_from(&mut buf).unwrap(), (1, addr1));
81+
let res = sock2.recv_from(&mut buf).unwrap();
82+
assert_eq!(res.0, 1);
83+
assert_eq!(compare_ignore_zoneid(&res.1, &addr1), true);
8284
assert_eq!(buf[0], 1);
8385
t!(sock2.send_to(&[2], &addr1));
8486
});
@@ -94,7 +96,9 @@ fn udp_clone_smoke() {
9496
});
9597
tx1.send(()).unwrap();
9698
let mut buf = [0, 0];
97-
assert_eq!(sock1.recv_from(&mut buf).unwrap(), (1, addr2));
99+
let res = sock1.recv_from(&mut buf).unwrap();
100+
assert_eq!(res.0, 1);
101+
assert_eq!(compare_ignore_zoneid(&res.1, &addr2), true);
98102
rx2.recv().unwrap();
99103
})
100104
}

0 commit comments

Comments
 (0)