Skip to content

Commit c0f4fee

Browse files
committed
---
yaml --- r: 274805 b: refs/heads/stable c: 78a5d5b h: refs/heads/master i: 274803: 7853c03
1 parent 899a33e commit c0f4fee

File tree

9 files changed

+190
-23
lines changed

9 files changed

+190
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 55dd595c081f76c90f212811ccb55fdf0861784b
32+
refs/heads/stable: 78a5d5b54e0ff91bda8518df7ed9673cc657a4e6
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/compiletest/runtest.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,11 +1229,13 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
12291229
// for the test suite (otherwise including libstd statically in all
12301230
// executables takes up quite a bit of space).
12311231
//
1232-
// For targets like MUSL, however, there is no support for dynamic
1233-
// libraries so we just go back to building a normal library. Note,
1234-
// however, that if the library is built with `force_host` then it's
1235-
// ok to be a dylib as the host should always support dylibs.
1236-
if config.target.contains("musl") && !aux_props.force_host {
1232+
// For targets like MUSL or Emscripten, however, there is no support for
1233+
// dynamic libraries so we just go back to building a normal library. Note,
1234+
// however, that for MUSL if the library is built with `force_host` then
1235+
// it's ok to be a dylib as the host should always support dylibs.
1236+
if (config.target.contains("musl") && !aux_props.force_host) ||
1237+
config.target.contains("emscripten")
1238+
{
12371239
vec!("--crate-type=lib".to_owned())
12381240
} else {
12391241
vec!("--crate-type=dylib".to_owned())

branches/stable/src/librustc_trans/trans/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
265265
// on memory dependencies rather than pointer equality
266266
let interior_unsafe = mt.ty.type_contents(ccx.tcx()).interior_unsafe();
267267

268-
if mt.mutbl == hir::MutMutable || !interior_unsafe {
268+
if mt.mutbl != hir::MutMutable && !interior_unsafe {
269269
attrs.arg(idx, llvm::Attribute::NoAlias);
270270
}
271271

branches/stable/src/libstd/net/addr.rs

Lines changed: 120 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ impl SocketAddr {
6767
}
6868
}
6969

70+
/// Change the IP address associated with this socket address.
71+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
72+
pub fn set_ip(&mut self, new_ip: IpAddr) {
73+
// `match (*self, new_ip)` would have us mutate a copy of self only to throw it away.
74+
match (self, new_ip) {
75+
(&mut SocketAddr::V4(ref mut a), IpAddr::V4(new_ip)) => a.set_ip(new_ip),
76+
(&mut SocketAddr::V6(ref mut a), IpAddr::V6(new_ip)) => a.set_ip(new_ip),
77+
(self_, new_ip) => *self_ = Self::new(new_ip, self_.port()),
78+
}
79+
}
80+
7081
/// Returns the port number associated with this socket address.
7182
#[stable(feature = "rust1", since = "1.0.0")]
7283
pub fn port(&self) -> u16 {
@@ -75,6 +86,15 @@ impl SocketAddr {
7586
SocketAddr::V6(ref a) => a.port(),
7687
}
7788
}
89+
90+
/// Change the port number associated with this socket address.
91+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
92+
pub fn set_port(&mut self, new_port: u16) {
93+
match *self {
94+
SocketAddr::V4(ref mut a) => a.set_port(new_port),
95+
SocketAddr::V6(ref mut a) => a.set_port(new_port),
96+
}
97+
}
7898
}
7999

80100
impl SocketAddrV4 {
@@ -99,9 +119,17 @@ impl SocketAddrV4 {
99119
}
100120
}
101121

122+
/// Change the IP address associated with this socket address.
123+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
124+
pub fn set_ip(&mut self, new_ip: Ipv4Addr) { self.inner.sin_addr = *new_ip.as_inner() }
125+
102126
/// Returns the port number associated with this socket address.
103127
#[stable(feature = "rust1", since = "1.0.0")]
104128
pub fn port(&self) -> u16 { ntoh(self.inner.sin_port) }
129+
130+
/// Change the port number associated with this socket address.
131+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
132+
pub fn set_port(&mut self, new_port: u16) { self.inner.sin_port = hton(new_port) }
105133
}
106134

107135
impl SocketAddrV6 {
@@ -130,19 +158,39 @@ impl SocketAddrV6 {
130158
}
131159
}
132160

161+
/// Change the IP address associated with this socket address.
162+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
163+
pub fn set_ip(&mut self, new_ip: Ipv6Addr) { self.inner.sin6_addr = *new_ip.as_inner() }
164+
133165
/// Returns the port number associated with this socket address.
134166
#[stable(feature = "rust1", since = "1.0.0")]
135167
pub fn port(&self) -> u16 { ntoh(self.inner.sin6_port) }
136168

169+
/// Change the port number associated with this socket address.
170+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
171+
pub fn set_port(&mut self, new_port: u16) { self.inner.sin6_port = hton(new_port) }
172+
137173
/// Returns the flow information associated with this address,
138174
/// corresponding to the `sin6_flowinfo` field in C.
139175
#[stable(feature = "rust1", since = "1.0.0")]
140176
pub fn flowinfo(&self) -> u32 { ntoh(self.inner.sin6_flowinfo) }
141177

178+
/// Change the flow information associated with this socket address.
179+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
180+
pub fn set_flowinfo(&mut self, new_flowinfo: u32) {
181+
self.inner.sin6_flowinfo = hton(new_flowinfo)
182+
}
183+
142184
/// Returns the scope ID associated with this address,
143185
/// corresponding to the `sin6_scope_id` field in C.
144186
#[stable(feature = "rust1", since = "1.0.0")]
145187
pub fn scope_id(&self) -> u32 { ntoh(self.inner.sin6_scope_id) }
188+
189+
/// Change the scope ID associated with this socket address.
190+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
191+
pub fn set_scope_id(&mut self, new_scope_id: u32) {
192+
self.inner.sin6_scope_id = hton(new_scope_id)
193+
}
146194
}
147195

148196
impl FromInner<c::sockaddr_in> for SocketAddrV4 {
@@ -385,16 +433,9 @@ impl ToSocketAddrs for (Ipv6Addr, u16) {
385433
fn resolve_socket_addr(s: &str, p: u16) -> io::Result<vec::IntoIter<SocketAddr>> {
386434
let ips = try!(lookup_host(s));
387435
let v: Vec<_> = try!(ips.map(|a| {
388-
a.map(|a| {
389-
match a {
390-
SocketAddr::V4(ref a) => {
391-
SocketAddr::V4(SocketAddrV4::new(*a.ip(), p))
392-
}
393-
SocketAddr::V6(ref a) => {
394-
SocketAddr::V6(SocketAddrV6::new(*a.ip(), p, a.flowinfo(),
395-
a.scope_id()))
396-
}
397-
}
436+
a.map(|mut a| {
437+
a.set_port(p);
438+
a
398439
})
399440
}).collect());
400441
Ok(v.into_iter())
@@ -511,4 +552,73 @@ mod tests {
511552
fn to_socket_addr_str_bad() {
512553
assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err());
513554
}
555+
556+
#[test]
557+
fn set_ip() {
558+
fn ip4(low: u8) -> Ipv4Addr { Ipv4Addr::new(77, 88, 21, low) }
559+
fn ip6(low: u16) -> Ipv6Addr { Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, low) }
560+
561+
let mut v4 = SocketAddrV4::new(ip4(11), 80);
562+
assert_eq!(v4.ip(), &ip4(11));
563+
v4.set_ip(ip4(12));
564+
assert_eq!(v4.ip(), &ip4(12));
565+
566+
let mut addr = SocketAddr::V4(v4);
567+
assert_eq!(addr.ip(), IpAddr::V4(ip4(12)));
568+
addr.set_ip(IpAddr::V4(ip4(13)));
569+
assert_eq!(addr.ip(), IpAddr::V4(ip4(13)));
570+
addr.set_ip(IpAddr::V6(ip6(14)));
571+
assert_eq!(addr.ip(), IpAddr::V6(ip6(14)));
572+
573+
let mut v6 = SocketAddrV6::new(ip6(1), 80, 0, 0);
574+
assert_eq!(v6.ip(), &ip6(1));
575+
v6.set_ip(ip6(2));
576+
assert_eq!(v6.ip(), &ip6(2));
577+
578+
let mut addr = SocketAddr::V6(v6);
579+
assert_eq!(addr.ip(), IpAddr::V6(ip6(2)));
580+
addr.set_ip(IpAddr::V6(ip6(3)));
581+
assert_eq!(addr.ip(), IpAddr::V6(ip6(3)));
582+
addr.set_ip(IpAddr::V4(ip4(4)));
583+
assert_eq!(addr.ip(), IpAddr::V4(ip4(4)));
584+
}
585+
586+
#[test]
587+
fn set_port() {
588+
let mut v4 = SocketAddrV4::new(Ipv4Addr::new(77, 88, 21, 11), 80);
589+
assert_eq!(v4.port(), 80);
590+
v4.set_port(443);
591+
assert_eq!(v4.port(), 443);
592+
593+
let mut addr = SocketAddr::V4(v4);
594+
assert_eq!(addr.port(), 443);
595+
addr.set_port(8080);
596+
assert_eq!(addr.port(), 8080);
597+
598+
let mut v6 = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 80, 0, 0);
599+
assert_eq!(v6.port(), 80);
600+
v6.set_port(443);
601+
assert_eq!(v6.port(), 443);
602+
603+
let mut addr = SocketAddr::V6(v6);
604+
assert_eq!(addr.port(), 443);
605+
addr.set_port(8080);
606+
assert_eq!(addr.port(), 8080);
607+
}
608+
609+
#[test]
610+
fn set_flowinfo() {
611+
let mut v6 = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 80, 10, 0);
612+
assert_eq!(v6.flowinfo(), 10);
613+
v6.set_flowinfo(20);
614+
assert_eq!(v6.flowinfo(), 20);
615+
}
616+
617+
#[test]
618+
fn set_scope_id() {
619+
let mut v6 = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 80, 0, 10);
620+
assert_eq!(v6.scope_id(), 10);
621+
v6.set_scope_id(20);
622+
assert_eq!(v6.scope_id(), 20);
623+
}
514624
}

branches/stable/src/libstd/sys/unix/fd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ impl FileDesc {
5151
Ok(ret as usize)
5252
}
5353

54-
#[cfg(not(any(target_env = "newlib", target_os = "solaris")))]
54+
#[cfg(not(any(target_env = "newlib", target_os = "solaris", target_os = "emscripten")))]
5555
pub fn set_cloexec(&self) {
5656
unsafe {
5757
let ret = libc::ioctl(self.fd, libc::FIOCLEX);
5858
debug_assert_eq!(ret, 0);
5959
}
6060
}
61-
#[cfg(any(target_env = "newlib", target_os = "solaris"))]
61+
#[cfg(any(target_env = "newlib", target_os = "solaris", target_os = "emscripten"))]
6262
pub fn set_cloexec(&self) {
6363
unsafe {
6464
let previous = libc::fcntl(self.fd, libc::F_GETFD);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="a"]
12+
#![crate_type = "lib"]
13+
14+
pub struct X(pub u8);
15+
16+
impl Drop for X {
17+
fn drop(&mut self) {
18+
assert_eq!(self.0, 1)
19+
}
20+
}
21+
22+
pub fn f(x: &mut X, g: fn()) {
23+
x.0 = 1;
24+
g();
25+
x.0 = 0;
26+
}

branches/stable/src/test/codegen/function-arguments.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ pub fn named_borrow<'r>(_: &'r i32) {
5151
pub fn unsafe_borrow(_: &UnsafeInner) {
5252
}
5353

54-
// CHECK: @mutable_unsafe_borrow(%UnsafeInner* noalias dereferenceable(2))
54+
// CHECK: @mutable_unsafe_borrow(%UnsafeInner* dereferenceable(2))
5555
// ... unless this is a mutable borrow, those never alias
56+
// ... except that there's this LLVM bug that forces us to not use noalias, see #29485
5657
#[no_mangle]
5758
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
5859
}
5960

60-
// CHECK: @mutable_borrow(i32* noalias dereferenceable(4))
61+
// CHECK: @mutable_borrow(i32* dereferenceable(4))
6162
// FIXME #25759 This should also have `nocapture`
63+
// ... there's this LLVM bug that forces us to not use noalias, see #29485
6264
#[no_mangle]
6365
pub fn mutable_borrow(_: &mut i32) {
6466
}
@@ -100,8 +102,9 @@ fn helper(_: usize) {
100102
fn slice(_: &[u8]) {
101103
}
102104

103-
// CHECK: @mutable_slice(i8* noalias nonnull, [[USIZE]])
105+
// CHECK: @mutable_slice(i8* nonnull, [[USIZE]])
104106
// FIXME #25759 This should also have `nocapture`
107+
// ... there's this LLVM bug that forces us to not use noalias, see #29485
105108
#[no_mangle]
106109
fn mutable_slice(_: &mut [u8]) {
107110
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue-29485.rs
12+
13+
#[feature(recover)]
14+
15+
extern crate a;
16+
17+
fn main() {
18+
let _ = std::thread::spawn(move || {
19+
a::f(&mut a::X(0), g);
20+
}).join();
21+
}
22+
23+
fn g() {
24+
panic!();
25+
}

branches/stable/src/test/run-pass/x86stdcall.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ pub fn main() {
3838
target_os = "netbsd",
3939
target_os = "openbsd",
4040
target_os = "android",
41-
target_os = "solaris"))]
41+
target_os = "solaris",
42+
target_os = "emscripten"))]
4243
pub fn main() { }

0 commit comments

Comments
 (0)