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 7 pull requests #129348

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
01b68b7
add `Thread::{into_raw, from_raw}`
ibraheemdev Jul 12, 2022
78caecf
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF plat…
khuey Aug 4, 2024
e587855
Use Span::is_dummy().
khuey Aug 4, 2024
5dc4a19
Fix warning.
khuey Aug 4, 2024
803cbaf
Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs
rezwanahmedsami Aug 17, 2024
9f39427
Added #[cfg(target_arch = x86_64)] to f16 and f128
rezwanahmedsami Aug 18, 2024
35752cf
Update `library/Cargo.toml` in weekly job
tgross35 Aug 19, 2024
76fbf0a
Test wholearchive on rust staticlib
ChrisDenton Aug 18, 2024
3c735a0
Add a test.
khuey Aug 20, 2024
4e9725c
Add a comment.
khuey Aug 20, 2024
9d7574f
rustdoc: animate the `:target` highlight
notriddle Aug 19, 2024
40af214
Make import libraries compatible with wholearchive
ChrisDenton Aug 19, 2024
c78e7fa
Do not ICE on non-ADT rcvr type when looking for crate version collision
estebank Aug 18, 2024
b234f17
Rollup merge of #97524 - ibraheemdev:thread-raw, r=joshtriplett
tgross35 Aug 21, 2024
e147e30
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
tgross35 Aug 21, 2024
61cc570
Rollup merge of #129190 - rezwanahmedsami:master, r=tgross35
tgross35 Aug 21, 2024
aca99a2
Rollup merge of #129250 - estebank:issue-129205, r=compiler-errors
tgross35 Aug 21, 2024
114c21f
Rollup merge of #129257 - ChrisDenton:rename-null-descriptor, r=jieyouxu
tgross35 Aug 21, 2024
e3012a0
Rollup merge of #129264 - tgross35:dependencies-ci-library, r=Kobzol
tgross35 Aug 21, 2024
8e4e58c
Rollup merge of #129284 - notriddle:notriddle/animate-target=light, r…
tgross35 Aug 21, 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
7 changes: 6 additions & 1 deletion .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ jobs:
- name: cargo update
# Remove first line that always just says "Updating crates.io index"
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
- name: cargo update library
run: |
echo -e "\nlibrary dependencies:" >> cargo_update.log
cargo update --manifest-path library/Cargo.toml 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
- name: cargo update rustbook
run: |
echo -e "\nrustbook dependencies:" >> cargo_update.log
Expand All @@ -74,6 +78,7 @@ jobs:
name: Cargo-lock
path: |
Cargo.lock
library/Cargo.lock
src/tools/rustbook/Cargo.lock
retention-days: 1
- name: upload cargo-update log artifact for use in PR
Expand Down Expand Up @@ -119,7 +124,7 @@ jobs:
git config user.name github-actions
git config user.email github-actions@github.com
git switch --force-create cargo_update
git add ./Cargo.lock ./src/tools/rustbook/Cargo.lock
git add ./Cargo.lock ./library/Cargo.lock ./src/tools/rustbook/Cargo.lock
git commit --no-verify --file=commit.txt

- name: push
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ dependencies = [

[[package]]
name = "ar_archive_writer"
version = "0.4.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de11a9d32db3327f981143bdf699ade4d637c6887b13b97e6e91a9154666963c"
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
dependencies = [
"object 0.36.3",
]
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,17 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
inlined_at: Option<&'ll DILocation>,
span: Span,
) -> &'ll DILocation {
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
// When emitting debugging information, DWARF (i.e. everything but MSVC)
// treats line 0 as a magic value meaning that the code could not be
// attributed to any line in the source. That's also exactly what dummy
// spans are. Make that equivalence here, rather than passing dummy spans
// to lookup_debug_loc, which will return line 1 for them.
let (line, col) = if span.is_dummy() && !self.sess().target.is_like_msvc {
(0, 0)
} else {
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
(line, col)
};

unsafe { llvm::LLVMRustDIBuilderCreateDebugLocation(line, col, scope, inlined_at) }
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
# tidy-alphabetical-start
ar_archive_writer = "0.4.0"
ar_archive_writer = "0.4.2"
arrayvec = { version = "0.7", default-features = false }
bitflags = "2.4.1"
cc = "1.0.90"
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ pub trait ArchiveBuilderBuilder {
&exports,
machine,
!sess.target.is_like_msvc,
/*comdat=*/ false,
// Enable compatibility with MSVC's `/WHOLEARCHIVE` flag.
// Without this flag a duplicate symbol error would be emitted
// when linking a rust staticlib using `/WHOLEARCHIVE`.
// See #129020
true,
) {
sess.dcx()
.emit_fatal(ErrorCreatingImportLibrary { lib_name, error: error.to_string() });
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3498,7 +3498,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err,
pick.item.def_id,
rcvr.hir_id,
*rcvr_ty,
Some(*rcvr_ty),
);
if pick.autoderefs == 0 && !trait_in_other_version_found {
err.span_label(
Expand Down Expand Up @@ -3689,8 +3689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let SelfSource::QPath(ty) = source
&& !valid_out_of_scope_traits.is_empty()
&& let hir::TyKind::Path(path) = ty.kind
&& let hir::QPath::Resolved(_, path) = path
&& let Some(def_id) = path.res.opt_def_id()
&& let hir::QPath::Resolved(..) = path
&& let Some(assoc) = self
.tcx
.associated_items(valid_out_of_scope_traits[0])
Expand All @@ -3700,7 +3699,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// See if the `Type::function(val)` where `function` wasn't found corresponds to a
// `Trait` that is imported directly, but `Type` came from a different version of the
// same crate.
let rcvr_ty = self.tcx.type_of(def_id).instantiate_identity();

let rcvr_ty = self.node_ty_opt(ty.hir_id);
trait_in_other_version_found = self.detect_and_explain_multiple_crate_versions(
err,
assoc.def_id,
Expand Down Expand Up @@ -4080,7 +4080,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err: &mut Diag<'_>,
item_def_id: DefId,
hir_id: hir::HirId,
rcvr_ty: Ty<'_>,
rcvr_ty: Option<Ty<'_>>,
) -> bool {
let hir_id = self.tcx.parent_hir_id(hir_id);
let Some(traits) = self.tcx.in_scope_traits(hir_id) else { return false };
Expand Down Expand Up @@ -4110,8 +4110,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut multi_span: MultiSpan = trait_span.into();
multi_span.push_span_label(trait_span, format!("this is the trait that is needed"));
let descr = self.tcx.associated_item(item_def_id).descr();
let rcvr_ty =
rcvr_ty.map(|t| format!("`{t}`")).unwrap_or_else(|| "the receiver".to_string());
multi_span
.push_span_label(item_span, format!("the {descr} is available for `{rcvr_ty}` here"));
.push_span_label(item_span, format!("the {descr} is available for {rcvr_ty} here"));
for (def_id, import_def_id) in candidates {
if let Some(import_def_id) = import_def_id {
multi_span.push_span_label(
Expand Down
46 changes: 46 additions & 0 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,52 @@ impl Thread {
self.inner.name.as_str()
}

/// Consumes the `Thread`, returning a raw pointer.
///
/// To avoid a memory leak the pointer must be converted
/// back into a `Thread` using [`Thread::from_raw`].
///
/// # Examples
///
/// ```
/// #![feature(thread_raw)]
///
/// use std::thread::{self, Thread};
///
/// let thread = thread::current();
/// let id = thread.id();
/// let ptr = Thread::into_raw(thread);
/// unsafe {
/// assert_eq!(Thread::from_raw(ptr).id(), id);
/// }
/// ```
#[unstable(feature = "thread_raw", issue = "97523")]
pub fn into_raw(self) -> *const () {
Arc::into_raw(Pin::into_inner(self.inner)) as *const ()
}

/// Constructs a `Thread` from a raw pointer.
///
/// The raw pointer must have been previously returned
/// by a call to [`Thread::into_raw`].
///
/// # Safety
///
/// This function is unsafe because improper use may lead
/// to memory unsafety, even if the returned `Thread` is never
/// accessed.
///
/// Creating a `Thread` from a pointer other than one returned
/// from [`Thread::into_raw`] is **undefined behavior**.
///
/// Calling this function twice on the same raw pointer can lead
/// to a double-free if both `Thread` instances are dropped.
#[unstable(feature = "thread_raw", issue = "97523")]
pub unsafe fn from_raw(ptr: *const ()) -> Thread {
// SAFETY: upheld by caller
unsafe { Thread { inner: Pin::new_unchecked(Arc::from_raw(ptr as *const Inner)) } }
}

fn cname(&self) -> Option<&CStr> {
self.inner.name.as_cstr()
}
Expand Down
13 changes: 13 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1547,10 +1547,23 @@ instead, we check that it's not a "finger" cursor.
margin-left: 24px;
}

@keyframes targetfadein {
from {
background-color: var(--main-background-color);
}
10% {
background-color: var(--target-border-color);
}
to {
background-color: var(--target-background-color);
}
}

:target {
padding-right: 3px;
background-color: var(--target-background-color);
border-right: 3px solid var(--target-border-color);
animation: 0.65s cubic-bezier(0, 0, 0.1, 1.0) 0.1s targetfadein;
}

.code-header a.tooltip {
Expand Down
45 changes: 45 additions & 0 deletions tests/debuginfo/dummy_span.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//@ min-lldb-version: 310

//@ compile-flags:-g

// === GDB TESTS ===================================================================================

// gdb-command:run 7

// gdb-command:next
// gdb-command:next
// gdb-check:[...]#loc1[...]
// gdb-command:next
// gdb-check:[...]#loc2[...]

// === LLDB TESTS ==================================================================================

// lldb-command:run 7

// lldb-command:next
// lldb-command:next
// lldb-command:frame select
// lldb-check:[...]#loc1[...]
// lldb-command:next
// lldb-command:frame select
// lldb-check:[...]#loc2[...]

use std::env;
use std::num::ParseIntError;

fn main() -> Result<(), ParseIntError> {
let args = env::args();
let number_str = args.skip(1).next().unwrap();
let number = number_str.parse::<i32>()?;
zzz(); // #break
if number % 7 == 0 {
// This generates code with a dummy span for
// some reason. If that ever changes this
// test will not test what it wants to test.
return Ok(()); // #loc1
}
println!("{}", number);
Ok(())
} // #loc2

fn zzz() { () }
1 change: 1 addition & 0 deletions tests/run-make/msvc-wholearchive/c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This page is intentionally left blank
4 changes: 4 additions & 0 deletions tests/run-make/msvc-wholearchive/dll.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LIBRARY dll
EXPORTS
hello
number
52 changes: 52 additions & 0 deletions tests/run-make/msvc-wholearchive/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//! This is a regression test for #129020
//! It ensures we can use `/WHOLEARCHIVE` to link a rust staticlib into DLL
//! using the MSVC linker

//@ only-msvc
// Reason: this is testing the MSVC linker

use std::path::PathBuf;

use run_make_support::{cc, cmd, env_var, extra_c_flags, rustc};

fn main() {
// Build the staticlib
rustc().crate_type("staticlib").input("static.rs").output("static.lib").run();
// Build an empty object to pass to the linker.
cc().input("c.c").output("c.obj").args(["-c"]).run();

// Find the C toolchain's linker.
let mut linker = PathBuf::from(env_var("CC"));
let linker_flavour = if linker.file_stem().is_some_and(|s| s == "cl") {
linker.set_file_name("link.exe");
"msvc"
} else if linker.file_stem().is_some_and(|s| s == "clang-cl") {
linker.set_file_name("lld-link.exe");
"llvm"
} else {
panic!("unknown C toolchain");
};

// As a sanity check, make sure this works without /WHOLEARCHIVE.
// Otherwise the actual test failure may be caused by something else.
cmd(&linker)
.args(["c.obj", "./static.lib", "-dll", "-def:dll.def", "-out:dll.dll"])
.args(extra_c_flags())
.run();

// FIXME(@ChrisDenton): this doesn't currently work with llvm's lld-link for other reasons.
// May need LLVM patches.
if linker_flavour == "msvc" {
// Link in the staticlib using `/WHOLEARCHIVE` and produce a DLL.
cmd(&linker)
.args([
"c.obj",
"-WHOLEARCHIVE:./static.lib",
"-dll",
"-def:dll.def",
"-out:dll_whole_archive.dll",
])
.args(extra_c_flags())
.run();
}
}
9 changes: 9 additions & 0 deletions tests/run-make/msvc-wholearchive/static.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[no_mangle]
pub extern "C" fn hello() {
println!("Hello world!");
}

#[no_mangle]
pub extern "C" fn number() -> u32 {
42
}
2 changes: 1 addition & 1 deletion tests/rustdoc-gui/target.goml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define-function: (
[theme, background, border],
block {
call-function: ("switch-theme", {"theme": |theme|})
assert-css: ("#method\.a_method:target", {
wait-for-css: ("#method\.a_method:target", {
"background-color": |background|,
"border-right": "3px solid " + |border|,
})
Expand Down
Loading
Loading