Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ pub fn struct_lint_level(
(Level::Deny | Level::Forbid, None) => sess.diagnostic().struct_err_lint(""),
};

err.set_primary_message(msg);
err.set_is_lint();

// If this code originates in a foreign macro, aka something that this crate
Expand All @@ -375,6 +374,10 @@ pub fn struct_lint_level(
}
}

// Delay evaluating and setting the primary message until after we've
// suppressed the lint due to macros.
err.set_primary_message(msg);

// Lint diagnostics that are covered by the expect level will not be emitted outside
// the compiler. It is therefore not necessary to add any information for the user.
// This will therefore directly call the decorate function which will in turn emit
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub trait From<T>: Sized {
#[lang = "from"]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
fn from(_: T) -> Self;
fn from(value: T) -> Self;
}

/// An attempted conversion that consumes `self`, which may or may not be
Expand Down
24 changes: 24 additions & 0 deletions library/core/src/future/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ impl<T> Future for Ready<T> {
}
}

impl<T> Ready<T> {
/// Consumes the `Ready`, returning the wrapped value.
///
/// # Panics
///
/// Will panic if this [`Ready`] was already polled to completion.
///
/// # Examples
///
/// ```
/// #![feature(ready_into_inner)]
/// use std::future;
///
/// let a = future::ready(1);
/// assert_eq!(a.into_inner(), 1);
/// ```
#[unstable(feature = "ready_into_inner", issue = "101196")]
#[must_use]
#[inline]
pub fn into_inner(self) -> T {
self.0.expect("Called `into_inner()` on `Ready` after completion")
}
}

/// Creates a future that is immediately ready with a value.
///
/// Futures created through this function are functionally similar to those
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
#![feature(exhaustive_patterns)]
#![feature(if_let_guard)]
#![feature(intra_doc_pointers)]
#![feature(ipv6_hop_limit)]
#![feature(lang_items)]
#![feature(let_chains)]
#![feature(linkage)]
Expand Down
156 changes: 156 additions & 0 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,86 @@ impl TcpStream {
self.0.ttl()
}

/// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket.
///
/// This value sets the unicast hop limit field that is used in every packet
/// sent from this socket.
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpStream;
///
/// let stream = TcpStream::connect("127.0.0.1:54321")
/// .expect("Couldn't connect to the server...");
/// stream.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> {
self.0.set_hop_limit_v6(limit)
}

/// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket.
///
/// For more information about this option, see [`TcpStream::set_hop_limit_v6`].
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpStream;
///
/// let stream = TcpStream::connect("127.0.0.1:54321")
/// .expect("Couldn't connect to the server...");
/// stream.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
/// assert_eq!(stream.hop_limit_v6().unwrap(), 88);
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn hop_limit_v6(&self) -> io::Result<u32> {
self.0.hop_limit_v6()
}

/// Sets the value for the `IPV6_MULTICAST_HOPS` option on this socket.
///
/// This value sets the hop limit field for outgoing multicast packets
/// sent from this socket.
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpStream;
///
/// let stream = TcpStream::connect("127.0.0.1:54321")
/// .expect("Couldn't connect to the server...");
/// stream.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed");
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> {
self.0.set_multicast_hop_limit_v6(limit)
}

/// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket.
///
/// For more information about this option, see [`TcpStream::set_multicast_hop_limit_v6`].
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpStream;
///
/// let stream = TcpStream::connect("127.0.0.1:54321")
/// .expect("Couldn't connect to the server...");
/// stream.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed");
/// assert_eq!(stream.multicast_hop_limit_v6().unwrap(), 88);
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn multicast_hop_limit_v6(&self) -> io::Result<u32> {
self.0.multicast_hop_limit_v6()
}

/// Gets the value of the `SO_ERROR` option on this socket.
///
/// This will retrieve the stored error in the underlying socket, clearing
Expand Down Expand Up @@ -915,6 +995,82 @@ impl TcpListener {
self.0.ttl()
}

/// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket.
///
/// This value sets the unicast hop limit field that is used in every packet
/// sent from this socket.
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpListener;
///
/// let listener = TcpListener::bind("127.0.0.1:54321").unwrap();
/// listener.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> {
self.0.set_hop_limit_v6(limit)
}

/// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket.
///
/// For more information about this option, see [`TcpListener::set_hop_limit_v6`].
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpListener;
///
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
/// listener.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
/// assert_eq!(listener.hop_limit_v6().unwrap(), 88);
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn hop_limit_v6(&self) -> io::Result<u32> {
self.0.hop_limit_v6()
}

/// Sets the value for the `IPV6_MULTICAST_HOPS` option on this socket.
///
/// This value sets the hop limit field for outgoing multicast packets
/// sent from this socket.
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpListener;
///
/// let listener = TcpListener::bind("127.0.0.1:54321").unwrap();
/// listener.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed");
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> {
self.0.set_multicast_hop_limit_v6(limit)
}

/// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket.
///
/// For more information about this option, see [`TcpListener::set_multicast_hop_limit_v6`].
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::TcpListener;
///
/// let listener = TcpListener::bind("127.0.0.1:54321").unwrap();
/// listener.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed");
/// assert_eq!(listener.multicast_hop_limit_v6().unwrap(), 88);
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn multicast_hop_limit_v6(&self) -> io::Result<u32> {
self.0.multicast_hop_limit_v6()
}

#[stable(feature = "net2_mutators", since = "1.9.0")]
#[deprecated(since = "1.16.0", note = "this option can only be set before the socket is bound")]
#[allow(missing_docs)]
Expand Down
17 changes: 17 additions & 0 deletions library/std/src/net/tcp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,23 @@ fn ttl() {
assert_eq!(ttl, t!(stream.ttl()));
}

#[test]
#[cfg_attr(target_env = "sgx", ignore)]
fn hop_limit() {
let hlim: u32 = 100;

let addr = next_test_ip6();
let listener = t!(TcpListener::bind(&addr));

t!(listener.set_hop_limit_v6(hlim));
assert_eq!(hlim, t!(listener.hop_limit_v6()));

let stream = t!(TcpStream::connect(&addr));

t!(stream.set_hop_limit_v6(hlim));
assert_eq!(hlim, t!(stream.hop_limit_v6()));
}

#[test]
#[cfg_attr(target_env = "sgx", ignore)]
fn set_nonblocking() {
Expand Down
76 changes: 76 additions & 0 deletions library/std/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,82 @@ impl UdpSocket {
self.0.ttl()
}

/// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket.
///
/// This value sets the unicast hop limit field that is used in every packet
/// sent from this socket.
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address");
/// socket.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> {
self.0.set_hop_limit_v6(limit)
}

/// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket.
///
/// For more information about this option, see [`UdpSocket::set_hop_limit_v6`].
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address");
/// socket.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
/// assert_eq!(socket.hop_limit_v6().unwrap(), 88);
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn hop_limit_v6(&self) -> io::Result<u32> {
self.0.hop_limit_v6()
}

/// Sets the value for the `IPV6_MULTICAST_HOPS` option on this socket.
///
/// This value sets the hop limit field for outgoing multicast packets
/// sent from this socket.
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address");
/// socket.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed");
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> {
self.0.set_multicast_hop_limit_v6(limit)
}

/// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket.
///
/// For more information about this option, see [`UdpSocket::set_multicast_hop_limit_v6`].
///
/// # Examples
///
/// ```no_run
/// #![feature(ipv6_hop_limit)]
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address");
/// socket.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed");
/// assert_eq!(socket.multicast_hop_limit_v6().unwrap(), 88);
/// ```
#[unstable(feature = "ipv6_hop_limit", issue = "47727")]
pub fn multicast_hop_limit_v6(&self) -> io::Result<u32> {
self.0.multicast_hop_limit_v6()
}

/// Executes an operation of the `IP_ADD_MEMBERSHIP` type.
///
/// This function specifies a new multicast group for this socket to join.
Expand Down
12 changes: 12 additions & 0 deletions library/std/src/net/udp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,18 @@ fn ttl() {
assert_eq!(ttl, t!(stream.ttl()));
}

#[test]
fn hop_limit() {
let hlim = 100;

let addr = next_test_ip6();

let stream = t!(UdpSocket::bind(&addr));

t!(stream.set_hop_limit_v6(hlim));
assert_eq!(hlim, t!(stream.hop_limit_v6()));
}

#[test]
fn set_nonblocking() {
each_ip(&mut |addr, _| {
Expand Down
Loading