Skip to content

Commit e5da71f

Browse files
committed
Auto merge of #127377 - cuviper:beta-next, r=cuviper
[beta] backports - Properly gate `safe` keyword in pre-expansion #126757 - Switch back `non_local_definitions` lint to allow-by-default #127015 - Stall computing instance for drop shim until it has no unsubstituted const params #127068 - Update LLVM submodule #127190 - Change to the NetBSD archive URL rather than the CDN #127232 r? cuviper
2 parents 64a1fe6 + c822bf2 commit e5da71f

35 files changed

+268
-110
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
562562
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
563563
gate_all!(global_registration, "global registration is experimental");
564564
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
565+
gate_all!(
566+
unsafe_extern_blocks,
567+
"`unsafe extern {}` blocks and `safe` keyword are experimental"
568+
);
565569

566570
if !visitor.features.never_patterns {
567571
if let Some(spans) = spans.get(&sym::never_patterns) {

compiler/rustc_lint/src/non_local_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ declare_lint! {
5050
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for
5151
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
5252
pub NON_LOCAL_DEFINITIONS,
53-
Warn,
53+
Allow,
5454
"checks for non-local definitions",
5555
report_in_external_macro
5656
}

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
1010
use rustc_middle::mir::visit::*;
1111
use rustc_middle::mir::*;
1212
use rustc_middle::ty::TypeVisitableExt;
13-
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
13+
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeFlags};
1414
use rustc_session::config::{DebugInfo, OptLevel};
1515
use rustc_span::source_map::Spanned;
1616
use rustc_span::sym;
@@ -320,6 +320,16 @@ impl<'tcx> Inliner<'tcx> {
320320
InstanceDef::Intrinsic(_) | InstanceDef::Virtual(..) => {
321321
return Err("instance without MIR (intrinsic / virtual)");
322322
}
323+
324+
// FIXME(#127030): `ConstParamHasTy` has bad interactions with
325+
// the drop shim builder, which does not evaluate predicates in
326+
// the correct param-env for types being dropped. Stall resolving
327+
// the MIR for this instance until all of its const params are
328+
// substituted.
329+
InstanceDef::DropGlue(_, Some(ty)) if ty.has_type_flags(TypeFlags::HAS_CT_PARAM) => {
330+
return Err("still needs substitution");
331+
}
332+
323333
// This cannot result in an immediate cycle since the callee MIR is a shim, which does
324334
// not get any optimizations run on it. Any subsequent inlining may cause cycles, but we
325335
// do not need to catch this here, we can wait until the inliner decides to continue

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ impl<'a> Parser<'a> {
12211221
if self.eat_keyword_case(kw::Unsafe, case) {
12221222
Safety::Unsafe(self.prev_token.uninterpolated_span())
12231223
} else if self.eat_keyword_case(kw::Safe, case) {
1224+
self.psess
1225+
.gated_spans
1226+
.gate(sym::unsafe_extern_blocks, self.prev_token.uninterpolated_span());
12241227
Safety::Safe(self.prev_token.uninterpolated_span())
12251228
} else {
12261229
Safety::Default

src/ci/docker/host-x86_64/dist-x86_64-netbsd/build-netbsd-toolchain.sh

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# ignore-tidy-linelength
33

4-
set -ex
4+
set -eux
55

66
hide_output() {
77
set +x
@@ -20,24 +20,54 @@ exit 1
2020
set -x
2121
}
2222

23+
# Download, verify SHA512, and remove the downloaded file
24+
# Usage: <file name> <url> <file sha> <full tar command using fname>
25+
download() {
26+
fname="$1"
27+
shift
28+
url="$1"
29+
shift
30+
sha="$1"
31+
shift
32+
33+
curl "$url" -o "$fname"
34+
echo "$sha $fname" | shasum -a 512 --check || exit 1
35+
"$@"
36+
rm "$fname"
37+
}
38+
2339
mkdir netbsd
2440
cd netbsd
2541

2642
mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot
2743

2844
# URL=https://ci-mirrors.rust-lang.org/rustc
2945

30-
SOURCE_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/source/sets
31-
curl $SOURCE_URL/src.tgz | tar xzf -
32-
curl $SOURCE_URL/gnusrc.tgz | tar xzf -
33-
curl $SOURCE_URL/sharesrc.tgz | tar xzf -
34-
curl $SOURCE_URL/syssrc.tgz | tar xzf -
35-
36-
BINARY_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/sets
37-
curl $BINARY_URL/base.tar.xz | \
38-
tar xJf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
39-
curl $BINARY_URL/comp.tar.xz | \
40-
tar xJf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib
46+
# Hashes come from https://cdn.netbsd.org/pub/NetBSD/security/hashes/NetBSD-9.0_hashes.asc
47+
SRC_SHA=2c791ae009a6929c6fc893ec5df7e62910ee8207e0b2159d6937309c03efe175b6ae1e445829a13d041b6851334ad35c521f2fa03c97675d4a05f1fafe58ede0
48+
GNUSRC_SHA=3710085a73feecf6a843415271ec794c90146b03f6bbd30f07c9e0c79febf8995d557e40194f1e05db655e4f5ef2fae97563f8456fceaae65d4ea98857a83b1c
49+
SHARESRC_SHA=f080776ed82c3ac5d6272dee39746f87897d8e6984996caf5bf6d87bf11d9c9e0c1ad5c437c21258bd278bb6fd76974946e878f548517885f71c556096231369
50+
SYSSRC_SHA=60b9ddf4cc6402256473e2e1eefeabd9001aa4e205208715ecc6d6fc3f5b400e469944580077271b8e80562a4c2f601249e69e07a504f46744e0c50335f1cbf1
51+
BASE_SHA=b5926b107cebf40c3c19b4f6cd039b610987dd7f819e7cdde3bd1e5230a856906e7930b15ab242d52ced9f0bda01d574be59488b8dbb95fa5df2987d0a70995f
52+
COMP_SHA=38ea54f30d5fc2afea87e5096f06873e00182789e8ad9cec0cb3e9f7c538c1aa4779e63fd401a36ba02676158e83fa5c95e8e87898db59c1914fb206aecd82d2
53+
54+
# FIXME: the archive URL is being used temporarily while the CDN is down.
55+
# We should serve this from our own CDN
56+
# SOURCE_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/source/sets
57+
SOURCE_URL=http://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.0/source/sets
58+
download src.tgz "$SOURCE_URL/src.tgz" "$SRC_SHA" tar xzf src.tgz
59+
download gnusrc.tgz "$SOURCE_URL/gnusrc.tgz" "$GNUSRC_SHA" tar xzf gnusrc.tgz
60+
download sharesrc.tgz "$SOURCE_URL/sharesrc.tgz" "$SHARESRC_SHA" tar xzf sharesrc.tgz
61+
download syssrc.tgz "$SOURCE_URL/syssrc.tgz" "$SYSSRC_SHA" tar xzf syssrc.tgz
62+
63+
# FIXME: the archive URL is being used temporarily while the CDN is down.
64+
# We should serve this from our own CDN
65+
# BINARY_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/sets
66+
BINARY_URL=http://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.0/amd64/binary/sets
67+
download base.tar.xz "$BINARY_URL/base.tar.xz" "$BASE_SHA" \
68+
tar xJf base.tar.xz -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
69+
download comp.tar.xz "$BINARY_URL/comp.tar.xz" "$COMP_SHA" \
70+
tar xJf comp.tar.xz -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib
4171

4272
cd usr/src
4373

tests/rustdoc-ui/doctest/non_local_defs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//@ normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
55
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
66

7+
#![doc(test(attr(warn(non_local_definitions))))]
8+
79
//! ```
810
//! #[macro_export]
911
//! macro_rules! a_macro { () => {} }
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
2-
--> $DIR/non_local_defs.rs:9:1
2+
--> $DIR/non_local_defs.rs:11:1
33
|
44
LL | macro_rules! a_macro { () => {} }
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
88
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
99
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
10-
= note: `#[warn(non_local_definitions)]` on by default
10+
note: the lint level is defined here
11+
--> $DIR/non_local_defs.rs:8:9
12+
|
13+
LL | #![warn(non_local_definitions)]
14+
| ^^^^^^^^^^^^^^^^^^^^^
1115

1216
warning: 1 warning emitted
1317

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
running 1 test
3-
test $DIR/non_local_defs.rs - (line 7) ... ok
3+
test $DIR/non_local_defs.rs - (line 9) ... ok
44

55
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
66

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: -Zinline-mir=yes --crate-type=lib
2+
//@ build-pass
3+
4+
use std::mem::ManuallyDrop;
5+
6+
pub struct Foo<T, const N: usize>([T; N]);
7+
8+
pub struct Dorp {}
9+
10+
impl Drop for Dorp {
11+
fn drop(&mut self) {}
12+
}
13+
14+
#[inline]
15+
// SAFETY: call this with a valid allocation idk
16+
pub unsafe fn drop<const M: usize>(x: *mut Foo<Dorp, M>) {
17+
std::ptr::drop_in_place(x);
18+
}

0 commit comments

Comments
 (0)