Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #87714

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2733,9 +2733,9 @@ dependencies = [

[[package]]
name = "psm"
version = "0.1.11"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96e0536f6528466dbbbbe6b986c34175a8d0ff25b794c4bacda22e068cd2f2c5"
checksum = "14ce37fa8c0428a37307d163292add09b3aedc003472e6b3622486878404191d"
dependencies = [
"cc",
]
Expand Down Expand Up @@ -4810,12 +4810,12 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"

[[package]]
name = "stacker"
version = "0.1.12"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21ccb4c06ec57bc82d0f610f1a2963d7648700e43a6f513e564b9c89f7991786"
checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4"
dependencies = [
"cc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"libc",
"psm",
"winapi",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustc_index = { path = "../rustc_index", package = "rustc_index" }
bitflags = "1.2.1"
measureme = "9.1.0"
libc = "0.2"
stacker = "0.1.12"
stacker = "0.1.14"
tempfile = "3.2"

[dependencies.parking_lot]
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,10 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD

// Closures are handled by their owner, if it has a body
if tcx.is_closure(def.did.to_def_id()) {
let owner = tcx.hir().local_def_id_to_hir_id(def.did).owner;
let owner_hir_id = tcx.hir().local_def_id_to_hir_id(owner);

if tcx.hir().maybe_body_owned_by(owner_hir_id).is_some() {
tcx.ensure().thir_check_unsafety(owner);
return;
}
let hir = tcx.hir();
let owner = hir.enclosing_body_owner(hir.local_def_id_to_hir_id(def.did));
tcx.ensure().thir_check_unsafety(hir.local_def_id(owner));
return;
}

let (thir, expr) = tcx.thir_body(def);
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1714,13 +1714,11 @@ impl<'a> Parser<'a> {
// the AST for typechecking.
err.span_label(ident.span, "while parsing this `fn`");
err.emit();
(Vec::new(), None)
} else {
return Err(err);
}
} else {
unreachable!()
}
(Vec::new(), None)
};
attrs.extend(inner_attrs);
Ok(body)
Expand Down
30 changes: 30 additions & 0 deletions library/std/src/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ impl<T: UnwindSafe> UnwindSafe for SyncOnceCell<T> {}

#[unstable(feature = "once_cell", issue = "74465")]
impl<T> Default for SyncOnceCell<T> {
/// Creates a new empty cell.
///
/// # Example
///
/// ```
/// #![feature(once_cell)]
///
/// use std::lazy::SyncOnceCell;
///
/// fn main() {
/// assert_eq!(SyncOnceCell::<()>::new(), SyncOnceCell::default());
/// }
/// ```
fn default() -> SyncOnceCell<T> {
SyncOnceCell::new()
}
Expand Down Expand Up @@ -118,6 +131,23 @@ impl<T: Clone> Clone for SyncOnceCell<T> {

#[unstable(feature = "once_cell", issue = "74465")]
impl<T> From<T> for SyncOnceCell<T> {
/// Create a new cell with its contents set to `value`.
///
/// # Example
///
/// ```
/// #![feature(once_cell)]
///
/// use std::lazy::SyncOnceCell;
///
/// # fn main() -> Result<(), i32> {
/// let a = SyncOnceCell::from(3);
/// let b = SyncOnceCell::new();
/// b.set(3)?;
/// assert_eq!(a, b);
/// Ok(())
/// # }
/// ```
fn from(value: T) -> Self {
let cell = Self::new();
match cell.set(value) {
Expand Down
45 changes: 45 additions & 0 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,29 @@ impl IpAddr {
pub const fn is_ipv6(&self) -> bool {
matches!(self, IpAddr::V6(_))
}

/// Converts this address to an `IpAddr::V4` if it is a IPv4-mapped IPv6 addresses, otherwise it
/// return `self` as-is.
///
/// # Examples
///
/// ```
/// #![feature(ip)]
/// use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
///
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).to_canonical().is_loopback(), true);
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).is_loopback(), false);
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true);
/// ```
#[inline]
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
pub const fn to_canonical(&self) -> IpAddr {
match self {
&v4 @ IpAddr::V4(_) => v4,
IpAddr::V6(v6) => v6.to_canonical(),
}
}
}

impl Ipv4Addr {
Expand Down Expand Up @@ -1540,6 +1563,28 @@ impl Ipv6Addr {
}
}

/// Converts this address to an `IpAddr::V4` if it is a IPv4-mapped addresses, otherwise it
/// returns self wrapped in a `IpAddr::V6`.
///
/// # Examples
///
/// ```
/// #![feature(ip)]
/// use std::net::Ipv6Addr;
///
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false);
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true);
/// ```
#[inline]
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
pub const fn to_canonical(&self) -> IpAddr {
if let Some(mapped) = self.to_ipv4_mapped() {
return IpAddr::V4(mapped);
}
IpAddr::V6(*self)
}

/// Returns the sixteen eight-bit integers the IPv6 address consists of.
///
/// ```
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/parser/issue-87635.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct Foo {}

impl Foo {
pub fn bar()
//~^ ERROR: expected `;`, found `}`
//~| ERROR: associated function in `impl` without body
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/parser/issue-87635.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: expected `;`, found `}`
--> $DIR/issue-87635.rs:4:17
|
LL | pub fn bar()
| ^ help: add `;` here
...
LL | }
| - unexpected token

error: associated function in `impl` without body
--> $DIR/issue-87635.rs:4:5
|
LL | pub fn bar()
| ^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`

error: aborting due to 2 previous errors

15 changes: 15 additions & 0 deletions src/test/ui/unsafe/issue-87414-query-cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Regression test for #87414.

// check-pass
// compile-flags: -Zthir-unsafeck

fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }

fn foo() -> [(); { |x: u32| { x }; 4 }] { todo!() }
fn bar() { let _: [(); { |x: u32| { x }; 4 }]; }

// This one should not cause any errors either:
unsafe fn unsf() {}
fn bad2<T>() -> Box<dyn Iterator<Item = [(); { unsafe { || { unsf() } }; 4 }]>> { todo!() }

fn main() {}
1 change: 1 addition & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static HOSTS: &[&str] = &[
static TARGETS: &[&str] = &[
"aarch64-apple-darwin",
"aarch64-apple-ios",
"aarch64-apple-ios-sim",
"aarch64-fuchsia",
"aarch64-linux-android",
"aarch64-pc-windows-msvc",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer