Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #130247

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5396124
Update compiler-builtins to 0.1.125
alexcrichton Sep 5, 2024
7ed9f94
Don't leave debug locations for constants sitting on the builder inde…
khuey Sep 6, 2024
f98ca32
Fix linking error when compiling for 32-bit watchOS
madsmtm Sep 7, 2024
0b20ffc
Remove needless returns detected by clippy in the compiler
eduardosm Sep 9, 2024
ce47935
remove dead code in CGREP script
jyn514 Dec 24, 2023
6ce3c6c
give a better error for tuple structs in `derive(Diagnostic)`
jyn514 Dec 24, 2023
b58c2fb
show linker warnings even if it returns 0
jyn514 Dec 24, 2023
6b77d59
don't show the full linker args unless `--verbose` is passed
jyn514 Dec 25, 2023
56b8c94
don't pass `-L .../auxiliary` unless it exists
Jan 28, 2024
2f1e1be
maint: update docs for change_time ext and doc links
juliusl Sep 9, 2024
a0a89e5
chore: removing supporting links in favor of existing doc-comment style
juliusl Sep 9, 2024
713828d
Add test for S_OBJNAME and update test for LF_BUILDINFO cl and cmd for
nebulark Sep 6, 2024
180eace
these tests seem to work fine on i586 these days
RalfJung Aug 31, 2024
c40ee79
move float tests into their own dir
workingjubilee Sep 10, 2024
3daa951
enable and extend float-classify test
RalfJung Aug 31, 2024
e556c13
clean up internal comments about float semantics
RalfJung Aug 31, 2024
b44f1dd
update stdarch
RalfJung Aug 28, 2024
542a6c6
miri: support vector index arguments in simd_shuffle
RalfJung Sep 11, 2024
5b7be14
Revert warning empty patterns as unreachable
Nadrieril Aug 28, 2024
6c84238
docs: remove struct info
juliusl Sep 11, 2024
3842ea6
miri: fix overflow detection for unsigned pointer offset
RalfJung Sep 11, 2024
5527076
chore: remove struct details
juliusl Sep 11, 2024
ac27367
Rollup merge of #119286 - jyn514:linker-output, r=bjorn3
workingjubilee Sep 11, 2024
70b92e3
Rollup merge of #129103 - Nadrieril:dont-warn-empty-unreachable, r=co…
workingjubilee Sep 11, 2024
bf9a415
Rollup merge of #129696 - RalfJung:stdarch, r=Amanieu
workingjubilee Sep 11, 2024
fbb73c4
Rollup merge of #129835 - RalfJung:float-tests, r=workingjubilee
workingjubilee Sep 11, 2024
c266516
Rollup merge of #129992 - alexcrichton:update-compiler-builtins, r=tg…
workingjubilee Sep 11, 2024
a498fdc
Rollup merge of #130052 - khuey:clear-dilocation-after-const-emission…
workingjubilee Sep 11, 2024
2994fde
Rollup merge of #130077 - madsmtm:watchos-arm-unwind, r=workingjubilee
workingjubilee Sep 11, 2024
9e42180
Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errors
workingjubilee Sep 11, 2024
d86d1ad
Rollup merge of #130156 - nebulark:test_buildinfo, r=jieyouxu
workingjubilee Sep 11, 2024
0ad8638
Rollup merge of #130168 - juliusl:pr/fix-win-fs-change-time-links, r=…
workingjubilee Sep 11, 2024
b867f89
Rollup merge of #130239 - RalfJung:miri-ptr-offset-unsigned, r=compil…
workingjubilee Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/ast_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl HasTokens for StmtKind {
StmtKind::Let(local) => local.tokens.as_ref(),
StmtKind::Item(item) => item.tokens(),
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
StmtKind::Empty => return None,
StmtKind::Empty => None,
StmtKind::MacCall(mac) => mac.tokens.as_ref(),
}
}
Expand All @@ -162,7 +162,7 @@ impl HasTokens for StmtKind {
StmtKind::Let(local) => Some(&mut local.tokens),
StmtKind::Item(item) => item.tokens_mut(),
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
StmtKind::Empty => return None,
StmtKind::Empty => None,
StmtKind::MacCall(mac) => Some(&mut mac.tokens),
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,5 +1240,5 @@ pub fn parse_confusables(attr: &Attribute) -> Option<Vec<Symbol>> {
candidates.push(meta_lit.symbol);
}

return Some(candidates);
Some(candidates)
}
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
reinits.push(location);
return true;
}
return false;
false
};

while let Some(location) = stack.pop() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
let delegate = FnMutDelegate {
regions: &mut |br: ty::BoundRegion| {
if let Some(ex_reg_var) = reg_map.get(&br) {
return *ex_reg_var;
*ex_reg_var
} else {
let ex_reg_var = self.next_existential_region_var(true, br.kind.get_name());
debug!(?ex_reg_var);
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_gcc/src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation) {
self.location = Some(dbg_loc);
}

fn clear_dbg_loc(&mut self) {
self.location = None;
}
}

/// Generate the `debug_context` in an MIR Body.
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![doc = include_str!("doc.md")]

use std::cell::{OnceCell, RefCell};
use std::iter;
use std::ops::Range;
use std::{iter, ptr};

use libc::c_uint;
use rustc_codegen_ssa::debuginfo::type_names;
Expand Down Expand Up @@ -209,6 +209,12 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
}
}

fn clear_dbg_loc(&mut self) {
unsafe {
llvm::LLVMSetCurrentDebugLocation2(self.llbuilder, ptr::null());
}
}

fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ unsafe extern "C" {
pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);

// Metadata
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: &'a Metadata);
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata);

// Terminators
pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ pub(crate) fn check_tied_features(
}
}
}
return None;
None
}

/// Used to generate cfg variables and apply features
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ codegen_ssa_linker_file_stem = couldn't extract file stem from specified linker
codegen_ssa_linker_not_found = linker `{$linker_path}` not found
.note = {$error}

codegen_ssa_linker_output = {$inner}

codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for current linker

codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}
Expand Down
35 changes: 29 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_macros::Diagnostic;
use rustc_metadata::fs::{copy_to_stdout, emit_wrapper_file, METADATA_FILENAME};
use rustc_metadata::{find_native_static_library, walk_native_lib_search_dirs};
use rustc_middle::bug;
Expand Down Expand Up @@ -438,7 +439,7 @@ fn link_rlib<'a>(
ab.add_file(&lib)
}

return Ok(ab);
Ok(ab)
}

/// Extract all symbols defined in raw-dylib libraries, collated by library name.
Expand Down Expand Up @@ -750,6 +751,14 @@ fn link_dwarf_object(sess: &Session, cg_results: &CodegenResults, executable_out
}
}

#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_output)]
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
/// end up with inconsistent languages within the same diagnostic.
struct LinkerOutput {
inner: String,
}

/// Create a dynamic library or executable.
///
/// This will invoke the system linker/cc to create the resulting file. This links to all upstream
Expand Down Expand Up @@ -976,12 +985,12 @@ fn link_natively(
let mut output = prog.stderr.clone();
output.extend_from_slice(&prog.stdout);
let escaped_output = escape_linker_output(&output, flavor);
// FIXME: Add UI tests for this error.
let err = errors::LinkingFailed {
linker_path: &linker_path,
exit_status: prog.status,
command: &cmd,
escaped_output,
verbose: sess.opts.verbose,
};
sess.dcx().emit_err(err);
// If MSVC's `link.exe` was expected but the return code
Expand Down Expand Up @@ -1022,8 +1031,22 @@ fn link_natively(

sess.dcx().abort_if_errors();
}
info!("linker stderr:\n{}", escape_string(&prog.stderr));
info!("linker stdout:\n{}", escape_string(&prog.stdout));

if !prog.stderr.is_empty() {
// We already print `warning:` at the start of the diagnostic. Remove it from the linker output if present.
let stderr = escape_string(&prog.stderr);
debug!("original stderr: {stderr}");
let stderr = stderr
.strip_prefix("warning: ")
.unwrap_or(&stderr)
.replace(": warning: ", ": ");
sess.dcx().emit_warn(LinkerOutput { inner: format!("linker stderr: {stderr}") });
}
if !prog.stdout.is_empty() && sess.opts.verbose {
sess.dcx().emit_warn(LinkerOutput {
inner: format!("linker stdout: {}", escape_string(&prog.stdout)),
});
}
}
Err(e) => {
let linker_not_found = e.kind() == io::ErrorKind::NotFound;
Expand Down Expand Up @@ -1319,15 +1342,15 @@ fn link_sanitizer_runtime(
fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf {
let path = sess.target_tlib_path.dir.join(filename);
if path.exists() {
return sess.target_tlib_path.dir.clone();
sess.target_tlib_path.dir.clone()
} else {
let default_sysroot =
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
let default_tlib = filesearch::make_target_lib_path(
&default_sysroot,
sess.opts.target_triple.triple(),
);
return default_tlib;
default_tlib
}
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,6 @@ impl<'a> Linker for L4Bender<'a> {
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
// ToDo, not implemented, copy from GCC
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
return;
}

fn subsystem(&mut self, subsystem: &str) {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a
"Metadata at offset {offset} with size {len} is beyond .info section"
));
}
return Ok(&info_data[offset..(offset + len)]);
Ok(&info_data[offset..(offset + len)])
} else {
return Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"));
};
Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"))
}
}

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

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

pub enum MetadataPosition {
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ pub struct LinkingFailed<'a> {
pub exit_status: ExitStatus,
pub command: &'a Command,
pub escaped_output: String,
pub verbose: bool,
}

impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
Expand All @@ -358,7 +359,13 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {

let contains_undefined_ref = self.escaped_output.contains("undefined reference to");

diag.note(format!("{:?}", self.command)).note(self.escaped_output);
if self.verbose {
diag.note(format!("{:?}", self.command));
} else {
diag.note("use `--verbose` to show all linker arguments");
}

diag.note(self.escaped_output);

// Trying to match an error from OS linkers
// which by now we have no way to translate.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
self.set_debug_loc(bx, var.source_info);
let base =
Self::spill_operand_to_stack(operand, Some(var.name.to_string()), bx);
bx.clear_dbg_loc();

bx.dbg_var_addr(
dbg_var,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/traits/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub trait DebugInfoBuilderMethods: BackendTypes {
fragment: Option<Range<Size>>,
);
fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
fn clear_dbg_loc(&mut self);
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
fn set_var_name(&mut self, value: Self::Value, name: &str);
}
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
if self.layout_compat(caller_abi.layout, callee_abi.layout)? {
// Ensure that our checks imply actual ABI compatibility for this concrete call.
assert!(caller_abi.eq_abi(callee_abi));
return Ok(true);
Ok(true)
} else {
trace!(
"check_argument_compat: incompatible ABIs:\ncaller: {:?}\ncallee: {:?}",
caller_abi, callee_abi
);
return Ok(false);
Ok(false)
}
}

Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
let pointee_layout = self.layout_of(pointee_ty)?;
assert!(pointee_layout.abi.is_sized());

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

let offset_bytes = val.to_target_isize(self)?;
if !right.layout.abi.is_signed() && offset_bytes < 0 {
// We were supposed to do an unsigned offset but the result is negative -- this
// can only mean that the cast wrapped around.
throw_ub!(PointerArithOverflow)
}
let offset_ptr = self.ptr_offset_inbounds(ptr, offset_bytes)?;
Ok(ImmTy::from_scalar(Scalar::from_maybe_pointer(offset_ptr, self), left.layout))
}
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_expand/src/mbe/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,34 +773,34 @@ fn extract_symbol_from_pnr<'a>(
match pnr {
ParseNtResult::Ident(nt_ident, is_raw) => {
if let IdentIsRaw::Yes = is_raw {
return Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR));
Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR))
} else {
Ok(nt_ident.name)
}
return Ok(nt_ident.name);
}
ParseNtResult::Tt(TokenTree::Token(
Token { kind: TokenKind::Ident(symbol, is_raw), .. },
_,
)) => {
if let IdentIsRaw::Yes = is_raw {
return Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR));
Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR))
} else {
Ok(*symbol)
}
return Ok(*symbol);
}
ParseNtResult::Tt(TokenTree::Token(
Token {
kind: TokenKind::Literal(Lit { kind: LitKind::Str, symbol, suffix: None }),
..
},
_,
)) => {
return Ok(*symbol);
}
)) => Ok(*symbol),
ParseNtResult::Nt(nt)
if let Nonterminal::NtLiteral(expr) = &**nt
&& let ExprKind::Lit(Lit { kind: LitKind::Str, symbol, suffix: None }) =
&expr.kind =>
{
return Ok(*symbol);
Ok(*symbol)
}
_ => Err(dcx
.struct_err(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ fn report_trait_method_mismatch<'tcx>(
false,
);

return diag.emit();
diag.emit()
}

fn check_region_bounds_on_impl_item<'tcx>(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
return false;
}

return true;
true
})
.collect::<Vec<_>>();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Abi::Rust,
));

return Some(ExpectedSig { cause_span, sig });
Some(ExpectedSig { cause_span, sig })
}

fn sig_of_closure(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return true;
}
}
return false;
false
}

fn explain_self_literal(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'tcx> ArgMatrix<'tcx> {
permutation.into_iter().map(|x| x.unwrap()).collect();
return Some(Issue::Permutation(final_permutation));
}
return None;
None
}

// Obviously, detecting exact user intention is impossible, so the goal here is to
Expand Down Expand Up @@ -410,6 +410,6 @@ impl<'tcx> ArgMatrix<'tcx> {
// sort errors with same type by the order they appear in the source
// so that suggestion will be handled properly, see #112507
errors.sort();
return (errors, matched_inputs);
(errors, matched_inputs)
}
}
Loading
Loading