Skip to content

Commit

Permalink
Auto merge of rust-lang#123466 - cuviper:beta-next, r=cuviper
Browse files Browse the repository at this point in the history
[beta] backports

- Fix f16 and f128 feature gates in editions other than 2015 rust-lang#123307 / rust-lang#123445
- Update to LLVM 18.1.2 rust-lang#122772
- unix fs: Make hurd using explicit new rather than From rust-lang#123057
- Don't inherit codegen attrs from parent static rust-lang#123310
- Make sure to insert Sized bound first into clauses list rust-lang#123302

r? cuviper
  • Loading branch information
bors committed Apr 5, 2024
2 parents c119551 + cf44931 commit ad9b3c8
Show file tree
Hide file tree
Showing 16 changed files with 208 additions and 17 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc_ast::Mutability;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::interpret::{ConstAllocation, CtfeProvenance, InterpResult};
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::layout::TyAndLayout;
Expand Down Expand Up @@ -106,7 +107,12 @@ fn intern_as_new_static<'tcx>(
DefKind::Static { mutability: alloc.0.mutability, nested: true },
);
tcx.set_nested_alloc_id_static(alloc_id, feed.def_id());
feed.codegen_fn_attrs(tcx.codegen_fn_attrs(static_id).clone());

// These do not inherit the codegen attrs of the parent static allocation, since
// it doesn't make sense for them to inherit their `#[no_mangle]` and `#[link_name = ..]`
// and the like.
feed.codegen_fn_attrs(CodegenFnAttrs::new());

feed.eval_static_initializer(Ok(alloc));
feed.generics_of(tcx.generics_of(static_id).clone());
feed.def_ident_span(tcx.def_ident_span(static_id));
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_hir_analysis/src/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,20 @@ impl<'tcx> Bounds<'tcx> {
span: Span,
polarity: ty::ImplPolarity,
) {
self.clauses.push((
let clause = (
trait_ref
.map_bound(|trait_ref| {
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity })
})
.to_predicate(tcx),
span,
));
);
// FIXME(-Znext-solver): We can likely remove this hack once the new trait solver lands.
if tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
self.clauses.insert(0, clause);
} else {
self.clauses.push(clause);
}
}

pub fn push_projection_bound(
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
&& !this.tcx.features().f16
&& !ident.span.allows_unstable(sym::f16)
&& finalize.is_some()
&& innermost_result.is_none()
{
feature_err(
this.tcx.sess,
Expand All @@ -618,6 +619,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
&& !this.tcx.features().f128
&& !ident.span.allows_unstable(sym::f128)
&& finalize.is_some()
&& innermost_result.is_none()
{
feature_err(
this.tcx.sess,
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl FileAttr {

#[cfg(any(target_os = "horizon", target_os = "hurd"))]
pub fn modified(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(self.stat.st_mtim))
SystemTime::new(self.stat.st_mtim.tv_sec as i64, self.stat.st_mtim.tv_nsec as i64)
}

#[cfg(not(any(
Expand Down Expand Up @@ -545,7 +545,7 @@ impl FileAttr {

#[cfg(any(target_os = "horizon", target_os = "hurd"))]
pub fn accessed(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(self.stat.st_atim))
SystemTime::new(self.stat.st_atim.tv_sec as i64, self.stat.st_atim.tv_nsec as i64)
}

#[cfg(any(
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 67 files
+10 −2 .github/workflows/llvm-tests.yml
+138 −32 clang-tools-extra/clangd/HeuristicResolver.cpp
+0 −37 clang-tools-extra/clangd/HeuristicResolver.h
+27 −0 clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+10 −0 clang/include/clang/AST/DeclBase.h
+0 −7 clang/include/clang/Serialization/ASTReader.h
+1 −1 clang/lib/AST/Decl.cpp
+5 −0 clang/lib/AST/DeclBase.cpp
+3 −4 clang/lib/Basic/Module.cpp
+25 −2 clang/lib/Driver/ToolChains/WebAssembly.cpp
+1 −1 clang/lib/Driver/ToolChains/WebAssembly.h
+1 −1 clang/lib/Headers/__stddef_null.h
+6 −1 clang/lib/Headers/__stddef_nullptr_t.h
+6 −1 clang/lib/Headers/__stddef_offsetof.h
+6 −1 clang/lib/Headers/__stddef_ptrdiff_t.h
+6 −1 clang/lib/Headers/__stddef_rsize_t.h
+6 −1 clang/lib/Headers/__stddef_size_t.h
+6 −1 clang/lib/Headers/__stddef_unreachable.h
+6 −1 clang/lib/Headers/__stddef_wchar_t.h
+9 −11 clang/lib/Headers/module.modulemap
+6 −3 clang/lib/Lex/ModuleMap.cpp
+1 −1 clang/lib/Serialization/ASTReader.cpp
+4 −4 clang/lib/Serialization/ASTReaderDecl.cpp
+1 −1 clang/lib/Serialization/ASTWriter.cpp
+4 −4 clang/lib/Serialization/ASTWriterDecl.cpp
+24 −0 clang/test/Driver/wasm-toolchain.c
+67 −0 clang/test/Modules/hashing-decls-in-exprs-from-gmf.cppm
+1 −1 clang/test/Modules/no-undeclared-includes-builtins.cpp
+18 −14 clang/test/Modules/stddef.c
+1 −1 libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+3 −2 lld/ELF/Arch/LoongArch.cpp
+1 −0 lld/test/COFF/def-export-cpp.s
+13 −0 lld/test/COFF/def-export-stdcall.s
+4 −0 lld/test/COFF/dllexport.s
+1 −1 lld/test/ELF/loongarch-reloc-leb128.s
+3 −3 llvm/cmake/modules/AddLLVM.cmake
+4 −1 llvm/include/llvm/BinaryFormat/COFF.h
+41 −0 llvm/include/llvm/Object/COFF.h
+32 −3 llvm/include/llvm/Object/COFFImportFile.h
+11 −0 llvm/lib/Object/ArchiveWriter.cpp
+87 −27 llvm/lib/Object/COFFImportFile.cpp
+2 −0 llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
+2 −0 llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+0 −28 llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
+1 −1 llvm/lib/Target/AVR/AVRInstrInfo.td
+1 −0 llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+12 −8 llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+3 −0 llvm/lib/Target/X86/X86InstrVecCompiler.td
+1 −0 llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+5 −4 llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+163 −0 llvm/test/CodeGen/AVR/bug-81911.ll
+58 −0 llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
+58 −0 llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
+43 −0 llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
+22 −0 llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
+0 −1 llvm/test/CodeGen/X86/bfloat.ll
+20 −0 llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
+40 −0 llvm/test/Transforms/InstCombine/intrinsic-select.ll
+7 −0 llvm/test/tools/llvm-dlltool/coff-decorated.def
+3 −0 llvm/test/tools/llvm-dlltool/coff-exports.def
+1 −0 llvm/test/tools/llvm-dlltool/coff-noname.def
+2 −0 llvm/test/tools/llvm-dlltool/no-leading-underscore.def
+55 −1 llvm/test/tools/llvm-lib/arm64ec-implib.test
+1 −0 llvm/test/tools/llvm-readobj/COFF/file-headers.test
+6 −0 llvm/tools/llvm-readobj/COFFImportDumper.cpp
+7 −4 llvm/tools/llvm-shlib/CMakeLists.txt
+0 −10 openmp/runtime/src/kmp.h
2 changes: 1 addition & 1 deletion tests/incremental/hashes/function_interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn second_trait_bound<T: Eq + Clone>() {}
pub fn second_builtin_bound<T: Send >() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "opt_hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail2", except = "opt_hir_owner_nodes")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "opt_hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail6")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:3:10
--> $DIR/feature-gate-f128.rs:7:10
|
LL | const A: f128 = 10.0;
| ^^^^
Expand All @@ -9,7 +9,7 @@ LL | const A: f128 = 10.0;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:6:12
--> $DIR/feature-gate-f128.rs:10:12
|
LL | let a: f128 = 100.0;
| ^^^^
Expand All @@ -19,7 +19,7 @@ LL | let a: f128 = 100.0;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:11:11
--> $DIR/feature-gate-f128.rs:15:11
|
LL | fn foo(a: f128) {}
| ^^^^
Expand All @@ -29,7 +29,7 @@ LL | fn foo(a: f128) {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:14:8
--> $DIR/feature-gate-f128.rs:18:8
|
LL | a: f128,
| ^^^^
Expand All @@ -39,7 +39,7 @@ LL | a: f128,
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:7:13
--> $DIR/feature-gate-f128.rs:11:13
|
LL | let b = 0.0f128;
| ^^^^^^^
Expand Down
53 changes: 53 additions & 0 deletions tests/ui/feature-gates/feature-gate-f128.e2018.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:7:10
|
LL | const A: f128 = 10.0;
| ^^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f128)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:10:12
|
LL | let a: f128 = 100.0;
| ^^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f128)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:15:11
|
LL | fn foo(a: f128) {}
| ^^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f128)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:18:8
|
LL | a: f128,
| ^^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f128)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:11:13
|
LL | let b = 0.0f128;
| ^^^^^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f128)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
4 changes: 4 additions & 0 deletions tests/ui/feature-gates/feature-gate-f128.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

#![allow(unused)]

const A: f128 = 10.0; //~ ERROR the type `f128` is unstable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:3:10
--> $DIR/feature-gate-f16.rs:7:10
|
LL | const A: f16 = 10.0;
| ^^^
Expand All @@ -9,7 +9,7 @@ LL | const A: f16 = 10.0;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:6:12
--> $DIR/feature-gate-f16.rs:10:12
|
LL | let a: f16 = 100.0;
| ^^^
Expand All @@ -19,7 +19,7 @@ LL | let a: f16 = 100.0;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:11:11
--> $DIR/feature-gate-f16.rs:15:11
|
LL | fn foo(a: f16) {}
| ^^^
Expand All @@ -29,7 +29,7 @@ LL | fn foo(a: f16) {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:14:8
--> $DIR/feature-gate-f16.rs:18:8
|
LL | a: f16,
| ^^^
Expand All @@ -39,7 +39,7 @@ LL | a: f16,
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:7:13
--> $DIR/feature-gate-f16.rs:11:13
|
LL | let b = 0.0f16;
| ^^^^^^
Expand Down
53 changes: 53 additions & 0 deletions tests/ui/feature-gates/feature-gate-f16.e2018.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:7:10
|
LL | const A: f16 = 10.0;
| ^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f16)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:10:12
|
LL | let a: f16 = 100.0;
| ^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f16)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:15:11
|
LL | fn foo(a: f16) {}
| ^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f16)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:18:8
|
LL | a: f16,
| ^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f16)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:11:13
|
LL | let b = 0.0f16;
| ^^^^^^
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
= help: add `#![feature(f16)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
4 changes: 4 additions & 0 deletions tests/ui/feature-gates/feature-gate-f16.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

#![allow(unused)]

const A: f16 = 10.0; //~ ERROR the type `f16` is unstable
Expand Down
30 changes: 30 additions & 0 deletions tests/ui/methods/probe-overflow-due-to-sized-predicate-ordering.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//@ check-pass
// Regression test due to #123279

pub trait Job: AsJob {
fn run_once(&self);
}

impl<F: Fn()> Job for F {
fn run_once(&self) {
todo!()
}
}

pub trait AsJob {}

// Ensure that `T: Sized + Job` by reordering the explicit `Sized` to where
// the implicit sized pred would go.
impl<T: Job + Sized> AsJob for T {}

pub struct LoopingJobService {
job: Box<dyn Job>,
}

impl Job for LoopingJobService {
fn run_once(&self) {
self.job.run_once()
}
}

fn main() {}
19 changes: 19 additions & 0 deletions tests/ui/resolve/primitive-f16-f128-shadowed-mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ compile-flags: --crate-type=lib
//@ check-pass
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

// Verify that gates for the `f16` and `f128` features do not apply to user modules
// See <https://github.com/rust-lang/rust/issues/123282>

mod f16 {
pub fn a16() {}
}

mod f128 {
pub fn a128() {}
}

pub use f128::a128;
pub use f16::a16;
3 changes: 3 additions & 0 deletions tests/ui/resolve/primitive-f16-f128-shadowed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//@ compile-flags: --crate-type=lib
//@ check-pass
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

// Verify that gates for the `f16` and `f128` features do not apply to user types

Expand Down
11 changes: 11 additions & 0 deletions tests/ui/statics/nested-allocations-dont-inherit-codegen-attrs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ build-pass

// Make sure that the nested static allocation for `FOO` doesn't inherit `no_mangle`.
#[no_mangle]
pub static mut FOO: &mut [i32] = &mut [42];

// Make sure that the nested static allocation for `BAR` doesn't inherit `export_name`.
#[export_name = "BAR_"]
pub static mut BAR: &mut [i32] = &mut [42];

fn main() {}

0 comments on commit ad9b3c8

Please sign in to comment.