Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 083f2c8

Browse files
committed
Auto merge of rust-lang#130247 - workingjubilee:rollup-fjyvh47, r=workingjubilee
Rollup of 11 pull requests Successful merges: - rust-lang#119286 (show linker output even if the linker succeeds) - rust-lang#129103 (Don't warn empty branches unreachable for now) - rust-lang#129696 (update stdarch) - rust-lang#129835 (enable const-float-classify test, and test_next_up/down on 32bit x86) - rust-lang#129992 (Update compiler-builtins to 0.1.125) - rust-lang#130052 (Don't leave debug locations for constants sitting on the builder indefinitely) - rust-lang#130077 (Fix linking error when compiling for 32-bit watchOS) - rust-lang#130114 (Remove needless returns detected by clippy in the compiler) - rust-lang#130156 (Add test for S_OBJNAME & update test for LF_BUILDINFO cl and cmd) - rust-lang#130168 (maint: update docs for change_time ext and doc links) - rust-lang#130239 (miri: fix overflow detection for unsigned pointer offset) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8d6b88b + b867f89 commit 083f2c8

File tree

112 files changed

+903
-1039
lines changed

Some content is hidden

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

112 files changed

+903
-1039
lines changed

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_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_codegen_gcc/src/debuginfo.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
4848
fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation) {
4949
self.location = Some(dbg_loc);
5050
}
51+
52+
fn clear_dbg_loc(&mut self) {
53+
self.location = None;
54+
}
5155
}
5256

5357
/// Generate the `debug_context` in an MIR Body.

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![doc = include_str!("doc.md")]
22

33
use std::cell::{OnceCell, RefCell};
4-
use std::iter;
54
use std::ops::Range;
5+
use std::{iter, ptr};
66

77
use libc::c_uint;
88
use rustc_codegen_ssa::debuginfo::type_names;
@@ -209,6 +209,12 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
209209
}
210210
}
211211

212+
fn clear_dbg_loc(&mut self) {
213+
unsafe {
214+
llvm::LLVMSetCurrentDebugLocation2(self.llbuilder, ptr::null());
215+
}
216+
}
217+
212218
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
213219
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
214220
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ unsafe extern "C" {
10411041
pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
10421042

10431043
// Metadata
1044-
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: &'a Metadata);
1044+
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata);
10451045

10461046
// Terminators
10471047
pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;

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/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ codegen_ssa_linker_file_stem = couldn't extract file stem from specified linker
172172
codegen_ssa_linker_not_found = linker `{$linker_path}` not found
173173
.note = {$error}
174174
175+
codegen_ssa_linker_output = {$inner}
176+
175177
codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for current linker
176178
177179
codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
1818
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
1919
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
2020
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
21+
use rustc_macros::Diagnostic;
2122
use rustc_metadata::fs::{copy_to_stdout, emit_wrapper_file, METADATA_FILENAME};
2223
use rustc_metadata::{find_native_static_library, walk_native_lib_search_dirs};
2324
use rustc_middle::bug;
@@ -438,7 +439,7 @@ fn link_rlib<'a>(
438439
ab.add_file(&lib)
439440
}
440441

441-
return Ok(ab);
442+
Ok(ab)
442443
}
443444

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

754+
#[derive(Diagnostic)]
755+
#[diag(codegen_ssa_linker_output)]
756+
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
757+
/// end up with inconsistent languages within the same diagnostic.
758+
struct LinkerOutput {
759+
inner: String,
760+
}
761+
753762
/// Create a dynamic library or executable.
754763
///
755764
/// This will invoke the system linker/cc to create the resulting file. This links to all upstream
@@ -976,12 +985,12 @@ fn link_natively(
976985
let mut output = prog.stderr.clone();
977986
output.extend_from_slice(&prog.stdout);
978987
let escaped_output = escape_linker_output(&output, flavor);
979-
// FIXME: Add UI tests for this error.
980988
let err = errors::LinkingFailed {
981989
linker_path: &linker_path,
982990
exit_status: prog.status,
983991
command: &cmd,
984992
escaped_output,
993+
verbose: sess.opts.verbose,
985994
};
986995
sess.dcx().emit_err(err);
987996
// If MSVC's `link.exe` was expected but the return code
@@ -1022,8 +1031,22 @@ fn link_natively(
10221031

10231032
sess.dcx().abort_if_errors();
10241033
}
1025-
info!("linker stderr:\n{}", escape_string(&prog.stderr));
1026-
info!("linker stdout:\n{}", escape_string(&prog.stdout));
1034+
1035+
if !prog.stderr.is_empty() {
1036+
// We already print `warning:` at the start of the diagnostic. Remove it from the linker output if present.
1037+
let stderr = escape_string(&prog.stderr);
1038+
debug!("original stderr: {stderr}");
1039+
let stderr = stderr
1040+
.strip_prefix("warning: ")
1041+
.unwrap_or(&stderr)
1042+
.replace(": warning: ", ": ");
1043+
sess.dcx().emit_warn(LinkerOutput { inner: format!("linker stderr: {stderr}") });
1044+
}
1045+
if !prog.stdout.is_empty() && sess.opts.verbose {
1046+
sess.dcx().emit_warn(LinkerOutput {
1047+
inner: format!("linker stdout: {}", escape_string(&prog.stdout)),
1048+
});
1049+
}
10271050
}
10281051
Err(e) => {
10291052
let linker_not_found = e.kind() == io::ErrorKind::NotFound;
@@ -1319,15 +1342,15 @@ fn link_sanitizer_runtime(
13191342
fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf {
13201343
let path = sess.target_tlib_path.dir.join(filename);
13211344
if path.exists() {
1322-
return sess.target_tlib_path.dir.clone();
1345+
sess.target_tlib_path.dir.clone()
13231346
} else {
13241347
let default_sysroot =
13251348
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
13261349
let default_tlib = filesearch::make_target_lib_path(
13271350
&default_sysroot,
13281351
sess.opts.target_triple.triple(),
13291352
);
1330-
return default_tlib;
1353+
default_tlib
13311354
}
13321355
}
13331356

0 commit comments

Comments
 (0)