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 #130902

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4788e8c
Add the library workspace to the suggested rust-analyzer config
bjorn3 Sep 18, 2024
86493d4
Extend rustdoc template check to detect unneeded comments
GuillaumeGomez Sep 22, 2024
912e1ae
Remove unneeded jinja comments in templates
GuillaumeGomez Sep 22, 2024
986e20d
Fixed diagnostics for coroutines with () as input.
91khr Sep 25, 2024
8f1ed9b
Utf8Chunks: add link to Utf8Chunk
RalfJung Sep 25, 2024
d3e59a5
Revert Break into the debugger on panic (129019)
ChrisDenton Sep 25, 2024
afb7eef
Pass Module Analysis Manager to Standard Instrumentations
Sep 25, 2024
a51b0a2
Use `mem::offset_of!` for `sockaddr_un.sun_path`
cuviper Sep 25, 2024
5892187
Fix the misleading diagnostic for let_underscore_drop on type without…
makai410 Sep 26, 2024
1bef68c
Update FIXME comment in s390x_unknown_linux_*.rs
taiki-e Sep 26, 2024
ef87a7f
add missing FIXME(const-hack)
RalfJung Sep 26, 2024
9431d1a
Add `sun_path` to the fake doc `sockaddr_un`
cuviper Sep 26, 2024
e29ff8c
Pass correct HirId to late_bound_vars in diagnostic code
fmease Sep 26, 2024
16726f0
Rollup merge of #130517 - bjorn3:update_ra_config, r=onur-ozkan
workingjubilee Sep 26, 2024
de98278
Rollup merge of #130706 - GuillaumeGomez:remove-unneeded-jinja-commen…
workingjubilee Sep 26, 2024
e3fe4a2
Rollup merge of #130820 - 91khr:fix-coroutine-unit-arg, r=compiler-er…
workingjubilee Sep 26, 2024
3005040
Rollup merge of #130833 - makai410:master, r=compiler-errors,fee1-dead
workingjubilee Sep 26, 2024
0f628b2
Rollup merge of #130845 - RalfJung:utf8chunk, r=tgross35
workingjubilee Sep 26, 2024
6798174
Rollup merge of #130846 - ChrisDenton:revert-break, r=Noratrieb
workingjubilee Sep 26, 2024
7939ed5
Rollup merge of #130850 - saveasguy:pass-mam-to-standrd-instrumentati…
workingjubilee Sep 26, 2024
37ed94f
Rollup merge of #130861 - cuviper:sun-path-offset, r=ibraheemdev
workingjubilee Sep 26, 2024
0b91f88
Rollup merge of #130868 - taiki-e:s390x-fixme, r=jieyouxu
workingjubilee Sep 26, 2024
6490a7d
Rollup merge of #130879 - fmease:fix-diag-ice, r=compiler-errors
workingjubilee Sep 26, 2024
0aba6a5
Rollup merge of #130880 - RalfJung:const-hack, r=scottmcm
workingjubilee Sep 26, 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
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let ty = self.lowerer().lower_ty(hir_ty);
debug!(?ty, "return type (lowered)");
debug!(?expected, "expected type");
let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into());
let bound_vars =
self.tcx.late_bound_vars(self.tcx.local_def_id_to_hir_id(fn_id));
let ty = Binder::bind_with_vars(ty, bound_vars);
let ty = self.normalize(hir_ty.span, ty);
let ty = self.tcx.instantiate_bound_regions_with_erased(ty);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ lint_non_binding_let_multi_suggestion =
consider immediately dropping the value

lint_non_binding_let_on_drop_type =
non-binding let on a type that implements `Drop`
non-binding let on a type that has a destructor

lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
.label = this lock is not assigned to a binding and is immediately dropped
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ declare_lint! {
/// intent.
pub LET_UNDERSCORE_DROP,
Allow,
"non-binding let on a type that implements `Drop`"
"non-binding let on a type that has a destructor"
}

declare_lint! {
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
PTO.SLPVectorization = SLPVectorize;
PTO.MergeFunctions = MergeFunctions;

// FIXME: We may want to expose this as an option.
bool DebugPassManager = false;

PassInstrumentationCallbacks PIC;
StandardInstrumentations SI(TheModule->getContext(), DebugPassManager);
SI.registerCallbacks(PIC);

if (LlvmSelfProfiler) {
LLVMSelfProfileInitializeCallbacks(PIC, LlvmSelfProfiler,
Expand Down Expand Up @@ -784,6 +779,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;

// FIXME: We may want to expose this as an option.
bool DebugPassManager = false;

StandardInstrumentations SI(TheModule->getContext(), DebugPassManager);
SI.registerCallbacks(PIC, &MAM);

if (LLVMPluginsLen) {
auto PluginsStr = StringRef(LLVMPlugins, LLVMPluginsLen);
SmallVector<StringRef> Plugins;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
// also strip v128 from the data_layout below to match the older LLVM's expectation.
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
base.features = "-vector".into();
base.max_atomic_width = Some(128);
base.min_global_align = Some(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
// also strip v128 from the data_layout below to match the older LLVM's expectation.
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
base.features = "-vector".into();
base.max_atomic_width = Some(128);
base.min_global_align = Some(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2635,49 +2635,47 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// This shouldn't be common unless manually implementing one of the
// traits manually, but don't make it more confusing when it does
// happen.
Ok(
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait()
&& not_tupled
{
self.report_and_explain_type_error(
TypeTrace::trait_refs(
&obligation.cause,
true,
expected_trait_ref,
found_trait_ref,
),
ty::error::TypeError::Mismatch,
)
} else if found.len() == expected.len() {
self.report_closure_arg_mismatch(
span,
found_span,
found_trait_ref,
expected_trait_ref,
obligation.cause.code(),
found_node,
obligation.param_env,
)
} else {
let (closure_span, closure_arg_span, found) = found_did
.and_then(|did| {
let node = self.tcx.hir().get_if_local(did)?;
let (found_span, closure_arg_span, found) =
self.get_fn_like_arguments(node)?;
Some((Some(found_span), closure_arg_span, found))
})
.unwrap_or((found_span, None, found));

self.report_arg_count_mismatch(
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait() && not_tupled
{
return Ok(self.report_and_explain_type_error(
TypeTrace::trait_refs(&obligation.cause, true, expected_trait_ref, found_trait_ref),
ty::error::TypeError::Mismatch,
));
}
if found.len() != expected.len() {
let (closure_span, closure_arg_span, found) = found_did
.and_then(|did| {
let node = self.tcx.hir().get_if_local(did)?;
let (found_span, closure_arg_span, found) = self.get_fn_like_arguments(node)?;
Some((Some(found_span), closure_arg_span, found))
})
.unwrap_or((found_span, None, found));

// If the coroutine take a single () as its argument,
// the trait argument would found the coroutine take 0 arguments,
// but get_fn_like_arguments would give 1 argument.
// This would result in "Expected to take 1 argument, but it takes 1 argument".
// Check again to avoid this.
if found.len() != expected.len() {
return Ok(self.report_arg_count_mismatch(
span,
closure_span,
expected,
found,
found_trait_ty.is_closure(),
closure_arg_span,
)
},
)
));
}
}
Ok(self.report_closure_arg_mismatch(
span,
found_span,
found_trait_ref,
expected_trait_ref,
obligation.cause.code(),
found_node,
obligation.param_env,
))
}

/// Given some node representing a fn-like thing in the HIR map,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ptr/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Alignment {
!(unsafe { self.as_usize().unchecked_sub(1) })
}

// Remove me once `Ord::max` is usable in const
// FIXME(const-hack) Remove me once `Ord::max` is usable in const
pub(crate) const fn max(a: Self, b: Self) -> Self {
if a.as_usize() > b.as_usize() { a } else { b }
}
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/str/lossy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ impl [u8] {
/// Creates an iterator over the contiguous valid UTF-8 ranges of this
/// slice, and the non-UTF-8 fragments in between.
///
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
///
/// # Examples
///
/// This function formats arbitrary but mostly-UTF-8 bytes into Rust source
Expand Down Expand Up @@ -148,6 +150,8 @@ impl fmt::Debug for Debug<'_> {
/// If you want a simple conversion from UTF-8 byte slices to string slices,
/// [`from_utf8`] is easier to use.
///
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
///
/// [byteslice]: slice
/// [`from_utf8`]: super::from_utf8
///
Expand Down
21 changes: 9 additions & 12 deletions library/std/src/os/unix/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ mod libc {
pub type socklen_t = u32;
pub struct sockaddr;
#[derive(Clone)]
pub struct sockaddr_un;
pub struct sockaddr_un {
pub sun_path: [u8; 1],
}
}

fn sun_path_offset(addr: &libc::sockaddr_un) -> usize {
// Work with an actual instance of the type since using a null pointer is UB
let base = (addr as *const libc::sockaddr_un).addr();
let path = core::ptr::addr_of!(addr.sun_path).addr();
path - base
}
const SUN_PATH_OFFSET: usize = mem::offset_of!(libc::sockaddr_un, sun_path);

pub(super) fn sockaddr_un(path: &Path) -> io::Result<(libc::sockaddr_un, libc::socklen_t)> {
// SAFETY: All zeros is a valid representation for `sockaddr_un`.
Expand Down Expand Up @@ -53,7 +50,7 @@ pub(super) fn sockaddr_un(path: &Path) -> io::Result<(libc::sockaddr_un, libc::s
ptr::copy_nonoverlapping(bytes.as_ptr(), addr.sun_path.as_mut_ptr().cast(), bytes.len())
};

let mut len = sun_path_offset(&addr) + bytes.len();
let mut len = SUN_PATH_OFFSET + bytes.len();
match bytes.get(0) {
Some(&0) | None => {}
Some(_) => len += 1,
Expand Down Expand Up @@ -114,13 +111,13 @@ impl SocketAddr {
let sun_path: &[u8] =
unsafe { mem::transmute::<&[libc::c_char], &[u8]>(&addr.sun_path) };
len = core::slice::memchr::memchr(0, sun_path)
.map_or(len, |new_len| (new_len + sun_path_offset(&addr)) as libc::socklen_t);
.map_or(len, |new_len| (new_len + SUN_PATH_OFFSET) as libc::socklen_t);
}

if len == 0 {
// When there is a datagram from unnamed unix socket
// linux returns zero bytes of address
len = sun_path_offset(&addr) as libc::socklen_t; // i.e., zero-length address
len = SUN_PATH_OFFSET as libc::socklen_t; // i.e., zero-length address
} else if addr.sun_family != libc::AF_UNIX as libc::sa_family_t {
return Err(io::const_io_error!(
io::ErrorKind::InvalidInput,
Expand Down Expand Up @@ -238,7 +235,7 @@ impl SocketAddr {
}

fn address(&self) -> AddressKind<'_> {
let len = self.len as usize - sun_path_offset(&self.addr);
let len = self.len as usize - SUN_PATH_OFFSET;
let path = unsafe { mem::transmute::<&[libc::c_char], &[u8]>(&self.addr.sun_path) };

// macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses
Expand Down Expand Up @@ -287,7 +284,7 @@ impl linux_ext::addr::SocketAddrExt for SocketAddr {
addr.sun_path.as_mut_ptr().add(1) as *mut u8,
name.len(),
);
let len = (sun_path_offset(&addr) + 1 + name.len()) as libc::socklen_t;
let len = (SUN_PATH_OFFSET + 1 + name.len()) as libc::socklen_t;
SocketAddr::from_parts(addr, len)
}
}
Expand Down
18 changes: 1 addition & 17 deletions library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use crate::mem::{self, ManuallyDrop};
use crate::panic::{BacktraceStyle, PanicHookInfo};
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::sync::{PoisonError, RwLock};
use crate::sys::backtrace;
use crate::sys::stdio::panic_output;
use crate::sys::{backtrace, dbg};
use crate::{fmt, intrinsics, process, thread};

// Binary interface to the panic runtime that the standard library depends on.
Expand Down Expand Up @@ -859,29 +859,13 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
#[cfg_attr(not(test), rustc_std_internal_symbol)]
#[cfg(not(feature = "panic_immediate_abort"))]
fn rust_panic(msg: &mut dyn PanicPayload) -> ! {
// Break into the debugger if it is attached.
// The return value is not currently used.
//
// This function isn't used anywhere else, and
// using inside `#[panic_handler]` doesn't seem
// to count, so a warning is issued.
let _ = dbg::breakpoint_if_debugging();

let code = unsafe { __rust_start_panic(msg) };
rtabort!("failed to initiate panic, error {code}")
}

#[cfg_attr(not(test), rustc_std_internal_symbol)]
#[cfg(feature = "panic_immediate_abort")]
fn rust_panic(_: &mut dyn PanicPayload) -> ! {
// Break into the debugger if it is attached.
// The return value is not currently used.
//
// This function isn't used anywhere else, and
// using inside `#[panic_handler]` doesn't seem
// to count, so a warning is issued.
let _ = dbg::breakpoint_if_debugging();

unsafe {
crate::intrinsics::abort();
}
Expand Down
Loading
Loading