Skip to content

Commit 8d3100e

Browse files
authored
Merge branch 'rust-lang:master' into feature-rustdoc-sort-traits
2 parents 0e4be77 + f609b7e commit 8d3100e

File tree

455 files changed

+5580
-5047
lines changed

Some content is hidden

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

455 files changed

+5580
-5047
lines changed

compiler/rustc_abi/src/layout.rs

+952-920
Large diffs are not rendered by default.

compiler/rustc_abi/src/lib.rs

+17-1
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 {
@@ -781,6 +789,14 @@ impl Align {
781789
}
782790

783791
/// A pair of alignments, ABI-mandated and preferred.
792+
///
793+
/// The "preferred" alignment is an LLVM concept that is virtually meaningless to Rust code:
794+
/// it is not exposed semantically to programmers nor can they meaningfully affect it.
795+
/// The only concern for us is that preferred alignment must not be less than the mandated alignment
796+
/// and thus in practice the two values are almost always identical.
797+
///
798+
/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
799+
/// It is of effectively no consequence for layout in structs and on the stack.
784800
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
785801
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
786802
pub struct AbiAndPrefAlign {

compiler/rustc_ast/src/ast.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ impl Expr {
12931293
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
12941294
ExprKind::Unary(..) => ExprPrecedence::Unary,
12951295
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) => ExprPrecedence::Lit,
1296-
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
1296+
ExprKind::Cast(..) => ExprPrecedence::Cast,
12971297
ExprKind::Let(..) => ExprPrecedence::Let,
12981298
ExprKind::If(..) => ExprPrecedence::If,
12991299
ExprKind::While(..) => ExprPrecedence::While,
@@ -1317,17 +1317,18 @@ impl Expr {
13171317
ExprKind::Break(..) => ExprPrecedence::Break,
13181318
ExprKind::Continue(..) => ExprPrecedence::Continue,
13191319
ExprKind::Ret(..) => ExprPrecedence::Ret,
1320-
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
1321-
ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf,
1322-
ExprKind::MacCall(..) => ExprPrecedence::Mac,
13231320
ExprKind::Struct(..) => ExprPrecedence::Struct,
13241321
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
13251322
ExprKind::Paren(..) => ExprPrecedence::Paren,
13261323
ExprKind::Try(..) => ExprPrecedence::Try,
13271324
ExprKind::Yield(..) => ExprPrecedence::Yield,
13281325
ExprKind::Yeet(..) => ExprPrecedence::Yeet,
1329-
ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs,
13301326
ExprKind::Become(..) => ExprPrecedence::Become,
1327+
ExprKind::InlineAsm(..)
1328+
| ExprKind::Type(..)
1329+
| ExprKind::OffsetOf(..)
1330+
| ExprKind::FormatArgs(..)
1331+
| ExprKind::MacCall(..) => ExprPrecedence::Mac,
13311332
ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err,
13321333
}
13331334
}

compiler/rustc_ast/src/util/parser.rs

-6
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,7 @@ pub enum ExprPrecedence {
265265
Field,
266266
Index,
267267
Try,
268-
InlineAsm,
269-
OffsetOf,
270268
Mac,
271-
FormatArgs,
272269

273270
Array,
274271
Repeat,
@@ -333,17 +330,14 @@ impl ExprPrecedence {
333330
| ExprPrecedence::ConstBlock
334331
| ExprPrecedence::Field
335332
| ExprPrecedence::ForLoop
336-
| ExprPrecedence::FormatArgs
337333
| ExprPrecedence::Gen
338334
| ExprPrecedence::If
339335
| ExprPrecedence::Index
340-
| ExprPrecedence::InlineAsm
341336
| ExprPrecedence::Lit
342337
| ExprPrecedence::Loop
343338
| ExprPrecedence::Mac
344339
| ExprPrecedence::Match
345340
| ExprPrecedence::MethodCall
346-
| ExprPrecedence::OffsetOf
347341
| ExprPrecedence::Paren
348342
| ExprPrecedence::Path
349343
| ExprPrecedence::PostfixMatch

compiler/rustc_ast_passes/src/feature_gate.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,9 @@ struct PostExpansionVisitor<'a> {
7575

7676
impl<'a> PostExpansionVisitor<'a> {
7777
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
78-
fn check_abi(&self, abi: ast::StrLit, constness: ast::Const) {
78+
fn check_abi(&self, abi: ast::StrLit) {
7979
let ast::StrLit { symbol_unescaped, span, .. } = abi;
8080

81-
if let ast::Const::Yes(_) = constness {
82-
match symbol_unescaped {
83-
// Stable
84-
sym::Rust | sym::C => {}
85-
abi => gate!(
86-
&self,
87-
const_extern_fn,
88-
span,
89-
format!("`{}` as a `const fn` ABI is unstable", abi)
90-
),
91-
}
92-
}
93-
9481
match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
9582
Ok(()) => (),
9683
Err(abi::AbiDisabled::Unstable { feature, explain }) => {
@@ -110,9 +97,9 @@ impl<'a> PostExpansionVisitor<'a> {
11097
}
11198
}
11299

113-
fn check_extern(&self, ext: ast::Extern, constness: ast::Const) {
100+
fn check_extern(&self, ext: ast::Extern) {
114101
if let ast::Extern::Explicit(abi, _) = ext {
115-
self.check_abi(abi, constness);
102+
self.check_abi(abi);
116103
}
117104
}
118105

@@ -239,7 +226,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
239226
match &i.kind {
240227
ast::ItemKind::ForeignMod(foreign_module) => {
241228
if let Some(abi) = foreign_module.abi {
242-
self.check_abi(abi, ast::Const::No);
229+
self.check_abi(abi);
243230
}
244231
}
245232

@@ -341,7 +328,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
341328
match &ty.kind {
342329
ast::TyKind::BareFn(bare_fn_ty) => {
343330
// Function pointers cannot be `const`
344-
self.check_extern(bare_fn_ty.ext, ast::Const::No);
331+
self.check_extern(bare_fn_ty.ext);
345332
self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params);
346333
}
347334
ast::TyKind::Never => {
@@ -446,7 +433,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
446433
fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) {
447434
if let Some(header) = fn_kind.header() {
448435
// Stability of const fn methods are covered in `visit_assoc_item` below.
449-
self.check_extern(header.ext, header.constness);
436+
self.check_extern(header.ext);
450437
}
451438

452439
if let FnKind::Closure(ast::ClosureBinder::For { generic_params, .. }, ..) = fn_kind {

compiler/rustc_codegen_llvm/src/back/write.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,13 @@ pub(crate) fn target_machine_factory(
185185
let reloc_model = to_llvm_relocation_model(sess.relocation_model());
186186

187187
let (opt_level, _) = to_llvm_opt_settings(optlvl);
188-
let use_softfp = sess.opts.cg.soft_float;
188+
let use_softfp = if sess.target.arch == "arm" && sess.target.abi == "eabihf" {
189+
sess.opts.cg.soft_float
190+
} else {
191+
// `validate_commandline_args_with_session_available` has already warned about this being ignored.
192+
// Let's make sure LLVM doesn't suddenly start using this flag on more targets.
193+
false
194+
};
189195

190196
let ffunction_sections =
191197
sess.opts.unstable_opts.function_sections.unwrap_or(sess.target.function_sections);

compiler/rustc_codegen_llvm/src/intrinsic.rs

+2-2
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/archive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub trait ArchiveBuilderBuilder {
157157
}
158158
}
159159

160-
pub fn create_mingw_dll_import_lib(
160+
fn create_mingw_dll_import_lib(
161161
sess: &Session,
162162
lib_name: &str,
163163
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,

compiler/rustc_codegen_ssa/src/back/command.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{fmt, io, mem};
88
use rustc_target::spec::LldFlavor;
99

1010
#[derive(Clone)]
11-
pub struct Command {
11+
pub(crate) struct Command {
1212
program: Program,
1313
args: Vec<OsString>,
1414
env: Vec<(OsString, OsString)>,
@@ -23,28 +23,28 @@ enum Program {
2323
}
2424

2525
impl Command {
26-
pub fn new<P: AsRef<OsStr>>(program: P) -> Command {
26+
pub(crate) fn new<P: AsRef<OsStr>>(program: P) -> Command {
2727
Command::_new(Program::Normal(program.as_ref().to_owned()))
2828
}
2929

30-
pub fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
30+
pub(crate) fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
3131
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
3232
}
3333

34-
pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
34+
pub(crate) fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
3535
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
3636
}
3737

3838
fn _new(program: Program) -> Command {
3939
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
4040
}
4141

42-
pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
42+
pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
4343
self._arg(arg.as_ref());
4444
self
4545
}
4646

47-
pub fn args<I>(&mut self, args: I) -> &mut Command
47+
pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
4848
where
4949
I: IntoIterator<Item: AsRef<OsStr>>,
5050
{
@@ -58,7 +58,7 @@ impl Command {
5858
self.args.push(arg.to_owned());
5959
}
6060

61-
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
61+
pub(crate) fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
6262
where
6363
K: AsRef<OsStr>,
6464
V: AsRef<OsStr>,
@@ -71,7 +71,7 @@ impl Command {
7171
self.env.push((key.to_owned(), value.to_owned()));
7272
}
7373

74-
pub fn env_remove<K>(&mut self, key: K) -> &mut Command
74+
pub(crate) fn env_remove<K>(&mut self, key: K) -> &mut Command
7575
where
7676
K: AsRef<OsStr>,
7777
{
@@ -83,11 +83,11 @@ impl Command {
8383
self.env_remove.push(key.to_owned());
8484
}
8585

86-
pub fn output(&mut self) -> io::Result<Output> {
86+
pub(crate) fn output(&mut self) -> io::Result<Output> {
8787
self.command().output()
8888
}
8989

90-
pub fn command(&self) -> process::Command {
90+
pub(crate) fn command(&self) -> process::Command {
9191
let mut ret = match self.program {
9292
Program::Normal(ref p) => process::Command::new(p),
9393
Program::CmdBatScript(ref p) => {
@@ -111,17 +111,17 @@ impl Command {
111111

112112
// extensions
113113

114-
pub fn get_args(&self) -> &[OsString] {
114+
pub(crate) fn get_args(&self) -> &[OsString] {
115115
&self.args
116116
}
117117

118-
pub fn take_args(&mut self) -> Vec<OsString> {
118+
pub(crate) fn take_args(&mut self) -> Vec<OsString> {
119119
mem::take(&mut self.args)
120120
}
121121

122122
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
123123
/// or `false` if we should attempt to spawn and see what the OS says.
124-
pub fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
124+
pub(crate) fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
125125
// We mostly only care about Windows in this method, on Unix the limits
126126
// can be gargantuan anyway so we're pretty unlikely to hit them
127127
if cfg!(unix) {

0 commit comments

Comments
 (0)