Skip to content

Commit fae15df

Browse files
committed
Auto merge of rust-lang#3280 - rust-lang:rustup-2024-01-26, r=RalfJung
Automatic Rustup
2 parents 9f4d1a4 + 2318b08 commit fae15df

File tree

255 files changed

+4545
-2917
lines changed

Some content is hidden

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

255 files changed

+4545
-2917
lines changed

Cargo.lock

+15-6
Original file line numberDiff line numberDiff line change
@@ -212,24 +212,24 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
212212

213213
[[package]]
214214
name = "askama"
215-
version = "0.12.0"
215+
version = "0.12.1"
216216
source = "registry+https://github.com/rust-lang/crates.io-index"
217-
checksum = "47cbc3cf73fa8d9833727bbee4835ba5c421a0d65b72daf9a7b5d0e0f9cfb57e"
217+
checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
218218
dependencies = [
219219
"askama_derive",
220220
"askama_escape",
221221
]
222222

223223
[[package]]
224224
name = "askama_derive"
225-
version = "0.12.1"
225+
version = "0.12.5"
226226
source = "registry+https://github.com/rust-lang/crates.io-index"
227-
checksum = "c22fbe0413545c098358e56966ff22cdd039e10215ae213cfbd65032b119fc94"
227+
checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"
228228
dependencies = [
229+
"askama_parser",
229230
"basic-toml",
230231
"mime",
231232
"mime_guess",
232-
"nom",
233233
"proc-macro2",
234234
"quote",
235235
"serde",
@@ -242,6 +242,15 @@ version = "0.10.3"
242242
source = "registry+https://github.com/rust-lang/crates.io-index"
243243
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
244244

245+
[[package]]
246+
name = "askama_parser"
247+
version = "0.2.1"
248+
source = "registry+https://github.com/rust-lang/crates.io-index"
249+
checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"
250+
dependencies = [
251+
"nom",
252+
]
253+
245254
[[package]]
246255
name = "autocfg"
247256
version = "1.1.0"
@@ -3654,10 +3663,10 @@ version = "0.0.0"
36543663
dependencies = [
36553664
"arrayvec",
36563665
"bitflags 2.4.1",
3666+
"either",
36573667
"elsa",
36583668
"ena",
36593669
"indexmap",
3660-
"itertools",
36613670
"jobserver",
36623671
"libc",
36633672
"measureme",

compiler/rustc_ast/src/visit.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,11 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
375375
}
376376
ItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
377377
ItemKind::MacroDef(ts) => visitor.visit_mac_def(ts, item.id),
378-
ItemKind::Delegation(box Delegation { id: _, qself, path, body }) => {
378+
ItemKind::Delegation(box Delegation { id, qself, path, body }) => {
379379
if let Some(qself) = qself {
380380
visitor.visit_ty(&qself.ty);
381381
}
382-
walk_path(visitor, path);
382+
visitor.visit_path(path, *id);
383383
if let Some(body) = body {
384384
visitor.visit_block(body);
385385
}
@@ -502,7 +502,7 @@ where
502502
}
503503
GenericArgs::Parenthesized(data) => {
504504
walk_list!(visitor, visit_ty, &data.inputs);
505-
walk_fn_ret_ty(visitor, &data.output);
505+
visitor.visit_fn_ret_ty(&data.output);
506506
}
507507
}
508508
}
@@ -713,11 +713,11 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
713713
AssocItemKind::MacCall(mac) => {
714714
visitor.visit_mac_call(mac);
715715
}
716-
AssocItemKind::Delegation(box Delegation { id: _, qself, path, body }) => {
716+
AssocItemKind::Delegation(box Delegation { id, qself, path, body }) => {
717717
if let Some(qself) = qself {
718718
visitor.visit_ty(&qself.ty);
719719
}
720-
walk_path(visitor, path);
720+
visitor.visit_path(path, *id);
721721
if let Some(body) = body {
722722
visitor.visit_block(body);
723723
}

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

-13
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ pub fn expand_deriving_eq(
1919
) {
2020
let span = cx.with_def_site_ctxt(span);
2121

22-
let structural_trait_def = TraitDef {
23-
span,
24-
path: path_std!(marker::StructuralEq),
25-
skip_path_as_bound: true, // crucial!
26-
needs_copy_as_bound_if_packed: false,
27-
additional_bounds: Vec::new(),
28-
supports_unions: true,
29-
methods: Vec::new(),
30-
associated_types: Vec::new(),
31-
is_const: false,
32-
};
33-
structural_trait_def.expand(cx, mitem, item, push);
34-
3522
let trait_def = TraitDef {
3623
span,
3724
path: path_std!(cmp::Eq),

compiler/rustc_codegen_cranelift/example/mini_core.rs

-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
104104
#[lang = "structural_peq"]
105105
pub trait StructuralPartialEq {}
106106

107-
#[lang = "structural_teq"]
108-
pub trait StructuralEq {}
109-
110107
#[lang = "not"]
111108
pub trait Not {
112109
type Output;

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
443443

444444
ret.write_cvalue(fx, a);
445445
}
446+
sym::is_val_statically_known => {
447+
intrinsic_args!(fx, args => (_a); intrinsic);
448+
449+
let res = fx.bcx.ins().iconst(types::I8, 0);
450+
ret.write_cvalue(fx, CValue::by_val(res, ret.layout()));
451+
}
446452
sym::breakpoint => {
447453
intrinsic_args!(fx, args => (); intrinsic);
448454

compiler/rustc_codegen_gcc/example/mini_core.rs

-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
100100
#[lang = "structural_peq"]
101101
pub trait StructuralPartialEq {}
102102

103-
#[lang = "structural_teq"]
104-
pub trait StructuralEq {}
105-
106103
#[lang = "not"]
107104
pub trait Not {
108105
type Output;

compiler/rustc_codegen_gcc/src/context.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,16 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
196196

197197
let mut functions = FxHashMap::default();
198198
let builtins = [
199-
"__builtin_unreachable", "abort", "__builtin_expect", "__builtin_add_overflow", "__builtin_mul_overflow",
200-
"__builtin_saddll_overflow", /*"__builtin_sadd_overflow",*/ "__builtin_smulll_overflow", /*"__builtin_smul_overflow",*/
199+
"__builtin_unreachable", "abort", "__builtin_expect", /*"__builtin_expect_with_probability",*/
200+
"__builtin_constant_p", "__builtin_add_overflow", "__builtin_mul_overflow", "__builtin_saddll_overflow",
201+
/*"__builtin_sadd_overflow",*/ "__builtin_smulll_overflow", /*"__builtin_smul_overflow",*/
201202
"__builtin_ssubll_overflow", /*"__builtin_ssub_overflow",*/ "__builtin_sub_overflow", "__builtin_uaddll_overflow",
202203
"__builtin_uadd_overflow", "__builtin_umulll_overflow", "__builtin_umul_overflow", "__builtin_usubll_overflow",
203204
"__builtin_usub_overflow", "sqrtf", "sqrt", "__builtin_powif", "__builtin_powi", "sinf", "sin", "cosf", "cos",
204205
"powf", "pow", "expf", "exp", "exp2f", "exp2", "logf", "log", "log10f", "log10", "log2f", "log2", "fmaf",
205206
"fma", "fabsf", "fabs", "fminf", "fmin", "fmaxf", "fmax", "copysignf", "copysign", "floorf", "floor", "ceilf",
206207
"ceil", "truncf", "trunc", "rintf", "rint", "nearbyintf", "nearbyint", "roundf", "round",
207-
"__builtin_expect_with_probability",
208+
208209
];
209210

210211
for builtin in builtins.iter() {

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
123123
sym::unlikely => {
124124
self.expect(args[0].immediate(), false)
125125
}
126+
sym::is_val_statically_known => {
127+
let a = args[0].immediate();
128+
let builtin = self.context.get_builtin_function("__builtin_constant_p");
129+
let res = self.context.new_call(None, builtin, &[a]);
130+
self.icmp(IntPredicate::IntEQ, res, self.const_i32(0))
131+
}
126132
kw::Try => {
127133
try_intrinsic(
128134
self,

compiler/rustc_codegen_gcc/tests/run/static.rs

-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ mod libc {
6161
#[lang = "structural_peq"]
6262
pub trait StructuralPartialEq {}
6363

64-
#[lang = "structural_teq"]
65-
pub trait StructuralEq {}
66-
6764
#[lang = "drop_in_place"]
6865
#[allow(unconditional_recursion)]
6966
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {

compiler/rustc_codegen_llvm/src/context.rs

+14
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,20 @@ impl<'ll> CodegenCx<'ll, '_> {
916916
ifn!("llvm.lifetime.start.p0i8", fn(t_i64, ptr) -> void);
917917
ifn!("llvm.lifetime.end.p0i8", fn(t_i64, ptr) -> void);
918918

919+
// FIXME: This is an infinitesimally small portion of the types you can
920+
// pass to this intrinsic, if we can ever lazily register intrinsics we
921+
// should register these when they're used, that way any type can be
922+
// passed.
923+
ifn!("llvm.is.constant.i1", fn(i1) -> i1);
924+
ifn!("llvm.is.constant.i8", fn(t_i8) -> i1);
925+
ifn!("llvm.is.constant.i16", fn(t_i16) -> i1);
926+
ifn!("llvm.is.constant.i32", fn(t_i32) -> i1);
927+
ifn!("llvm.is.constant.i64", fn(t_i64) -> i1);
928+
ifn!("llvm.is.constant.i128", fn(t_i128) -> i1);
929+
ifn!("llvm.is.constant.isize", fn(t_isize) -> i1);
930+
ifn!("llvm.is.constant.f32", fn(t_f32) -> i1);
931+
ifn!("llvm.is.constant.f64", fn(t_f64) -> i1);
932+
919933
ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
920934
ifn!("llvm.eh.typeid.for", fn(ptr) -> t_i32);
921935
ifn!("llvm.localescape", fn(...) -> void);

compiler/rustc_codegen_llvm/src/intrinsic.rs

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
119119
sym::likely => {
120120
self.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(true)])
121121
}
122+
sym::is_val_statically_known => self.call_intrinsic(
123+
&format!("llvm.is.constant.{:?}", args[0].layout.immediate_llvm_type(self.cx)),
124+
&[args[0].immediate()],
125+
),
122126
sym::unlikely => self
123127
.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]),
124128
kw::Try => {

compiler/rustc_codegen_ssa/src/back/link.rs

+36-28
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ use std::path::{Path, PathBuf};
5252
use std::process::{ExitStatus, Output, Stdio};
5353
use std::{env, fmt, fs, io, mem, str};
5454

55+
#[derive(Default)]
56+
pub struct SearchPaths(OnceCell<Vec<PathBuf>>);
57+
58+
impl SearchPaths {
59+
pub(super) fn get(&self, sess: &Session) -> &[PathBuf] {
60+
self.0.get_or_init(|| archive_search_paths(sess))
61+
}
62+
}
63+
5564
pub fn ensure_removed(dcx: &DiagCtxt, path: &Path) {
5665
if let Err(e) = fs::remove_file(path) {
5766
if e.kind() != io::ErrorKind::NotFound {
@@ -1265,15 +1274,15 @@ fn link_sanitizer_runtime(
12651274
let path = find_sanitizer_runtime(sess, &filename);
12661275
let rpath = path.to_str().expect("non-utf8 component in path");
12671276
linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
1268-
linker.link_dylib(&filename, false, true);
1277+
linker.link_dylib_by_name(&filename, false, true);
12691278
} else if sess.target.is_like_msvc && flavor == LinkerFlavor::Msvc(Lld::No) && name == "asan" {
12701279
// MSVC provides the `/INFERASANLIBS` argument to automatically find the
12711280
// compatible ASAN library.
12721281
linker.arg("/INFERASANLIBS");
12731282
} else {
12741283
let filename = format!("librustc{channel}_rt.{name}.a");
12751284
let path = find_sanitizer_runtime(sess, &filename).join(&filename);
1276-
linker.link_whole_rlib(&path);
1285+
linker.link_staticlib_by_path(&path, true);
12771286
}
12781287
}
12791288

@@ -2445,7 +2454,7 @@ fn add_native_libs_from_crate(
24452454
archive_builder_builder: &dyn ArchiveBuilderBuilder,
24462455
codegen_results: &CodegenResults,
24472456
tmpdir: &Path,
2448-
search_paths: &OnceCell<Vec<PathBuf>>,
2457+
search_paths: &SearchPaths,
24492458
bundled_libs: &FxHashSet<Symbol>,
24502459
cnum: CrateNum,
24512460
link_static: bool,
@@ -2505,46 +2514,34 @@ fn add_native_libs_from_crate(
25052514
if let Some(filename) = lib.filename {
25062515
// If rlib contains native libs as archives, they are unpacked to tmpdir.
25072516
let path = tmpdir.join(filename.as_str());
2508-
if whole_archive {
2509-
cmd.link_whole_rlib(&path);
2510-
} else {
2511-
cmd.link_rlib(&path);
2512-
}
2517+
cmd.link_staticlib_by_path(&path, whole_archive);
25132518
}
25142519
} else {
2515-
if whole_archive {
2516-
cmd.link_whole_staticlib(
2517-
name,
2518-
verbatim,
2519-
search_paths.get_or_init(|| archive_search_paths(sess)),
2520-
);
2521-
} else {
2522-
cmd.link_staticlib(name, verbatim)
2523-
}
2520+
cmd.link_staticlib_by_name(name, verbatim, whole_archive, search_paths);
25242521
}
25252522
}
25262523
}
25272524
NativeLibKind::Dylib { as_needed } => {
25282525
if link_dynamic {
2529-
cmd.link_dylib(name, verbatim, as_needed.unwrap_or(true))
2526+
cmd.link_dylib_by_name(name, verbatim, as_needed.unwrap_or(true))
25302527
}
25312528
}
25322529
NativeLibKind::Unspecified => {
25332530
// If we are generating a static binary, prefer static library when the
25342531
// link kind is unspecified.
25352532
if !link_output_kind.can_link_dylib() && !sess.target.crt_static_allows_dylibs {
25362533
if link_static {
2537-
cmd.link_staticlib(name, verbatim)
2534+
cmd.link_staticlib_by_name(name, verbatim, false, search_paths);
25382535
}
25392536
} else {
25402537
if link_dynamic {
2541-
cmd.link_dylib(name, verbatim, true);
2538+
cmd.link_dylib_by_name(name, verbatim, true);
25422539
}
25432540
}
25442541
}
25452542
NativeLibKind::Framework { as_needed } => {
25462543
if link_dynamic {
2547-
cmd.link_framework(name, as_needed.unwrap_or(true))
2544+
cmd.link_framework_by_name(name, verbatim, as_needed.unwrap_or(true))
25482545
}
25492546
}
25502547
NativeLibKind::RawDylib => {
@@ -2581,7 +2578,7 @@ fn add_local_native_libraries(
25812578
}
25822579
}
25832580

2584-
let search_paths = OnceCell::new();
2581+
let search_paths = SearchPaths::default();
25852582
// All static and dynamic native library dependencies are linked to the local crate.
25862583
let link_static = true;
25872584
let link_dynamic = true;
@@ -2623,7 +2620,7 @@ fn add_upstream_rust_crates<'a>(
26232620
.find(|(ty, _)| *ty == crate_type)
26242621
.expect("failed to find crate type in dependency format list");
26252622

2626-
let search_paths = OnceCell::new();
2623+
let search_paths = SearchPaths::default();
26272624
for &cnum in &codegen_results.crate_info.used_crates {
26282625
// We may not pass all crates through to the linker. Some crates may appear statically in
26292626
// an existing dylib, meaning we'll pick up all the symbols from the dylib.
@@ -2698,7 +2695,7 @@ fn add_upstream_native_libraries(
26982695
tmpdir: &Path,
26992696
link_output_kind: LinkOutputKind,
27002697
) {
2701-
let search_path = OnceCell::new();
2698+
let search_paths = SearchPaths::default();
27022699
for &cnum in &codegen_results.crate_info.used_crates {
27032700
// Static libraries are not linked here, they are linked in `add_upstream_rust_crates`.
27042701
// FIXME: Merge this function to `add_upstream_rust_crates` so that all native libraries
@@ -2720,7 +2717,7 @@ fn add_upstream_native_libraries(
27202717
archive_builder_builder,
27212718
codegen_results,
27222719
tmpdir,
2723-
&search_path,
2720+
&search_paths,
27242721
&Default::default(),
27252722
cnum,
27262723
link_static,
@@ -2791,7 +2788,7 @@ fn add_static_crate<'a>(
27912788
} else {
27922789
fix_windows_verbatim_for_gcc(path)
27932790
};
2794-
cmd.link_rlib(&rlib_path);
2791+
cmd.link_staticlib_by_path(&rlib_path, false);
27952792
};
27962793

27972794
if !are_upstream_rust_objects_already_included(sess)
@@ -2859,13 +2856,24 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
28592856
// Just need to tell the linker about where the library lives and
28602857
// what its name is
28612858
let parent = cratepath.parent();
2859+
// When producing a dll, the MSVC linker may not actually emit a
2860+
// `foo.lib` file if the dll doesn't actually export any symbols, so we
2861+
// check to see if the file is there and just omit linking to it if it's
2862+
// not present.
2863+
if sess.target.is_like_msvc && !cratepath.with_extension("dll.lib").exists() {
2864+
return;
2865+
}
28622866
if let Some(dir) = parent {
28632867
cmd.include_path(&rehome_sysroot_lib_dir(sess, dir));
28642868
}
2865-
let stem = cratepath.file_stem().unwrap().to_str().unwrap();
2869+
// "<dir>/name.dll -> name.dll" on windows-msvc
2870+
// "<dir>/name.dll -> name" on windows-gnu
2871+
// "<dir>/libname.<ext> -> name" elsewhere
2872+
let stem = if sess.target.is_like_msvc { cratepath.file_name() } else { cratepath.file_stem() };
2873+
let stem = stem.unwrap().to_str().unwrap();
28662874
// Convert library file-stem into a cc -l argument.
28672875
let prefix = if stem.starts_with("lib") && !sess.target.is_like_windows { 3 } else { 0 };
2868-
cmd.link_rust_dylib(&stem[prefix..], parent.unwrap_or_else(|| Path::new("")));
2876+
cmd.link_dylib_by_name(&stem[prefix..], false, true);
28692877
}
28702878

28712879
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {

0 commit comments

Comments
 (0)