Auto merge of #126284 - jieyouxu:rollup-nq7bf9k, r=jieyouxu
Rollup of 6 pull requests Successful merges: - #115974 (Split core's PanicInfo and std's PanicInfo) - #125659 (Remove usage of `isize` in example) - #125669 (CI: Update riscv64gc-linux job to Ubuntu 22.04, rename to riscv64gc-gnu) - #125684 (Account for existing bindings when suggesting `pin!()`) - #126055 (Expand list of trait implementers in E0277 when calling rustc with --verbose) - #126174 (Migrate `tests/run-make/prefer-dylib` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ebcb862bbb
24 changed files with 521 additions and 350 deletions
|
|
@ -52,7 +52,7 @@ use std::ffi::OsString;
|
|||
use std::fmt::Write as _;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, IsTerminal, Read, Write};
|
||||
use std::panic::{self, catch_unwind, PanicInfo};
|
||||
use std::panic::{self, catch_unwind, PanicHookInfo};
|
||||
use std::path::PathBuf;
|
||||
use std::process::{self, Command, Stdio};
|
||||
use std::str;
|
||||
|
|
@ -1366,11 +1366,10 @@ pub fn install_ice_hook(
|
|||
let using_internal_features = Arc::new(std::sync::atomic::AtomicBool::default());
|
||||
let using_internal_features_hook = using_internal_features.clone();
|
||||
panic::update_hook(Box::new(
|
||||
move |default_hook: &(dyn Fn(&PanicInfo<'_>) + Send + Sync + 'static),
|
||||
info: &PanicInfo<'_>| {
|
||||
move |default_hook: &(dyn Fn(&PanicHookInfo<'_>) + Send + Sync + 'static),
|
||||
info: &PanicHookInfo<'_>| {
|
||||
// Lock stderr to prevent interleaving of concurrent panics.
|
||||
let _guard = io::stderr().lock();
|
||||
|
||||
// If the error was caused by a broken pipe then this is not a bug.
|
||||
// Write the error and return immediately. See #98700.
|
||||
#[cfg(windows)]
|
||||
|
|
@ -1431,7 +1430,7 @@ pub fn install_ice_hook(
|
|||
/// When `install_ice_hook` is called, this function will be called as the panic
|
||||
/// hook.
|
||||
fn report_ice(
|
||||
info: &panic::PanicInfo<'_>,
|
||||
info: &panic::PanicHookInfo<'_>,
|
||||
bug_report_url: &str,
|
||||
extra_info: fn(&DiagCtxt),
|
||||
using_internal_features: &AtomicBool,
|
||||
|
|
|
|||
|
|
@ -3360,14 +3360,66 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.source_map()
|
||||
.indentation_before(rcvr.span)
|
||||
.unwrap_or_else(|| " ".to_string());
|
||||
err.multipart_suggestion(
|
||||
"consider pinning the expression",
|
||||
vec![
|
||||
(rcvr.span.shrink_to_lo(), format!("let mut pinned = std::pin::pin!(")),
|
||||
(rcvr.span.shrink_to_hi(), format!(");\n{indent}pinned.{pin_call}()")),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
let mut expr = rcvr;
|
||||
while let Node::Expr(call_expr) = self.tcx.parent_hir_node(expr.hir_id)
|
||||
&& let hir::ExprKind::MethodCall(hir::PathSegment { .. }, ..) =
|
||||
call_expr.kind
|
||||
{
|
||||
expr = call_expr;
|
||||
}
|
||||
match self.tcx.parent_hir_node(expr.hir_id) {
|
||||
Node::LetStmt(stmt)
|
||||
if let Some(init) = stmt.init
|
||||
&& let Ok(code) =
|
||||
self.tcx.sess.source_map().span_to_snippet(rcvr.span) =>
|
||||
{
|
||||
// We need to take care to account for the existing binding when we
|
||||
// suggest the code.
|
||||
err.multipart_suggestion(
|
||||
"consider pinning the expression",
|
||||
vec![
|
||||
(
|
||||
stmt.span.shrink_to_lo(),
|
||||
format!(
|
||||
"let mut pinned = std::pin::pin!({code});\n{indent}"
|
||||
),
|
||||
),
|
||||
(
|
||||
init.span.until(rcvr.span.shrink_to_hi()),
|
||||
format!("pinned.{pin_call}()"),
|
||||
),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
Node::Block(_) | Node::Stmt(_) => {
|
||||
// There's no binding, so we can provide a slightly nicer looking
|
||||
// suggestion.
|
||||
err.multipart_suggestion(
|
||||
"consider pinning the expression",
|
||||
vec![
|
||||
(
|
||||
rcvr.span.shrink_to_lo(),
|
||||
format!("let mut pinned = std::pin::pin!("),
|
||||
),
|
||||
(
|
||||
rcvr.span.shrink_to_hi(),
|
||||
format!(");\n{indent}pinned.{pin_call}()"),
|
||||
),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
// We don't quite know what the users' code looks like, so we don't
|
||||
// provide a pinning suggestion.
|
||||
err.span_help(
|
||||
rcvr.span,
|
||||
"consider pinning the expression with `std::pin::pin!()` and \
|
||||
assigning that to a new binding",
|
||||
);
|
||||
}
|
||||
}
|
||||
// We don't care about the other suggestions.
|
||||
alt_rcvr_sugg = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ declare_lint! {
|
|||
/// ```rust,compile_fail
|
||||
/// #![deny(box_pointers)]
|
||||
/// struct Foo {
|
||||
/// x: Box<isize>,
|
||||
/// x: Box<i32>,
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
|
|
|||
|
|
@ -2069,12 +2069,16 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let end = if candidates.len() <= 9 { candidates.len() } else { 8 };
|
||||
let end = if candidates.len() <= 9 || self.tcx.sess.opts.verbose {
|
||||
candidates.len()
|
||||
} else {
|
||||
8
|
||||
};
|
||||
err.help(format!(
|
||||
"the following {other}types implement trait `{}`:{}{}",
|
||||
trait_ref.print_trait_sugared(),
|
||||
candidates[..end].join(""),
|
||||
if candidates.len() > 9 {
|
||||
if candidates.len() > 9 && !self.tcx.sess.opts.verbose {
|
||||
format!("\nand {} others", candidates.len() - 8)
|
||||
} else {
|
||||
String::new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue