Skip to content

Commit 93ef7cd

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 2f09cac + b72b42d commit 93ef7cd

File tree

152 files changed

+1903
-2047
lines changed

Some content is hidden

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

152 files changed

+1903
-2047
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,11 +2418,22 @@ impl InlineAsmOperand {
24182418
}
24192419
}
24202420

2421+
#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic)]
2422+
pub enum AsmMacro {
2423+
/// The `asm!` macro
2424+
Asm,
2425+
/// The `global_asm!` macro
2426+
GlobalAsm,
2427+
/// The `naked_asm!` macro
2428+
NakedAsm,
2429+
}
2430+
24212431
/// Inline assembly.
24222432
///
24232433
/// E.g., `asm!("NOP");`.
24242434
#[derive(Clone, Encodable, Decodable, Debug)]
24252435
pub struct InlineAsm {
2436+
pub asm_macro: AsmMacro,
24262437
pub template: Vec<InlineAsmTemplatePiece>,
24272438
pub template_strs: Box<[(Symbol, Option<Symbol>, Span)]>,
24282439
pub operands: Vec<(InlineAsmOperand, Span)>,

compiler/rustc_ast/src/ast_traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl HasTokens for StmtKind {
153153
StmtKind::Let(local) => local.tokens.as_ref(),
154154
StmtKind::Item(item) => item.tokens(),
155155
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
156-
StmtKind::Empty => return None,
156+
StmtKind::Empty => None,
157157
StmtKind::MacCall(mac) => mac.tokens.as_ref(),
158158
}
159159
}
@@ -162,7 +162,7 @@ impl HasTokens for StmtKind {
162162
StmtKind::Let(local) => Some(&mut local.tokens),
163163
StmtKind::Item(item) => item.tokens_mut(),
164164
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
165-
StmtKind::Empty => return None,
165+
StmtKind::Empty => None,
166166
StmtKind::MacCall(mac) => Some(&mut mac.tokens),
167167
}
168168
}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ fn walk_anon_const<T: MutVisitor>(vis: &mut T, AnonConst { id, value }: &mut Ano
13881388
fn walk_inline_asm<T: MutVisitor>(vis: &mut T, asm: &mut InlineAsm) {
13891389
// FIXME: Visit spans inside all this currently ignored stuff.
13901390
let InlineAsm {
1391+
asm_macro: _,
13911392
template: _,
13921393
template_strs: _,
13931394
operands,

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ pub fn walk_anon_const<'a, V: Visitor<'a>>(visitor: &mut V, constant: &'a AnonCo
976976

977977
pub fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm) -> V::Result {
978978
let InlineAsm {
979+
asm_macro: _,
979980
template: _,
980981
template_strs: _,
981982
operands,

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
474474
);
475475
let line_spans =
476476
self.arena.alloc_from_iter(asm.line_spans.iter().map(|span| self.lower_span(*span)));
477-
let hir_asm =
478-
hir::InlineAsm { template, template_strs, operands, options: asm.options, line_spans };
477+
let hir_asm = hir::InlineAsm {
478+
asm_macro: asm.asm_macro,
479+
template,
480+
template_strs,
481+
operands,
482+
options: asm.options,
483+
line_spans,
484+
};
479485
self.arena.alloc(hir_asm)
480486
}
481487
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18371837
Safety::Default,
18381838
sym::allow,
18391839
sym::unreachable_code,
1840-
self.lower_span(span),
1840+
try_span,
18411841
);
18421842
let attrs: AttrVec = thin_vec![attr];
18431843

compiler/rustc_attr/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,5 +1240,5 @@ pub fn parse_confusables(attr: &Attribute) -> Option<Vec<Symbol>> {
12401240
candidates.push(meta_lit.symbol);
12411241
}
12421242

1243-
return Some(candidates);
1243+
Some(candidates)
12441244
}

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
36693669
reinits.push(location);
36703670
return true;
36713671
}
3672-
return false;
3672+
false
36733673
};
36743674

36753675
while let Some(location) = stack.pop() {

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
214214
let delegate = FnMutDelegate {
215215
regions: &mut |br: ty::BoundRegion| {
216216
if let Some(ex_reg_var) = reg_map.get(&br) {
217-
return *ex_reg_var;
217+
*ex_reg_var
218218
} else {
219219
let ex_reg_var = self.next_existential_region_var(true, br.kind.get_name());
220220
debug!(?ex_reg_var);

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use lint::BuiltinLintDiag;
33
use rustc_ast::ptr::P;
44
use rustc_ast::token::{self, Delimiter};
55
use rustc_ast::tokenstream::TokenStream;
6+
use rustc_ast::AsmMacro;
67
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
78
use rustc_errors::PResult;
89
use rustc_expand::base::*;
@@ -484,6 +485,7 @@ fn parse_reg<'a>(
484485

485486
fn expand_preparsed_asm(
486487
ecx: &mut ExtCtxt<'_>,
488+
asm_macro: ast::AsmMacro,
487489
args: AsmArgs,
488490
) -> ExpandResult<Result<ast::InlineAsm, ErrorGuaranteed>, ()> {
489491
let mut template = vec![];
@@ -774,6 +776,7 @@ fn expand_preparsed_asm(
774776
}
775777

776778
ExpandResult::Ready(Ok(ast::InlineAsm {
779+
asm_macro,
777780
template,
778781
template_strs: template_strs.into_boxed_slice(),
779782
operands: args.operands,
@@ -790,7 +793,7 @@ pub(super) fn expand_asm<'cx>(
790793
) -> MacroExpanderResult<'cx> {
791794
ExpandResult::Ready(match parse_args(ecx, sp, tts, false) {
792795
Ok(args) => {
793-
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, args) else {
796+
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, AsmMacro::Asm, args) else {
794797
return ExpandResult::Retry(());
795798
};
796799
let expr = match mac {
@@ -819,7 +822,8 @@ pub(super) fn expand_naked_asm<'cx>(
819822
) -> MacroExpanderResult<'cx> {
820823
ExpandResult::Ready(match parse_args(ecx, sp, tts, false) {
821824
Ok(args) => {
822-
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, args) else {
825+
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, AsmMacro::NakedAsm, args)
826+
else {
823827
return ExpandResult::Retry(());
824828
};
825829
let expr = match mac {
@@ -857,7 +861,8 @@ pub(super) fn expand_global_asm<'cx>(
857861
) -> MacroExpanderResult<'cx> {
858862
ExpandResult::Ready(match parse_args(ecx, sp, tts, true) {
859863
Ok(args) => {
860-
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, args) else {
864+
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, AsmMacro::GlobalAsm, args)
865+
else {
861866
return ExpandResult::Retry(());
862867
};
863868
match mac {

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ pub(crate) fn expand_test_or_bench(
277277
cx.attr_nested_word(sym::cfg, sym::test, attr_sp),
278278
// #[rustc_test_marker = "test_case_sort_key"]
279279
cx.attr_name_value_str(sym::rustc_test_marker, test_path_symbol, attr_sp),
280+
// #[doc(hidden)]
281+
cx.attr_nested_word(sym::doc, sym::hidden, attr_sp),
280282
],
281283
// const $ident: test::TestDescAndFn =
282284
ast::ItemKind::Const(

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
326326
let main_attr = ecx.attr_word(sym::rustc_main, sp);
327327
// #[coverage(off)]
328328
let coverage_attr = ecx.attr_nested_word(sym::coverage, sym::off, sp);
329-
// #[allow(missing_docs)]
330-
let missing_docs_attr = ecx.attr_nested_word(sym::allow, sym::missing_docs, sp);
329+
// #[doc(hidden)]
330+
let doc_hidden_attr = ecx.attr_nested_word(sym::doc, sym::hidden, sp);
331331

332332
// pub fn main() { ... }
333333
let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(ThinVec::new()));
@@ -357,7 +357,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
357357

358358
let main = P(ast::Item {
359359
ident: main_id,
360-
attrs: thin_vec![main_attr, coverage_attr, missing_docs_attr],
360+
attrs: thin_vec![main_attr, coverage_attr, doc_hidden_attr],
361361
id: ast::DUMMY_NODE_ID,
362362
kind: main,
363363
vis: ast::Visibility { span: sp, kind: ast::VisibilityKind::Public, tokens: None },

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub(crate) fn check_tied_features(
290290
}
291291
}
292292
}
293-
return None;
293+
None
294294
}
295295

296296
/// Used to generate cfg variables and apply features

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ fn link_rlib<'a>(
438438
ab.add_file(&lib)
439439
}
440440

441-
return Ok(ab);
441+
Ok(ab)
442442
}
443443

444444
/// Extract all symbols defined in raw-dylib libraries, collated by library name.
@@ -1319,15 +1319,15 @@ fn link_sanitizer_runtime(
13191319
fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf {
13201320
let path = sess.target_tlib_path.dir.join(filename);
13211321
if path.exists() {
1322-
return sess.target_tlib_path.dir.clone();
1322+
sess.target_tlib_path.dir.clone()
13231323
} else {
13241324
let default_sysroot =
13251325
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
13261326
let default_tlib = filesearch::make_target_lib_path(
13271327
&default_sysroot,
13281328
sess.opts.target_triple.triple(),
13291329
);
1330-
return default_tlib;
1330+
default_tlib
13311331
}
13321332
}
13331333

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,6 @@ impl<'a> Linker for L4Bender<'a> {
14841484
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
14851485
// ToDo, not implemented, copy from GCC
14861486
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
1487-
return;
14881487
}
14891488

14901489
fn subsystem(&mut self, subsystem: &str) {

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a
171171
"Metadata at offset {offset} with size {len} is beyond .info section"
172172
));
173173
}
174-
return Ok(&info_data[offset..(offset + len)]);
174+
Ok(&info_data[offset..(offset + len)])
175175
} else {
176-
return Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"));
177-
};
176+
Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"))
177+
}
178178
}
179179

180180
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
@@ -413,7 +413,7 @@ fn macho_object_build_version_for_target(target: &Target) -> object::write::Mach
413413

414414
/// Is Apple's CPU subtype `arm64e`s
415415
fn macho_is_arm64e(target: &Target) -> bool {
416-
return target.llvm_target.starts_with("arm64e");
416+
target.llvm_target.starts_with("arm64e")
417417
}
418418

419419
pub enum MetadataPosition {

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
235235
if self.layout_compat(caller_abi.layout, callee_abi.layout)? {
236236
// Ensure that our checks imply actual ABI compatibility for this concrete call.
237237
assert!(caller_abi.eq_abi(callee_abi));
238-
return Ok(true);
238+
Ok(true)
239239
} else {
240240
trace!(
241241
"check_argument_compat: incompatible ABIs:\ncaller: {:?}\ncallee: {:?}",
242242
caller_abi, callee_abi
243243
);
244-
return Ok(false);
244+
Ok(false)
245245
}
246246
}
247247

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for ImmTy<'tcx, Prov> {
433433
Ok(self.offset_(offset, layout, ecx))
434434
}
435435

436+
#[inline(always)]
436437
fn to_op<M: Machine<'tcx, Provenance = Prov>>(
437438
&self,
438439
_ecx: &InterpCx<'tcx, M>,
@@ -522,6 +523,7 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for OpTy<'tcx, Prov> {
522523
}
523524
}
524525

526+
#[inline(always)]
525527
fn to_op<M: Machine<'tcx, Provenance = Prov>>(
526528
&self,
527529
_ecx: &InterpCx<'tcx, M>,

compiler/rustc_const_eval/src/interpret/operator.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
303303
let pointee_layout = self.layout_of(pointee_ty)?;
304304
assert!(pointee_layout.abi.is_sized());
305305

306-
// We cannot overflow i64 as a type's size must be <= isize::MAX.
306+
// The size always fits in `i64` as it can be at most `isize::MAX`.
307307
let pointee_size = i64::try_from(pointee_layout.size.bytes()).unwrap();
308+
// This uses the same type as `right`, which can be `isize` or `usize`.
309+
// `pointee_size` is guaranteed to fit into both types.
308310
let pointee_size = ImmTy::from_int(pointee_size, right.layout);
309311
// Multiply element size and element count.
310312
let (val, overflowed) = self
@@ -316,6 +318,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
316318
}
317319

318320
let offset_bytes = val.to_target_isize(self)?;
321+
if !right.layout.abi.is_signed() && offset_bytes < 0 {
322+
// We were supposed to do an unsigned offset but the result is negative -- this
323+
// can only mean that the cast wrapped around.
324+
throw_ub!(PointerArithOverflow)
325+
}
319326
let offset_ptr = self.ptr_offset_inbounds(ptr, offset_bytes)?;
320327
Ok(ImmTy::from_scalar(Scalar::from_maybe_pointer(offset_ptr, self), left.layout))
321328
}

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for MPlaceTy<'tcx, Prov> {
166166
Ok(MPlaceTy { mplace: self.mplace.offset_with_meta_(offset, mode, meta, ecx)?, layout })
167167
}
168168

169+
#[inline(always)]
169170
fn to_op<M: Machine<'tcx, Provenance = Prov>>(
170171
&self,
171172
_ecx: &InterpCx<'tcx, M>,
@@ -299,6 +300,7 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for PlaceTy<'tcx, Prov> {
299300
})
300301
}
301302

303+
#[inline(always)]
302304
fn to_op<M: Machine<'tcx, Provenance = Prov>>(
303305
&self,
304306
ecx: &InterpCx<'tcx, M>,
@@ -560,6 +562,7 @@ where
560562

561563
/// Given a place, returns either the underlying mplace or a reference to where the value of
562564
/// this place is stored.
565+
#[inline(always)]
563566
fn as_mplace_or_mutable_local(
564567
&mut self,
565568
place: &PlaceTy<'tcx, M::Provenance>,

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use std::thread::panicking;
88

99
use rustc_data_structures::fx::FxIndexMap;
1010
use rustc_error_messages::{fluent_value_from_str_list_sep_by_and, FluentValue};
11-
use rustc_lint_defs::{Applicability, LintExpectationId};
11+
use rustc_lint_defs::Applicability;
1212
use rustc_macros::{Decodable, Encodable};
1313
use rustc_span::source_map::Spanned;
1414
use rustc_span::symbol::Symbol;
15-
use rustc_span::{AttrId, Span, DUMMY_SP};
15+
use rustc_span::{Span, DUMMY_SP};
1616
use tracing::debug;
1717

1818
use crate::snippet::Style;
@@ -354,26 +354,6 @@ impl DiagInner {
354354
}
355355
}
356356

357-
pub(crate) fn update_unstable_expectation_id(
358-
&mut self,
359-
unstable_to_stable: &FxIndexMap<AttrId, LintExpectationId>,
360-
) {
361-
if let Level::Expect(expectation_id) | Level::ForceWarning(Some(expectation_id)) =
362-
&mut self.level
363-
&& let LintExpectationId::Unstable { attr_id, lint_index } = *expectation_id
364-
{
365-
// The unstable to stable map only maps the unstable `AttrId` to a stable `HirId` with an attribute index.
366-
// The lint index inside the attribute is manually transferred here.
367-
let Some(stable_id) = unstable_to_stable.get(&attr_id) else {
368-
panic!("{expectation_id:?} must have a matching stable id")
369-
};
370-
371-
let mut stable_id = *stable_id;
372-
stable_id.set_lint_index(lint_index);
373-
*expectation_id = stable_id;
374-
}
375-
}
376-
377357
/// Indicates whether this diagnostic should show up in cargo's future breakage report.
378358
pub(crate) fn has_future_breakage(&self) -> bool {
379359
matches!(self.is_lint, Some(IsLint { has_future_breakage: true, .. }))

0 commit comments

Comments
 (0)