Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 88cd2ae

Browse files
committedJul 20, 2024
Auto merge of #128011 - matthiaskrgr:rollup-0vmf75y, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #127720 ([`macro_metavar_expr_concat`] Allow `concat` in repetitions) - #127734 (Windows: move BSD socket shims to netc) - #127752 (Ignore allocation bytes in one more mir-opt test) - #127839 (Fix git safe-directory path for docker images) - #127867 (Add `wasm32-wasip2` to `build-manifest` tool) - #127958 (Cleanup rmake.rs setup in compiletest) - #127975 (Fix trait bounds display) - #128005 (Remove _tls_used hack) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2e6fc42 + 8fe93c9 commit 88cd2ae

File tree

19 files changed

+458
-280
lines changed

19 files changed

+458
-280
lines changed
 

‎compiler/rustc_expand/src/mbe/macro_check.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ fn check_occurrences(
352352
check_ops_is_prefix(psess, node_id, macros, binders, ops, span, name);
353353
}
354354
TokenTree::MetaVarExpr(dl, ref mve) => {
355-
let Some(name) = mve.ident().map(MacroRulesNormalizedIdent::new) else {
356-
return;
357-
};
358-
check_ops_is_prefix(psess, node_id, macros, binders, ops, dl.entire(), name);
355+
mve.for_each_metavar((), |_, ident| {
356+
let name = MacroRulesNormalizedIdent::new(*ident);
357+
check_ops_is_prefix(psess, node_id, macros, binders, ops, dl.entire(), name);
358+
});
359359
}
360360
TokenTree::Delimited(.., ref del) => {
361361
check_nested_occurrences(psess, node_id, &del.tts, macros, binders, ops, guar);

‎compiler/rustc_expand/src/mbe/metavar_expr.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ impl MetaVarExpr {
111111
Ok(rslt)
112112
}
113113

114-
pub(crate) fn ident(&self) -> Option<Ident> {
115-
match *self {
116-
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(ident),
117-
MetaVarExpr::Concat { .. } | MetaVarExpr::Index(..) | MetaVarExpr::Len(..) => None,
114+
pub(crate) fn for_each_metavar<A>(&self, mut aux: A, mut cb: impl FnMut(A, &Ident) -> A) -> A {
115+
match self {
116+
MetaVarExpr::Concat(elems) => {
117+
for elem in elems {
118+
if let MetaVarExprConcatElem::Var(ident) = elem {
119+
aux = cb(aux, ident)
120+
}
121+
}
122+
aux
123+
}
124+
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => cb(aux, ident),
125+
MetaVarExpr::Index(..) | MetaVarExpr::Len(..) => aux,
118126
}
119127
}
120128
}

‎compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -557,17 +557,13 @@ fn lockstep_iter_size(
557557
}
558558
}
559559
TokenTree::MetaVarExpr(_, expr) => {
560-
let default_rslt = LockstepIterSize::Unconstrained;
561-
let Some(ident) = expr.ident() else {
562-
return default_rslt;
563-
};
564-
let name = MacroRulesNormalizedIdent::new(ident);
565-
match lookup_cur_matched(name, interpolations, repeats) {
566-
Some(MatchedSeq(ads)) => {
567-
default_rslt.with(LockstepIterSize::Constraint(ads.len(), name))
568-
}
569-
_ => default_rslt,
570-
}
560+
expr.for_each_metavar(LockstepIterSize::Unconstrained, |lis, ident| {
561+
lis.with(lockstep_iter_size(
562+
&TokenTree::MetaVar(ident.span, *ident),
563+
interpolations,
564+
repeats,
565+
))
566+
})
571567
}
572568
TokenTree::Token(..) => LockstepIterSize::Unconstrained,
573569
}
@@ -695,7 +691,23 @@ fn transcribe_metavar_expr<'a>(
695691
let symbol = match element {
696692
MetaVarExprConcatElem::Ident(elem) => elem.name,
697693
MetaVarExprConcatElem::Literal(elem) => *elem,
698-
MetaVarExprConcatElem::Var(elem) => extract_var_symbol(dcx, *elem, interp)?,
694+
MetaVarExprConcatElem::Var(ident) => {
695+
match matched_from_ident(dcx, *ident, interp)? {
696+
NamedMatch::MatchedSeq(named_matches) => {
697+
let curr_idx = repeats.last().unwrap().0;
698+
match &named_matches[curr_idx] {
699+
// FIXME(c410-f3r) Nested repetitions are unimplemented
700+
MatchedSeq(_) => unimplemented!(),
701+
MatchedSingle(pnr) => {
702+
extract_symbol_from_pnr(dcx, pnr, ident.span)?
703+
}
704+
}
705+
}
706+
NamedMatch::MatchedSingle(pnr) => {
707+
extract_symbol_from_pnr(dcx, pnr, ident.span)?
708+
}
709+
}
710+
}
699711
};
700712
concatenated.push_str(symbol.as_str());
701713
}
@@ -752,41 +764,48 @@ fn transcribe_metavar_expr<'a>(
752764
}
753765

754766
/// Extracts an metavariable symbol that can be an identifier, a token tree or a literal.
755-
fn extract_var_symbol<'a>(
767+
fn extract_symbol_from_pnr<'a>(
756768
dcx: DiagCtxtHandle<'a>,
757-
ident: Ident,
758-
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
769+
pnr: &ParseNtResult,
770+
span_err: Span,
759771
) -> PResult<'a, Symbol> {
760-
if let NamedMatch::MatchedSingle(pnr) = matched_from_ident(dcx, ident, interp)? {
761-
if let ParseNtResult::Ident(nt_ident, is_raw) = pnr {
772+
match pnr {
773+
ParseNtResult::Ident(nt_ident, is_raw) => {
762774
if let IdentIsRaw::Yes = is_raw {
763-
return Err(dcx.struct_span_err(ident.span, RAW_IDENT_ERR));
775+
return Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR));
764776
}
765777
return Ok(nt_ident.name);
766778
}
767-
768-
if let ParseNtResult::Tt(TokenTree::Token(Token { kind, .. }, _)) = pnr {
769-
if let TokenKind::Ident(symbol, is_raw) = kind {
770-
if let IdentIsRaw::Yes = is_raw {
771-
return Err(dcx.struct_span_err(ident.span, RAW_IDENT_ERR));
772-
}
773-
return Ok(*symbol);
774-
}
775-
776-
if let TokenKind::Literal(Lit { kind: LitKind::Str, symbol, suffix: None }) = kind {
777-
return Ok(*symbol);
779+
ParseNtResult::Tt(TokenTree::Token(
780+
Token { kind: TokenKind::Ident(symbol, is_raw), .. },
781+
_,
782+
)) => {
783+
if let IdentIsRaw::Yes = is_raw {
784+
return Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR));
778785
}
786+
return Ok(*symbol);
779787
}
780-
781-
if let ParseNtResult::Nt(nt) = pnr
782-
&& let Nonterminal::NtLiteral(expr) = &**nt
783-
&& let ExprKind::Lit(Lit { kind: LitKind::Str, symbol, suffix: None }) = &expr.kind
788+
ParseNtResult::Tt(TokenTree::Token(
789+
Token {
790+
kind: TokenKind::Literal(Lit { kind: LitKind::Str, symbol, suffix: None }),
791+
..
792+
},
793+
_,
794+
)) => {
795+
return Ok(*symbol);
796+
}
797+
ParseNtResult::Nt(nt)
798+
if let Nonterminal::NtLiteral(expr) = &**nt
799+
&& let ExprKind::Lit(Lit { kind: LitKind::Str, symbol, suffix: None }) =
800+
&expr.kind =>
784801
{
785802
return Ok(*symbol);
786803
}
804+
_ => Err(dcx
805+
.struct_err(
806+
"metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`",
807+
)
808+
.with_note("currently only string literals are supported")
809+
.with_span(span_err)),
787810
}
788-
Err(dcx
789-
.struct_err("metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`")
790-
.with_note("currently only string literals are supported")
791-
.with_span(ident.span))
792811
}

‎library/std/src/sys/pal/windows/c.rs

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use crate::ffi::CStr;
1010
use crate::mem;
11-
use crate::os::raw::{c_char, c_int, c_uint, c_ulong, c_ushort, c_void};
11+
use crate::os::raw::{c_uint, c_ulong, c_ushort, c_void};
1212
use crate::os::windows::io::{AsRawHandle, BorrowedHandle};
1313
use crate::ptr;
1414

@@ -19,12 +19,6 @@ pub use windows_sys::*;
1919

2020
pub type WCHAR = u16;
2121

22-
pub type socklen_t = c_int;
23-
pub type ADDRESS_FAMILY = c_ushort;
24-
pub use FD_SET as fd_set;
25-
pub use LINGER as linger;
26-
pub use TIMEVAL as timeval;
27-
2822
pub const INVALID_HANDLE_VALUE: HANDLE = ::core::ptr::without_provenance_mut(-1i32 as _);
2923

3024
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170
@@ -42,20 +36,6 @@ pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { Ptr: ptr::null_mut() };
4236
pub const OBJ_DONT_REPARSE: u32 = windows_sys::OBJ_DONT_REPARSE as u32;
4337
pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: u32 =
4438
windows_sys::FRS_ERR_SYSVOL_POPULATE_TIMEOUT as u32;
45-
pub const AF_INET: c_int = windows_sys::AF_INET as c_int;
46-
pub const AF_INET6: c_int = windows_sys::AF_INET6 as c_int;
47-
48-
#[repr(C)]
49-
pub struct ip_mreq {
50-
pub imr_multiaddr: in_addr,
51-
pub imr_interface: in_addr,
52-
}
53-
54-
#[repr(C)]
55-
pub struct ipv6_mreq {
56-
pub ipv6mr_multiaddr: in6_addr,
57-
pub ipv6mr_interface: c_uint,
58-
}
5939

6040
// Equivalent to the `NT_SUCCESS` C preprocessor macro.
6141
// See: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values
@@ -127,45 +107,6 @@ pub struct MOUNT_POINT_REPARSE_BUFFER {
127107
pub PathBuffer: WCHAR,
128108
}
129109

130-
#[repr(C)]
131-
pub struct SOCKADDR_STORAGE_LH {
132-
pub ss_family: ADDRESS_FAMILY,
133-
pub __ss_pad1: [c_char; 6],
134-
pub __ss_align: i64,
135-
pub __ss_pad2: [c_char; 112],
136-
}
137-
138-
#[repr(C)]
139-
#[derive(Copy, Clone)]
140-
pub struct sockaddr_in {
141-
pub sin_family: ADDRESS_FAMILY,
142-
pub sin_port: c_ushort,
143-
pub sin_addr: in_addr,
144-
pub sin_zero: [c_char; 8],
145-
}
146-
147-
#[repr(C)]
148-
#[derive(Copy, Clone)]
149-
pub struct sockaddr_in6 {
150-
pub sin6_family: ADDRESS_FAMILY,
151-
pub sin6_port: c_ushort,
152-
pub sin6_flowinfo: c_ulong,
153-
pub sin6_addr: in6_addr,
154-
pub sin6_scope_id: c_ulong,
155-
}
156-
157-
#[repr(C)]
158-
#[derive(Copy, Clone)]
159-
pub struct in_addr {
160-
pub s_addr: u32,
161-
}
162-
163-
#[repr(C)]
164-
#[derive(Copy, Clone)]
165-
pub struct in6_addr {
166-
pub s6_addr: [u8; 16],
167-
}
168-
169110
// Desktop specific functions & types
170111
cfg_if::cfg_if! {
171112
if #[cfg(not(target_vendor = "uwp"))] {
@@ -205,42 +146,6 @@ pub unsafe extern "system" fn ReadFileEx(
205146
)
206147
}
207148

208-
// POSIX compatibility shims.
209-
pub unsafe fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int {
210-
windows_sys::recv(socket, buf.cast::<u8>(), len, flags)
211-
}
212-
pub unsafe fn send(socket: SOCKET, buf: *const c_void, len: c_int, flags: c_int) -> c_int {
213-
windows_sys::send(socket, buf.cast::<u8>(), len, flags)
214-
}
215-
pub unsafe fn recvfrom(
216-
socket: SOCKET,
217-
buf: *mut c_void,
218-
len: c_int,
219-
flags: c_int,
220-
addr: *mut SOCKADDR,
221-
addrlen: *mut c_int,
222-
) -> c_int {
223-
windows_sys::recvfrom(socket, buf.cast::<u8>(), len, flags, addr, addrlen)
224-
}
225-
pub unsafe fn sendto(
226-
socket: SOCKET,
227-
buf: *const c_void,
228-
len: c_int,
229-
flags: c_int,
230-
addr: *const SOCKADDR,
231-
addrlen: c_int,
232-
) -> c_int {
233-
windows_sys::sendto(socket, buf.cast::<u8>(), len, flags, addr, addrlen)
234-
}
235-
pub unsafe fn getaddrinfo(
236-
node: *const c_char,
237-
service: *const c_char,
238-
hints: *const ADDRINFOA,
239-
res: *mut *mut ADDRINFOA,
240-
) -> c_int {
241-
windows_sys::getaddrinfo(node.cast::<u8>(), service.cast::<u8>(), hints, res)
242-
}
243-
244149
cfg_if::cfg_if! {
245150
if #[cfg(not(target_vendor = "uwp"))] {
246151
pub unsafe fn NtReadFile(

‎library/std/src/sys/pal/windows/c/bindings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,7 @@ Windows.Win32.Networking.WinSock.SOCK_RDM
20592059
Windows.Win32.Networking.WinSock.SOCK_SEQPACKET
20602060
Windows.Win32.Networking.WinSock.SOCK_STREAM
20612061
Windows.Win32.Networking.WinSock.SOCKADDR
2062+
Windows.Win32.Networking.WinSock.SOCKADDR_STORAGE
20622063
Windows.Win32.Networking.WinSock.SOCKADDR_UN
20632064
Windows.Win32.Networking.WinSock.SOCKET
20642065
Windows.Win32.Networking.WinSock.SOCKET_ERROR

‎library/std/src/sys/pal/windows/c/windows_sys.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,14 @@ pub struct SOCKADDR {
28902890
}
28912891
#[repr(C)]
28922892
#[derive(Clone, Copy)]
2893+
pub struct SOCKADDR_STORAGE {
2894+
pub ss_family: ADDRESS_FAMILY,
2895+
pub __ss_pad1: [i8; 6],
2896+
pub __ss_align: i64,
2897+
pub __ss_pad2: [i8; 112],
2898+
}
2899+
#[repr(C)]
2900+
#[derive(Clone, Copy)]
28932901
pub struct SOCKADDR_UN {
28942902
pub sun_family: ADDRESS_FAMILY,
28952903
pub sun_path: [i8; 108],

‎library/std/src/sys/pal/windows/net.rs

Lines changed: 99 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,100 @@ use crate::time::Duration;
1717

1818
use core::ffi::{c_int, c_long, c_ulong, c_ushort};
1919

20+
#[allow(non_camel_case_types)]
2021
pub type wrlen_t = i32;
2122

2223
pub mod netc {
23-
pub use crate::sys::c::ADDRESS_FAMILY as sa_family_t;
24-
pub use crate::sys::c::ADDRINFOA as addrinfo;
25-
pub use crate::sys::c::SOCKADDR as sockaddr;
26-
pub use crate::sys::c::SOCKADDR_STORAGE_LH as sockaddr_storage;
27-
pub use crate::sys::c::*;
24+
//! BSD socket compatibility shim
25+
//!
26+
//! Some Windows API types are not quite what's expected by our cross-platform
27+
//! net code. E.g. naming differences or different pointer types.
28+
use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET};
29+
use core::ffi::{c_char, c_int, c_uint, c_ulong, c_ushort, c_void};
30+
31+
// re-exports from Windows API bindings.
32+
pub use crate::sys::c::{
33+
bind, connect, freeaddrinfo, getpeername, getsockname, getsockopt, listen, setsockopt,
34+
ADDRESS_FAMILY as sa_family_t, ADDRINFOA as addrinfo, IPPROTO_IP, IPPROTO_IPV6,
35+
IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_MULTICAST_LOOP, IPV6_V6ONLY,
36+
IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_TTL,
37+
SOCKADDR as sockaddr, SOCKADDR_STORAGE as sockaddr_storage, SOCK_DGRAM, SOCK_STREAM,
38+
SOL_SOCKET, SO_BROADCAST, SO_RCVTIMEO, SO_SNDTIMEO,
39+
};
40+
41+
#[allow(non_camel_case_types)]
42+
pub type socklen_t = c_int;
43+
44+
pub const AF_INET: i32 = c::AF_INET as i32;
45+
pub const AF_INET6: i32 = c::AF_INET6 as i32;
46+
47+
// The following two structs use a union in the generated bindings but
48+
// our cross-platform code expects a normal field so it's redefined here.
49+
// As a consequence, we also need to redefine other structs that use this struct.
50+
#[repr(C)]
51+
#[derive(Copy, Clone)]
52+
pub struct in_addr {
53+
pub s_addr: u32,
54+
}
55+
56+
#[repr(C)]
57+
#[derive(Copy, Clone)]
58+
pub struct in6_addr {
59+
pub s6_addr: [u8; 16],
60+
}
61+
62+
#[repr(C)]
63+
pub struct ip_mreq {
64+
pub imr_multiaddr: in_addr,
65+
pub imr_interface: in_addr,
66+
}
67+
68+
#[repr(C)]
69+
pub struct ipv6_mreq {
70+
pub ipv6mr_multiaddr: in6_addr,
71+
pub ipv6mr_interface: c_uint,
72+
}
73+
74+
#[repr(C)]
75+
#[derive(Copy, Clone)]
76+
pub struct sockaddr_in {
77+
pub sin_family: ADDRESS_FAMILY,
78+
pub sin_port: c_ushort,
79+
pub sin_addr: in_addr,
80+
pub sin_zero: [c_char; 8],
81+
}
82+
83+
#[repr(C)]
84+
#[derive(Copy, Clone)]
85+
pub struct sockaddr_in6 {
86+
pub sin6_family: ADDRESS_FAMILY,
87+
pub sin6_port: c_ushort,
88+
pub sin6_flowinfo: c_ulong,
89+
pub sin6_addr: in6_addr,
90+
pub sin6_scope_id: c_ulong,
91+
}
92+
93+
pub unsafe fn send(socket: SOCKET, buf: *const c_void, len: c_int, flags: c_int) -> c_int {
94+
unsafe { c::send(socket, buf.cast::<u8>(), len, flags) }
95+
}
96+
pub unsafe fn sendto(
97+
socket: SOCKET,
98+
buf: *const c_void,
99+
len: c_int,
100+
flags: c_int,
101+
addr: *const SOCKADDR,
102+
addrlen: c_int,
103+
) -> c_int {
104+
unsafe { c::sendto(socket, buf.cast::<u8>(), len, flags, addr, addrlen) }
105+
}
106+
pub unsafe fn getaddrinfo(
107+
node: *const c_char,
108+
service: *const c_char,
109+
hints: *const ADDRINFOA,
110+
res: *mut *mut ADDRINFOA,
111+
) -> c_int {
112+
unsafe { c::getaddrinfo(node.cast::<u8>(), service.cast::<u8>(), hints, res) }
113+
}
28114
}
29115

30116
pub struct Socket(OwnedSocket);
@@ -102,8 +188,8 @@ where
102188
impl Socket {
103189
pub fn new(addr: &SocketAddr, ty: c_int) -> io::Result<Socket> {
104190
let family = match *addr {
105-
SocketAddr::V4(..) => c::AF_INET,
106-
SocketAddr::V6(..) => c::AF_INET6,
191+
SocketAddr::V4(..) => netc::AF_INET,
192+
SocketAddr::V6(..) => netc::AF_INET6,
107193
};
108194
let socket = unsafe {
109195
c::WSASocketW(
@@ -157,7 +243,7 @@ impl Socket {
157243
return Err(io::Error::ZERO_TIMEOUT);
158244
}
159245

160-
let mut timeout = c::timeval {
246+
let mut timeout = c::TIMEVAL {
161247
tv_sec: cmp::min(timeout.as_secs(), c_long::MAX as u64) as c_long,
162248
tv_usec: timeout.subsec_micros() as c_long,
163249
};
@@ -167,7 +253,7 @@ impl Socket {
167253
}
168254

169255
let fds = {
170-
let mut fds = unsafe { mem::zeroed::<c::fd_set>() };
256+
let mut fds = unsafe { mem::zeroed::<c::FD_SET>() };
171257
fds.fd_count = 1;
172258
fds.fd_array[0] = self.as_raw();
173259
fds
@@ -295,8 +381,8 @@ impl Socket {
295381
buf: &mut [u8],
296382
flags: c_int,
297383
) -> io::Result<(usize, SocketAddr)> {
298-
let mut storage = unsafe { mem::zeroed::<c::SOCKADDR_STORAGE_LH>() };
299-
let mut addrlen = mem::size_of_val(&storage) as c::socklen_t;
384+
let mut storage = unsafe { mem::zeroed::<c::SOCKADDR_STORAGE>() };
385+
let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t;
300386
let length = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
301387

302388
// On unix when a socket is shut down all further reads return 0, so we
@@ -399,7 +485,7 @@ impl Socket {
399485
}
400486

401487
pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
402-
let linger = c::linger {
488+
let linger = c::LINGER {
403489
l_onoff: linger.is_some() as c_ushort,
404490
l_linger: linger.unwrap_or_default().as_secs() as c_ushort,
405491
};
@@ -408,7 +494,7 @@ impl Socket {
408494
}
409495

410496
pub fn linger(&self) -> io::Result<Option<Duration>> {
411-
let val: c::linger = net::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
497+
let val: c::LINGER = net::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
412498

413499
Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64)))
414500
}

‎library/std/src/sys/thread_local/guard/windows.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ pub fn enable() {
7878
pub static CALLBACK: unsafe extern "system" fn(*mut c_void, u32, *mut c_void) = tls_callback;
7979

8080
unsafe extern "system" fn tls_callback(_h: *mut c_void, dw_reason: u32, _pv: *mut c_void) {
81-
// See comments above for what this is doing. Note that we don't need this
82-
// trickery on GNU windows, just on MSVC.
83-
#[cfg(all(target_env = "msvc", not(target_thread_local)))]
84-
{
85-
extern "C" {
86-
static _tls_used: u8;
87-
}
88-
89-
unsafe {
90-
ptr::from_ref(&_tls_used).read_volatile();
91-
}
92-
}
93-
9481
if dw_reason == c::DLL_THREAD_DETACH || dw_reason == c::DLL_PROCESS_DETACH {
9582
#[cfg(target_thread_local)]
9683
unsafe {

‎src/ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [ "$NO_CHANGE_USER" = "" ]; then
1919
# already be running with the right user.
2020
#
2121
# For NO_CHANGE_USER done in the small number of Dockerfiles affected.
22-
echo -e '[safe]\n\tdirectory = *' > /home/user/gitconfig
22+
echo -e '[safe]\n\tdirectory = *' > /home/user/.gitconfig
2323

2424
exec su --preserve-environment -c "env PATH=$PATH \"$0\"" user
2525
fi

‎src/librustdoc/html/render/print_item.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,16 +2062,23 @@ pub(super) fn item_path(ty: ItemType, name: &str) -> String {
20622062

20632063
fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool, cx: &Context<'_>) -> String {
20642064
let mut bounds = String::new();
2065-
if !t_bounds.is_empty() {
2066-
if !trait_alias {
2065+
if t_bounds.is_empty() {
2066+
return bounds;
2067+
}
2068+
let has_lots_of_bounds = t_bounds.len() > 2;
2069+
let inter_str = if has_lots_of_bounds { "\n + " } else { " + " };
2070+
if !trait_alias {
2071+
if has_lots_of_bounds {
2072+
bounds.push_str(":\n ");
2073+
} else {
20672074
bounds.push_str(": ");
20682075
}
2069-
for (i, p) in t_bounds.iter().enumerate() {
2070-
if i > 0 {
2071-
bounds.push_str(" + ");
2072-
}
2073-
bounds.push_str(&p.print(cx).to_string());
2076+
}
2077+
for (i, p) in t_bounds.iter().enumerate() {
2078+
if i > 0 {
2079+
bounds.push_str(inter_str);
20742080
}
2081+
bounds.push_str(&p.print(cx).to_string());
20752082
}
20762083
bounds
20772084
}

‎src/tools/build-manifest/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static TARGETS: &[&str] = &[
157157
"wasm32-wasi",
158158
"wasm32-wasip1",
159159
"wasm32-wasip1-threads",
160+
"wasm32-wasip2",
160161
"x86_64-apple-darwin",
161162
"x86_64-apple-ios",
162163
"x86_64-fortanix-unknown-sgx",

‎src/tools/compiletest/src/common.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,14 @@ pub fn output_testname_unique(
760760
/// test/revision should reside. Example:
761761
/// /path/to/build/host-triple/test/ui/relative/testname.revision.mode/
762762
pub fn output_base_dir(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> PathBuf {
763-
output_relative_path(config, &testpaths.relative_dir)
764-
.join(output_testname_unique(config, testpaths, revision))
763+
// In run-make tests, constructing a relative path + unique testname causes a double layering
764+
// since revisions are not supported, causing unnecessary nesting.
765+
if config.mode == Mode::RunMake {
766+
output_relative_path(config, &testpaths.relative_dir)
767+
} else {
768+
output_relative_path(config, &testpaths.relative_dir)
769+
.join(output_testname_unique(config, testpaths, revision))
770+
}
765771
}
766772

767773
/// Absolute path to the base filename used as output for the given

‎src/tools/compiletest/src/runtest.rs

Lines changed: 178 additions & 90 deletions
Large diffs are not rendered by default.

‎tests/mir-opt/dataflow-const-prop/aggregate_copy.foo.DataflowConstProp.diff

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@
5757
StorageDead(_1);
5858
return;
5959
}
60-
+ }
61-
+
62-
+ ALLOC0 (size: 8, align: 4) {
63-
+ 05 00 00 00 03 00 00 00 │ ........
6460
}
61+
+
62+
+ ALLOC0 (size: 8, align: 4) { .. }
6563

‎tests/mir-opt/dataflow-const-prop/aggregate_copy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Verify that we manage to propagate the value of aggregate `a` even without directly mentioning
22
//! the contained scalars.
33
//@ test-mir-pass: DataflowConstProp
4+
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
45

56
const Foo: (u32, u32) = (5, 3);
67

‎tests/rustdoc-gui/src/test_docs/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,9 @@ pub mod private {
614614
B,
615615
}
616616
}
617+
618+
pub mod trait_bounds {
619+
pub trait OneBound: Sized {}
620+
pub trait TwoBounds: Sized + Copy {}
621+
pub trait ThreeBounds: Sized + Copy + Eq {}
622+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Check that if a trait has more than 2 bounds, they are displayed on different lines.
2+
3+
// It tries to load a JS for each trait but there are none since they're not implemented.
4+
fail-on-request-error: false
5+
go-to: "file://" + |DOC_PATH| + "/test_docs/trait_bounds/trait.OneBound.html"
6+
// They should have the same Y position.
7+
compare-elements-position: (
8+
".item-decl code",
9+
".item-decl a.trait[title='trait core::marker::Sized']",
10+
["y"],
11+
)
12+
go-to: "file://" + |DOC_PATH| + "/test_docs/trait_bounds/trait.TwoBounds.html"
13+
// They should have the same Y position.
14+
compare-elements-position: (
15+
".item-decl code",
16+
".item-decl a.trait[title='trait core::marker::Copy']",
17+
["y"],
18+
)
19+
go-to: "file://" + |DOC_PATH| + "/test_docs/trait_bounds/trait.ThreeBounds.html"
20+
// All on their own line.
21+
compare-elements-position-false: (
22+
".item-decl code",
23+
".item-decl a.trait[title='trait core::marker::Sized']",
24+
["y"],
25+
)
26+
compare-elements-position-false: (
27+
".item-decl a.trait[title='trait core::marker::Sized']",
28+
".item-decl a.trait[title='trait core::marker::Copy']",
29+
["y"],
30+
)
31+
compare-elements-position-false: (
32+
".item-decl a.trait[title='trait core::marker::Copy']",
33+
".item-decl a.trait[title='trait core::cmp::Eq']",
34+
["y"],
35+
)

‎tests/rustdoc-gui/type-declation-overflow.goml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,38 @@ fail-on-request-error: false
88

99
go-to: "file://" + |DOC_PATH| + "/lib2/long_trait/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.html"
1010
// We set a fixed size so there is no chance of "random" resize.
11-
set-window-size: (1100, 800)
11+
set-window-size: (710, 800)
1212
// Logically, the <body> scroll width should be the width of the window.
13-
assert-property: ("body", {"scrollWidth": "1100"})
14-
// However, since there is overflow in the type declaration, its scroll width is bigger.
15-
assert-property: ("pre.item-decl", {"scrollWidth": "1324"})
13+
assert-property: ("body", {"scrollWidth": "710"})
14+
// We now check that the section width hasn't grown because of it.
15+
assert-property: ("#main-content", {"scrollWidth": "450"})
16+
// However, since there is overflow in the type declaration, its scroll width is bigger that "#main-content".
17+
assert-property: ("pre.item-decl", {"scrollWidth": "585"})
1618

1719
// In the table-ish view on the module index, the name should not be wrapped more than necessary.
1820
go-to: "file://" + |DOC_PATH| + "/lib2/too_long/index.html"
1921

2022
// We'll ensure that items with short documentation have the same width.
2123
store-property: ("//*[@class='item-table']//*[@class='struct']/..", {"offsetWidth": offset_width})
22-
assert: |offset_width| == "277"
24+
assert: |offset_width| == "149"
2325
assert-property: ("//*[@class='item-table']//*[@class='constant']/..", {"offsetWidth": |offset_width|})
2426

2527
// We now make the same check on type declaration...
2628
go-to: "file://" + |DOC_PATH| + "/lib2/too_long/type.ReallyLongTypeNameLongLongLong.html"
27-
assert-property: ("body", {"scrollWidth": "1100"})
29+
assert-property: ("body", {"scrollWidth": "710"})
30+
// Getting the width of the "<main>" element.
31+
assert-property: ("main", {"scrollWidth": "510"})
2832
// We now check that the section width hasn't grown because of it.
29-
assert-property: ("#main-content", {"scrollWidth": "840"})
33+
assert-property: ("#main-content", {"scrollWidth": "450"})
3034
// And now checking that it has scrollable content.
3135
assert-property: ("pre.item-decl", {"scrollWidth": "1103"})
3236

3337
// ... and constant.
3438
// On a sidenote, it also checks that the (very) long title isn't changing the docblock width.
3539
go-to: "file://" + |DOC_PATH| + "/lib2/too_long/constant.ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong.html"
36-
assert-property: ("body", {"scrollWidth": "1100"})
40+
assert-property: ("body", {"scrollWidth": "710"})
3741
// We now check that the section width hasn't grown because of it.
38-
assert-property: ("#main-content", {"scrollWidth": "840"})
42+
assert-property: ("#main-content", {"scrollWidth": "450"})
3943
// And now checking that it has scrollable content.
4044
assert-property: ("pre.item-decl", {"scrollWidth": "950"})
4145

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ run-pass
2+
3+
#![feature(macro_metavar_expr_concat)]
4+
5+
macro_rules! one_rep {
6+
( $($a:ident)* ) => {
7+
$(
8+
const ${concat($a, Z)}: i32 = 3;
9+
)*
10+
};
11+
}
12+
13+
fn main() {
14+
one_rep!(A B C);
15+
assert_eq!(AZ, 3);
16+
assert_eq!(BZ, 3);
17+
assert_eq!(CZ, 3);
18+
}

0 commit comments

Comments
 (0)
Please sign in to comment.