Skip to content

Commit ad9b3c8

Browse files
committed
Auto merge of rust-lang#123466 - cuviper:beta-next, r=cuviper
[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
2 parents c119551 + cf44931 commit ad9b3c8

16 files changed

+208
-17
lines changed

compiler/rustc_const_eval/src/interpret/intern.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_ast::Mutability;
1818
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
1919
use rustc_errors::ErrorGuaranteed;
2020
use rustc_hir as hir;
21+
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2122
use rustc_middle::mir::interpret::{ConstAllocation, CtfeProvenance, InterpResult};
2223
use rustc_middle::query::TyCtxtAt;
2324
use rustc_middle::ty::layout::TyAndLayout;
@@ -106,7 +107,12 @@ fn intern_as_new_static<'tcx>(
106107
DefKind::Static { mutability: alloc.0.mutability, nested: true },
107108
);
108109
tcx.set_nested_alloc_id_static(alloc_id, feed.def_id());
109-
feed.codegen_fn_attrs(tcx.codegen_fn_attrs(static_id).clone());
110+
111+
// These do not inherit the codegen attrs of the parent static allocation, since
112+
// it doesn't make sense for them to inherit their `#[no_mangle]` and `#[link_name = ..]`
113+
// and the like.
114+
feed.codegen_fn_attrs(CodegenFnAttrs::new());
115+
110116
feed.eval_static_initializer(Ok(alloc));
111117
feed.generics_of(tcx.generics_of(static_id).clone());
112118
feed.def_ident_span(tcx.def_ident_span(static_id));

compiler/rustc_hir_analysis/src/bounds.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,20 @@ impl<'tcx> Bounds<'tcx> {
5454
span: Span,
5555
polarity: ty::ImplPolarity,
5656
) {
57-
self.clauses.push((
57+
let clause = (
5858
trait_ref
5959
.map_bound(|trait_ref| {
6060
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity })
6161
})
6262
.to_predicate(tcx),
6363
span,
64-
));
64+
);
65+
// FIXME(-Znext-solver): We can likely remove this hack once the new trait solver lands.
66+
if tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
67+
self.clauses.insert(0, clause);
68+
} else {
69+
self.clauses.push(clause);
70+
}
6571
}
6672

6773
pub fn push_projection_bound(

compiler/rustc_resolve/src/ident.rs

+2
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
605605
&& !this.tcx.features().f16
606606
&& !ident.span.allows_unstable(sym::f16)
607607
&& finalize.is_some()
608+
&& innermost_result.is_none()
608609
{
609610
feature_err(
610611
this.tcx.sess,
@@ -618,6 +619,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
618619
&& !this.tcx.features().f128
619620
&& !ident.span.allows_unstable(sym::f128)
620621
&& finalize.is_some()
622+
&& innermost_result.is_none()
621623
{
622624
feature_err(
623625
this.tcx.sess,

library/std/src/sys/pal/unix/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl FileAttr {
517517

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

523523
#[cfg(not(any(
@@ -545,7 +545,7 @@ impl FileAttr {
545545

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

551551
#[cfg(any(

src/llvm-project

Submodule llvm-project updated 67 files

tests/incremental/hashes/function_interfaces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn second_trait_bound<T: Eq + Clone>() {}
217217
pub fn second_builtin_bound<T: Send >() {}
218218

219219
#[cfg(not(any(cfail1,cfail4)))]
220-
#[rustc_clean(cfg = "cfail2", except = "opt_hir_owner_nodes, predicates_of")]
220+
#[rustc_clean(cfg = "cfail2", except = "opt_hir_owner_nodes")]
221221
#[rustc_clean(cfg = "cfail3")]
222222
#[rustc_clean(cfg = "cfail5", except = "opt_hir_owner_nodes, predicates_of")]
223223
#[rustc_clean(cfg = "cfail6")]

tests/ui/feature-gates/feature-gate-f128.stderr tests/ui/feature-gates/feature-gate-f128.e2015.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the type `f128` is unstable
2-
--> $DIR/feature-gate-f128.rs:3:10
2+
--> $DIR/feature-gate-f128.rs:7:10
33
|
44
LL | const A: f128 = 10.0;
55
| ^^^^
@@ -9,7 +9,7 @@ LL | const A: f128 = 10.0;
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

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

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

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

4141
error[E0658]: the type `f128` is unstable
42-
--> $DIR/feature-gate-f128.rs:7:13
42+
--> $DIR/feature-gate-f128.rs:11:13
4343
|
4444
LL | let b = 0.0f128;
4545
| ^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error[E0658]: the type `f128` is unstable
2+
--> $DIR/feature-gate-f128.rs:7:10
3+
|
4+
LL | const A: f128 = 10.0;
5+
| ^^^^
6+
|
7+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
8+
= help: add `#![feature(f128)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: the type `f128` is unstable
12+
--> $DIR/feature-gate-f128.rs:10:12
13+
|
14+
LL | let a: f128 = 100.0;
15+
| ^^^^
16+
|
17+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
18+
= help: add `#![feature(f128)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error[E0658]: the type `f128` is unstable
22+
--> $DIR/feature-gate-f128.rs:15:11
23+
|
24+
LL | fn foo(a: f128) {}
25+
| ^^^^
26+
|
27+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
28+
= help: add `#![feature(f128)]` to the crate attributes to enable
29+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30+
31+
error[E0658]: the type `f128` is unstable
32+
--> $DIR/feature-gate-f128.rs:18:8
33+
|
34+
LL | a: f128,
35+
| ^^^^
36+
|
37+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
38+
= help: add `#![feature(f128)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
41+
error[E0658]: the type `f128` is unstable
42+
--> $DIR/feature-gate-f128.rs:11:13
43+
|
44+
LL | let b = 0.0f128;
45+
| ^^^^^^^
46+
|
47+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
48+
= help: add `#![feature(f128)]` to the crate attributes to enable
49+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50+
51+
error: aborting due to 5 previous errors
52+
53+
For more information about this error, try `rustc --explain E0658`.

tests/ui/feature-gates/feature-gate-f128.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//@ revisions: e2015 e2018
2+
//
3+
//@[e2018] edition:2018
4+
15
#![allow(unused)]
26

37
const A: f128 = 10.0; //~ ERROR the type `f128` is unstable

tests/ui/feature-gates/feature-gate-f16.stderr tests/ui/feature-gates/feature-gate-f16.e2015.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the type `f16` is unstable
2-
--> $DIR/feature-gate-f16.rs:3:10
2+
--> $DIR/feature-gate-f16.rs:7:10
33
|
44
LL | const A: f16 = 10.0;
55
| ^^^
@@ -9,7 +9,7 @@ LL | const A: f16 = 10.0;
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

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

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

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

4141
error[E0658]: the type `f16` is unstable
42-
--> $DIR/feature-gate-f16.rs:7:13
42+
--> $DIR/feature-gate-f16.rs:11:13
4343
|
4444
LL | let b = 0.0f16;
4545
| ^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error[E0658]: the type `f16` is unstable
2+
--> $DIR/feature-gate-f16.rs:7:10
3+
|
4+
LL | const A: f16 = 10.0;
5+
| ^^^
6+
|
7+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
8+
= help: add `#![feature(f16)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: the type `f16` is unstable
12+
--> $DIR/feature-gate-f16.rs:10:12
13+
|
14+
LL | let a: f16 = 100.0;
15+
| ^^^
16+
|
17+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
18+
= help: add `#![feature(f16)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error[E0658]: the type `f16` is unstable
22+
--> $DIR/feature-gate-f16.rs:15:11
23+
|
24+
LL | fn foo(a: f16) {}
25+
| ^^^
26+
|
27+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
28+
= help: add `#![feature(f16)]` to the crate attributes to enable
29+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30+
31+
error[E0658]: the type `f16` is unstable
32+
--> $DIR/feature-gate-f16.rs:18:8
33+
|
34+
LL | a: f16,
35+
| ^^^
36+
|
37+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
38+
= help: add `#![feature(f16)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
41+
error[E0658]: the type `f16` is unstable
42+
--> $DIR/feature-gate-f16.rs:11:13
43+
|
44+
LL | let b = 0.0f16;
45+
| ^^^^^^
46+
|
47+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
48+
= help: add `#![feature(f16)]` to the crate attributes to enable
49+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50+
51+
error: aborting due to 5 previous errors
52+
53+
For more information about this error, try `rustc --explain E0658`.

tests/ui/feature-gates/feature-gate-f16.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//@ revisions: e2015 e2018
2+
//
3+
//@[e2018] edition:2018
4+
15
#![allow(unused)]
26

37
const A: f16 = 10.0; //~ ERROR the type `f16` is unstable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//@ check-pass
2+
// Regression test due to #123279
3+
4+
pub trait Job: AsJob {
5+
fn run_once(&self);
6+
}
7+
8+
impl<F: Fn()> Job for F {
9+
fn run_once(&self) {
10+
todo!()
11+
}
12+
}
13+
14+
pub trait AsJob {}
15+
16+
// Ensure that `T: Sized + Job` by reordering the explicit `Sized` to where
17+
// the implicit sized pred would go.
18+
impl<T: Job + Sized> AsJob for T {}
19+
20+
pub struct LoopingJobService {
21+
job: Box<dyn Job>,
22+
}
23+
24+
impl Job for LoopingJobService {
25+
fn run_once(&self) {
26+
self.job.run_once()
27+
}
28+
}
29+
30+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: --crate-type=lib
2+
//@ check-pass
3+
//@ revisions: e2015 e2018
4+
//
5+
//@[e2018] edition:2018
6+
7+
// Verify that gates for the `f16` and `f128` features do not apply to user modules
8+
// See <https://github.com/rust-lang/rust/issues/123282>
9+
10+
mod f16 {
11+
pub fn a16() {}
12+
}
13+
14+
mod f128 {
15+
pub fn a128() {}
16+
}
17+
18+
pub use f128::a128;
19+
pub use f16::a16;

tests/ui/resolve/primitive-f16-f128-shadowed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//@ compile-flags: --crate-type=lib
22
//@ check-pass
3+
//@ revisions: e2015 e2018
4+
//
5+
//@[e2018] edition:2018
36

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ build-pass
2+
3+
// Make sure that the nested static allocation for `FOO` doesn't inherit `no_mangle`.
4+
#[no_mangle]
5+
pub static mut FOO: &mut [i32] = &mut [42];
6+
7+
// Make sure that the nested static allocation for `BAR` doesn't inherit `export_name`.
8+
#[export_name = "BAR_"]
9+
pub static mut BAR: &mut [i32] = &mut [42];
10+
11+
fn main() {}

0 commit comments

Comments
 (0)