Skip to content

Commit 81b457e

Browse files
authored
Merge pull request rust-lang#4716 from RalfJung/rustup
Rustup
2 parents 1b683cd + 4a08c29 commit 81b457e

File tree

141 files changed

+2722
-1321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2722
-1321
lines changed

Cargo.lock

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ dependencies = [
229229
"winnow 0.7.13",
230230
]
231231

232+
[[package]]
233+
name = "assert_cmd"
234+
version = "2.1.1"
235+
source = "registry+https://github.com/rust-lang/crates.io-index"
236+
checksum = "bcbb6924530aa9e0432442af08bbcafdad182db80d2e560da42a6d442535bf85"
237+
dependencies = [
238+
"anstyle",
239+
"bstr",
240+
"libc",
241+
"predicates",
242+
"predicates-core",
243+
"predicates-tree",
244+
"wait-timeout",
245+
]
246+
232247
[[package]]
233248
name = "autocfg"
234249
version = "1.5.0"
@@ -1151,6 +1166,12 @@ version = "0.1.13"
11511166
source = "registry+https://github.com/rust-lang/crates.io-index"
11521167
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
11531168

1169+
[[package]]
1170+
name = "difflib"
1171+
version = "0.4.0"
1172+
source = "registry+https://github.com/rust-lang/crates.io-index"
1173+
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
1174+
11541175
[[package]]
11551176
name = "digest"
11561177
version = "0.10.7"
@@ -2982,6 +3003,33 @@ version = "0.1.1"
29823003
source = "registry+https://github.com/rust-lang/crates.io-index"
29833004
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
29843005

3006+
[[package]]
3007+
name = "predicates"
3008+
version = "3.1.3"
3009+
source = "registry+https://github.com/rust-lang/crates.io-index"
3010+
checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573"
3011+
dependencies = [
3012+
"anstyle",
3013+
"difflib",
3014+
"predicates-core",
3015+
]
3016+
3017+
[[package]]
3018+
name = "predicates-core"
3019+
version = "1.0.9"
3020+
source = "registry+https://github.com/rust-lang/crates.io-index"
3021+
checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa"
3022+
3023+
[[package]]
3024+
name = "predicates-tree"
3025+
version = "1.0.12"
3026+
source = "registry+https://github.com/rust-lang/crates.io-index"
3027+
checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c"
3028+
dependencies = [
3029+
"predicates-core",
3030+
"termtree",
3031+
]
3032+
29853033
[[package]]
29863034
name = "prettydiff"
29873035
version = "0.7.0"
@@ -3262,6 +3310,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
32623310
[[package]]
32633311
name = "remote-test-client"
32643312
version = "0.1.0"
3313+
dependencies = [
3314+
"assert_cmd",
3315+
]
32653316

32663317
[[package]]
32673318
name = "remote-test-server"
@@ -4472,6 +4523,7 @@ dependencies = [
44724523
"rustc_target",
44734524
"scoped-tls",
44744525
"serde",
4526+
"serde_json",
44754527
"tracing",
44764528
]
44774529

@@ -5458,6 +5510,12 @@ dependencies = [
54585510
"windows-sys 0.60.2",
54595511
]
54605512

5513+
[[package]]
5514+
name = "termtree"
5515+
version = "0.5.1"
5516+
source = "registry+https://github.com/rust-lang/crates.io-index"
5517+
checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
5518+
54615519
[[package]]
54625520
name = "test-float-parse"
54635521
version = "0.1.0"
@@ -6076,6 +6134,15 @@ version = "0.9.5"
60766134
source = "registry+https://github.com/rust-lang/crates.io-index"
60776135
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
60786136

6137+
[[package]]
6138+
name = "wait-timeout"
6139+
version = "0.2.1"
6140+
source = "registry+https://github.com/rust-lang/crates.io-index"
6141+
checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11"
6142+
dependencies = [
6143+
"libc",
6144+
]
6145+
60796146
[[package]]
60806147
name = "walkdir"
60816148
version = "2.5.0"

compiler/rustc_ast_passes/messages.ftl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ ast_passes_assoc_type_without_body =
3737
.suggestion = provide a definition for the type
3838
3939
ast_passes_async_fn_in_const_trait_or_trait_impl =
40-
async functions are not allowed in `const` {$in_impl ->
41-
[true] trait impls
42-
*[false] traits
40+
async functions are not allowed in `const` {$context ->
41+
[trait_impl] trait impls
42+
[impl] impls
43+
*[trait] traits
4344
}
4445
.label = associated functions of `const` cannot be declared `async`
4546

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,15 @@ impl<'a> AstValidator<'a> {
312312
return;
313313
};
314314

315+
let context = match parent {
316+
TraitOrImpl::Trait { .. } => "trait",
317+
TraitOrImpl::TraitImpl { .. } => "trait_impl",
318+
TraitOrImpl::Impl { .. } => "impl",
319+
};
320+
315321
self.dcx().emit_err(errors::AsyncFnInConstTraitOrTraitImpl {
316322
async_keyword,
317-
in_impl: matches!(parent, TraitOrImpl::TraitImpl { .. }),
323+
context,
318324
const_keyword,
319325
});
320326
}
@@ -1714,9 +1720,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
17141720
self.check_async_fn_in_const_trait_or_impl(sig, parent);
17151721
}
17161722
}
1717-
Some(TraitOrImpl::Impl { constness }) => {
1723+
Some(parent @ TraitOrImpl::Impl { constness }) => {
17181724
if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind {
17191725
self.check_impl_fn_not_const(sig.header.constness, *constness);
1726+
self.check_async_fn_in_const_trait_or_impl(sig, parent);
17201727
}
17211728
}
17221729
None => {}

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub(crate) struct TraitFnConst {
7676
pub(crate) struct AsyncFnInConstTraitOrTraitImpl {
7777
#[primary_span]
7878
pub async_keyword: Span,
79-
pub in_impl: bool,
79+
pub context: &'static str,
8080
#[label]
8181
pub const_keyword: Span,
8282
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_middle::mir::BinOp;
1515
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
1616
use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv};
1717
use rustc_middle::{bug, span_bug};
18+
use rustc_session::config::CrateType;
1819
use rustc_span::{Span, Symbol, sym};
1920
use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
2021
use rustc_target::callconv::PassMode;
@@ -1136,8 +1137,17 @@ fn codegen_autodiff<'ll, 'tcx>(
11361137
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
11371138
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
11381139
}
1139-
if tcx.sess.lto() != rustc_session::config::Lto::Fat {
1140-
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
1140+
1141+
let ct = tcx.crate_types();
1142+
let lto = tcx.sess.lto();
1143+
if ct.len() == 1 && ct.contains(&CrateType::Executable) {
1144+
if lto != rustc_session::config::Lto::Fat {
1145+
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
1146+
}
1147+
} else {
1148+
if lto != rustc_session::config::Lto::Fat && !tcx.sess.opts.cg.linker_plugin_lto.enabled() {
1149+
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
1150+
}
11411151
}
11421152

11431153
let fn_args = instance.args;

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,14 +1291,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12911291
ty::Closure(..) => {
12921292
Adjust::Pointer(PointerCoercion::ClosureFnPointer(a_sig.safety()))
12931293
}
1294-
ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer),
1294+
ty::FnDef(def_id, ..) => {
1295+
// Intrinsics are not coercible to function pointers
1296+
if self.tcx.intrinsic(def_id).is_some() {
1297+
return Err(TypeError::IntrinsicCast);
1298+
}
1299+
Adjust::Pointer(PointerCoercion::ReifyFnPointer)
1300+
}
12951301
_ => span_bug!(cause.span, "should not try to coerce a {prev_ty} to a fn pointer"),
12961302
};
12971303
let next_adjustment = match new_ty.kind() {
12981304
ty::Closure(..) => {
12991305
Adjust::Pointer(PointerCoercion::ClosureFnPointer(b_sig.safety()))
13001306
}
1301-
ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer),
1307+
ty::FnDef(def_id, ..) => {
1308+
// Intrinsics are not coercible to function pointers
1309+
if self.tcx.intrinsic(def_id).is_some() {
1310+
return Err(TypeError::IntrinsicCast);
1311+
}
1312+
Adjust::Pointer(PointerCoercion::ReifyFnPointer)
1313+
}
13021314
_ => span_bug!(new.span, "should not try to coerce a {new_ty} to a fn pointer"),
13031315
};
13041316
for expr in exprs.iter().map(|e| e.as_coercion_site()) {

compiler/rustc_mir_transform/src/cross_crate_inline.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
3434
return true;
3535
}
3636

37+
// FIXME(autodiff): replace this as per discussion in https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880
38+
if tcx.has_attr(def_id, sym::autodiff_forward)
39+
|| tcx.has_attr(def_id, sym::autodiff_reverse)
40+
|| tcx.has_attr(def_id, sym::rustc_autodiff)
41+
{
42+
return true;
43+
}
44+
3745
if tcx.has_attr(def_id, sym::rustc_intrinsic) {
3846
// Intrinsic fallback bodies are always cross-crate inlineable.
3947
// To ensure that the MIR inliner doesn't cluelessly try to inline fallback

compiler/rustc_monomorphize/src/collector/autodiff.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use crate::collector::{MonoItems, create_fn_mono_item};
77
// mono so this does not interfere in `autodiff` intrinsics
88
// codegen process. If they are unused, LLVM will remove them when
99
// compiling with O3.
10+
// FIXME(autodiff): Remove this whole file, as per discussion in
11+
// https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880
1012
pub(crate) fn collect_autodiff_fn<'tcx>(
1113
tcx: TyCtxt<'tcx>,
1214
instance: ty::Instance<'tcx>,

compiler/rustc_public/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ rustc_session = { path = "../rustc_session" }
1313
rustc_span = { path = "../rustc_span" }
1414
rustc_target = { path = "../rustc_target" }
1515
scoped-tls = "1.0"
16-
serde = { version = "1.0.125", features = [ "derive" ] }
16+
serde = { version = "1.0.125", features = ["derive"] }
1717
tracing = "0.1"
1818
# tidy-alphabetical-end
1919

20+
[dev-dependencies]
21+
# tidy-alphabetical-start
22+
serde_json = "1.0.142"
23+
# tidy-alphabetical-end
24+
2025
[features]
2126
# tidy-alphabetical-start
2227
# Provides access to APIs that expose internals of the rust compiler.

compiler/rustc_public/src/abi.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use serde::Serialize;
77
use crate::compiler_interface::with;
88
use crate::mir::FieldIdx;
99
use crate::target::{MachineInfo, MachineSize as Size};
10-
use crate::ty::{Align, Ty, VariantIdx};
11-
use crate::{Error, Opaque, error};
10+
use crate::ty::{Align, Ty, VariantIdx, index_impl};
11+
use crate::{Error, Opaque, ThreadLocalIndex, error};
1212

1313
/// A function ABI definition.
1414
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
@@ -109,24 +109,16 @@ impl LayoutShape {
109109
}
110110
}
111111

112-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize)]
113-
pub struct Layout(usize);
112+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
113+
pub struct Layout(usize, ThreadLocalIndex);
114+
index_impl!(Layout);
114115

115116
impl Layout {
116117
pub fn shape(self) -> LayoutShape {
117118
with(|cx| cx.layout_shape(self))
118119
}
119120
}
120121

121-
impl crate::IndexedVal for Layout {
122-
fn to_val(index: usize) -> Self {
123-
Layout(index)
124-
}
125-
fn to_index(&self) -> usize {
126-
self.0
127-
}
128-
}
129-
130122
/// Describes how the fields of a type are shaped in memory.
131123
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
132124
pub enum FieldsShape {

0 commit comments

Comments
 (0)