Skip to content

Commit d0f4a52

Browse files
committed
Auto merge of #3894 - rust-lang:rustup-2024-09-17, r=RalfJung
Automatic Rustup
2 parents 9c3a392 + c5f5cfc commit d0f4a52

File tree

81 files changed

+1919
-1402
lines changed

Some content is hidden

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

81 files changed

+1919
-1402
lines changed

compiler/rustc_abi/src/layout.rs

Lines changed: 952 additions & 920 deletions
Large diffs are not rendered by default.

compiler/rustc_abi/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod layout;
2626
#[cfg(test)]
2727
mod tests;
2828

29-
pub use layout::LayoutCalculator;
29+
pub use layout::{LayoutCalculator, LayoutCalculatorError};
3030

3131
/// Requirements for a `StableHashingContext` to be used in this crate.
3232
/// This is a hack to allow using the `HashStable_Generic` derive macro
@@ -393,6 +393,14 @@ impl HasDataLayout for TargetDataLayout {
393393
}
394394
}
395395

396+
// used by rust-analyzer
397+
impl HasDataLayout for &TargetDataLayout {
398+
#[inline]
399+
fn data_layout(&self) -> &TargetDataLayout {
400+
(**self).data_layout()
401+
}
402+
}
403+
396404
/// Endianness of the target, which must match cfg(target-endian).
397405
#[derive(Copy, Clone, PartialEq, Eq)]
398406
pub enum Endian {

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,14 +2066,14 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
20662066
};
20672067
}
20682068

2069-
arith_red!(simd_reduce_add_ordered: vector_reduce_add, vector_reduce_fadd, true, add, 0.0);
2069+
arith_red!(simd_reduce_add_ordered: vector_reduce_add, vector_reduce_fadd, true, add, -0.0);
20702070
arith_red!(simd_reduce_mul_ordered: vector_reduce_mul, vector_reduce_fmul, true, mul, 1.0);
20712071
arith_red!(
20722072
simd_reduce_add_unordered: vector_reduce_add,
20732073
vector_reduce_fadd_reassoc,
20742074
false,
20752075
add,
2076-
0.0
2076+
-0.0
20772077
);
20782078
arith_red!(
20792079
simd_reduce_mul_unordered: vector_reduce_mul,

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use std::{env, iter, mem, str};
77

88
use cc::windows_registry;
99
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
10-
use rustc_metadata::{find_native_static_library, try_find_native_static_library};
10+
use rustc_metadata::{
11+
find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,
12+
};
1113
use rustc_middle::bug;
1214
use rustc_middle::middle::dependency_format::Linkage;
1315
use rustc_middle::middle::exported_symbols;
@@ -876,7 +878,13 @@ impl<'a> Linker for MsvcLinker<'a> {
876878
}
877879

878880
fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, _as_needed: bool) {
879-
self.link_arg(format!("{}{}", name, if verbatim { "" } else { ".lib" }));
881+
// On MSVC-like targets rustc supports import libraries using alternative naming
882+
// scheme (`libfoo.a`) unsupported by linker, search for such libraries manually.
883+
if let Some(path) = try_find_native_dynamic_library(self.sess, name, verbatim) {
884+
self.link_arg(path);
885+
} else {
886+
self.link_arg(format!("{}{}", name, if verbatim { "" } else { ".lib" }));
887+
}
880888
}
881889

882890
fn link_dylib_by_path(&mut self, path: &Path, _as_needed: bool) {

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ pub fn valtree_to_const_value<'tcx>(
319319
let branches = valtree.unwrap_branch();
320320
// Find the non-ZST field. (There can be aligned ZST!)
321321
for (i, &inner_valtree) in branches.iter().enumerate() {
322-
let field = layout.field(&LayoutCx { tcx, param_env }, i);
322+
let field = layout.field(&LayoutCx::new(tcx, param_env), i);
323323
if !field.is_zst() {
324324
return valtree_to_const_value(tcx, param_env.and(field.ty), inner_valtree);
325325
}

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::mir::interpret::{
2121
UnsupportedOpInfo, ValidationErrorInfo,
2222
};
2323
use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout};
24-
use rustc_middle::ty::{self, Ty, TyCtxt};
24+
use rustc_middle::ty::{self, Ty};
2525
use rustc_span::symbol::{sym, Symbol};
2626
use rustc_target::abi::{
2727
Abi, FieldIdx, FieldsShape, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange,
@@ -940,7 +940,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
940940
) -> Cow<'e, RangeSet> {
941941
assert!(layout.ty.is_union());
942942
assert!(layout.abi.is_sized(), "there are no unsized unions");
943-
let layout_cx = LayoutCx { tcx: *ecx.tcx, param_env: ecx.param_env };
943+
let layout_cx = LayoutCx::new(*ecx.tcx, ecx.param_env);
944944
return M::cached_union_data_range(ecx, layout.ty, || {
945945
let mut out = RangeSet(Vec::new());
946946
union_data_range_uncached(&layout_cx, layout, Size::ZERO, &mut out);
@@ -949,7 +949,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
949949

950950
/// Helper for recursive traversal: add data ranges of the given type to `out`.
951951
fn union_data_range_uncached<'tcx>(
952-
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
952+
cx: &LayoutCx<'tcx>,
953953
layout: TyAndLayout<'tcx>,
954954
base_offset: Size,
955955
out: &mut RangeSet,

compiler/rustc_const_eval/src/util/check_validity_requirement.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use rustc_middle::bug;
2-
use rustc_middle::ty::layout::{LayoutCx, LayoutError, LayoutOf, TyAndLayout, ValidityRequirement};
2+
use rustc_middle::ty::layout::{
3+
HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout, ValidityRequirement,
4+
};
35
use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};
46
use rustc_target::abi::{Abi, FieldsShape, Scalar, Variants};
57

@@ -30,7 +32,7 @@ pub fn check_validity_requirement<'tcx>(
3032
return Ok(!layout.abi.is_uninhabited());
3133
}
3234

33-
let layout_cx = LayoutCx { tcx, param_env: param_env_and_ty.param_env };
35+
let layout_cx = LayoutCx::new(tcx, param_env_and_ty.param_env);
3436
if kind == ValidityRequirement::Uninit || tcx.sess.opts.unstable_opts.strict_init_checks {
3537
check_validity_requirement_strict(layout, &layout_cx, kind)
3638
} else {
@@ -42,12 +44,12 @@ pub fn check_validity_requirement<'tcx>(
4244
/// for details.
4345
fn check_validity_requirement_strict<'tcx>(
4446
ty: TyAndLayout<'tcx>,
45-
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
47+
cx: &LayoutCx<'tcx>,
4648
kind: ValidityRequirement,
4749
) -> Result<bool, &'tcx LayoutError<'tcx>> {
4850
let machine = CompileTimeMachine::new(CanAccessMutGlobal::No, CheckAlignment::Error);
4951

50-
let mut cx = InterpCx::new(cx.tcx, rustc_span::DUMMY_SP, cx.param_env, machine);
52+
let mut cx = InterpCx::new(cx.tcx(), rustc_span::DUMMY_SP, cx.param_env, machine);
5153

5254
let allocated = cx
5355
.allocate(ty, MemoryKind::Machine(crate::const_eval::MemoryKind::Heap))
@@ -80,7 +82,7 @@ fn check_validity_requirement_strict<'tcx>(
8082
/// function for details.
8183
fn check_validity_requirement_lax<'tcx>(
8284
this: TyAndLayout<'tcx>,
83-
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
85+
cx: &LayoutCx<'tcx>,
8486
init_kind: ValidityRequirement,
8587
) -> Result<bool, &'tcx LayoutError<'tcx>> {
8688
let scalar_allows_raw_init = move |s: Scalar| -> bool {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Something other than a type or const parameter has been used when one was
2+
expected.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0799
7+
fn bad1() -> impl Sized + use<main> {}
8+
9+
fn bad2(x: ()) -> impl Sized + use<x> {}
10+
11+
fn main() {}
12+
```
13+
14+
In the given examples, for `bad1`, the name `main` corresponds to a function
15+
rather than a type or const parameter. In `bad2`, the name `x` corresponds to
16+
a function argument rather than a type or const parameter.
17+
18+
Only type and const parameters, including `Self`, may be captured by
19+
`use<...>` precise capturing bounds.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A type or const parameter of the given name is not in scope.
2+
3+
Erroneous code examples:
4+
5+
```compile_fail,E0800
6+
fn missing() -> impl Sized + use<T> {}
7+
```
8+
9+
To fix this error, please verify you didn't misspell the type or const
10+
parameter, or double-check if you forgot to declare the parameter in
11+
the list of generics.

compiler/rustc_error_codes/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ E0795: 0795,
538538
E0796: 0796,
539539
E0797: 0797,
540540
E0798: 0798,
541+
E0799: 0799,
542+
E0800: 0800,
541543
);
542544
)
543545
}

0 commit comments

Comments
 (0)