Auto merge of #81018 - m-ou-se:rollup-7202dc7, r=m-ou-se
Rollup of 17 pull requests Successful merges: - #79982 (Add missing methods to unix ExitStatusExt) - #80017 (Suggest `_` and `..` if a pattern has too few fields) - #80169 (Recommend panic::resume_unwind instead of panicking.) - #80217 (Add a `std::io::read_to_string` function) - #80444 (Add as_ref and as_mut methods for Bound) - #80567 (Add Iterator::intersperse_with) - #80829 (Get rid of `DepConstructor`) - #80895 (Fix handling of malicious Readers in read_to_end) - #80966 (Deprecate atomic::spin_loop_hint in favour of hint::spin_loop) - #80969 (Use better ICE message when no MIR is available) - #80972 (Remove unstable deprecated Vec::remove_item) - #80973 (Update books) - #80980 (Fixed incorrect doc comment) - #80981 (Fix -Cpasses=list and llvm version print with -vV) - #80985 (Fix stabilisation version of slice_strip) - #80990 (llvm: Remove the unused context from CreateDebugLocation) - #80991 (Fix formatting specifiers doc links) Failed merges: - #80944 (Use Option::map_or instead of `.map(..).unwrap_or(..)`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
e38fb306b7
42 changed files with 802 additions and 167 deletions
|
@ -552,7 +552,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateDebugLocation(
|
||||
utils::debug_context(self).llcontext,
|
||||
line.unwrap_or(UNKNOWN_LINE_NUMBER),
|
||||
col.unwrap_or(UNKNOWN_COLUMN_NUMBER),
|
||||
scope,
|
||||
|
|
|
@ -2102,7 +2102,6 @@ extern "C" {
|
|||
);
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateDebugLocation(
|
||||
Context: &'a Context,
|
||||
Line: c_uint,
|
||||
Column: c_uint,
|
||||
Scope: &'a DIScope,
|
||||
|
|
|
@ -798,7 +798,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
|
|||
println!("commit-date: {}", unw(util::commit_date_str()));
|
||||
println!("host: {}", config::host_triple());
|
||||
println!("release: {}", unw(util::release_str()));
|
||||
if cfg!(llvm) {
|
||||
if cfg!(feature = "llvm") {
|
||||
get_builtin_codegen_backend("llvm")().print_version();
|
||||
}
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
|
|||
}
|
||||
|
||||
if cg_flags.iter().any(|x| *x == "passes=list") {
|
||||
if cfg!(llvm) {
|
||||
if cfg!(feature = "llvm") {
|
||||
get_builtin_codegen_backend("llvm")().print_passes();
|
||||
}
|
||||
return None;
|
||||
|
|
|
@ -994,11 +994,9 @@ LLVMRustDICompositeTypeReplaceArrays(LLVMRustDIBuilderRef Builder,
|
|||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
LLVMRustDIBuilderCreateDebugLocation(LLVMContextRef ContextRef, unsigned Line,
|
||||
unsigned Column, LLVMMetadataRef Scope,
|
||||
LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column,
|
||||
LLVMMetadataRef Scope,
|
||||
LLVMMetadataRef InlinedAt) {
|
||||
LLVMContext &Context = *unwrap(ContextRef);
|
||||
|
||||
DebugLoc debug_loc = DebugLoc::get(Line, Column, unwrapDIPtr<MDNode>(Scope),
|
||||
unwrapDIPtr<MDNode>(InlinedAt));
|
||||
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
//! contained no `DefId` for thing that had been removed.
|
||||
//!
|
||||
//! `DepNode` definition happens in the `define_dep_nodes!()` macro. This macro
|
||||
//! defines the `DepKind` enum and a corresponding `dep_constructor` module. The
|
||||
//! `dep_constructor` module links a `DepKind` to the parameters that are needed at
|
||||
//! runtime in order to construct a valid `DepNode` fingerprint.
|
||||
//! defines the `DepKind` enum. Each `DepKind` has its own parameters that are
|
||||
//! needed at runtime in order to construct a valid `DepNode` fingerprint.
|
||||
//! However, only `CompileCodegenUnit` is constructed explicitly (with
|
||||
//! `make_compile_codegen_unit`).
|
||||
//!
|
||||
//! Because the macro sees what parameters a given `DepKind` requires, it can
|
||||
//! "infer" some properties for each kind of `DepNode`:
|
||||
|
@ -44,22 +45,14 @@
|
|||
//! `DefId` it was computed from. In other cases, too much information gets
|
||||
//! lost during fingerprint computation.
|
||||
//!
|
||||
//! The `dep_constructor` module, together with `DepNode::new()`, ensures that only
|
||||
//! `make_compile_codegen_unit`, together with `DepNode::new()`, ensures that only
|
||||
//! valid `DepNode` instances can be constructed. For example, the API does not
|
||||
//! allow for constructing parameterless `DepNode`s with anything other
|
||||
//! than a zeroed out fingerprint. More generally speaking, it relieves the
|
||||
//! user of the `DepNode` API of having to know how to compute the expected
|
||||
//! fingerprint for a given set of node parameters.
|
||||
|
||||
use crate::mir::interpret::{GlobalId, LitToConstInput};
|
||||
use crate::traits;
|
||||
use crate::traits::query::{
|
||||
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
|
||||
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
|
||||
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
|
||||
};
|
||||
use crate::ty::subst::{GenericArg, SubstsRef};
|
||||
use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
|
||||
use crate::ty::TyCtxt;
|
||||
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
|
||||
|
@ -338,25 +331,6 @@ macro_rules! define_dep_nodes {
|
|||
$($variant),*
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub mod dep_constructor {
|
||||
use super::*;
|
||||
|
||||
$(
|
||||
#[inline(always)]
|
||||
#[allow(unreachable_code, non_snake_case)]
|
||||
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
|
||||
// tuple args
|
||||
$({
|
||||
erase!($tuple_arg_ty);
|
||||
return DepNode::construct(_tcx, DepKind::$variant, &arg)
|
||||
})*
|
||||
|
||||
return DepNode::construct(_tcx, DepKind::$variant, &())
|
||||
}
|
||||
)*
|
||||
}
|
||||
|
||||
fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
|
||||
match label {
|
||||
$(stringify!($variant) => Ok(DepKind::$variant),)*
|
||||
|
@ -384,9 +358,16 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
|
|||
|
||||
[anon] TraitSelect,
|
||||
|
||||
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
|
||||
[] CompileCodegenUnit(Symbol),
|
||||
]);
|
||||
|
||||
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
|
||||
// Be very careful changing this type signature!
|
||||
crate fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
|
||||
DepNode::construct(tcx, DepKind::CompileCodegenUnit, &name)
|
||||
}
|
||||
|
||||
pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
|
||||
|
||||
// We keep a lot of `DepNode`s in memory during compilation. It's not
|
||||
|
|
|
@ -13,7 +13,8 @@ pub use rustc_query_system::dep_graph::{
|
|||
WorkProduct, WorkProductId,
|
||||
};
|
||||
|
||||
pub use dep_node::{dep_constructor, label_strs, DepKind, DepNode, DepNodeExt};
|
||||
crate use dep_node::make_compile_codegen_unit;
|
||||
pub use dep_node::{label_strs, DepKind, DepNode, DepNodeExt};
|
||||
|
||||
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
|
||||
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::dep_graph::{dep_constructor, DepNode, WorkProduct, WorkProductId};
|
||||
use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
|
||||
use rustc_attr::InlineAttr;
|
||||
|
@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> {
|
|||
}
|
||||
|
||||
pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode {
|
||||
dep_constructor::CompileCodegenUnit(tcx, self.name())
|
||||
crate::dep_graph::make_compile_codegen_unit(tcx, self.name())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -823,7 +823,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
|
|||
}
|
||||
|
||||
if !tcx.is_mir_available(def_id) {
|
||||
bug!("cannot create local mono-item for {:?}", def_id)
|
||||
bug!("no MIR available for {:?}", def_id);
|
||||
}
|
||||
|
||||
true
|
||||
|
|
|
@ -15,6 +15,7 @@ use rustc_span::hygiene::DesugaringKind;
|
|||
use rustc_span::lev_distance::find_best_match_for_name;
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{BytePos, DUMMY_SP};
|
||||
use rustc_trait_selection::traits::{ObligationCause, Pattern};
|
||||
|
||||
use std::cmp;
|
||||
|
@ -1001,7 +1002,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// More generally, the expected type wants a tuple variant with one field of an
|
||||
// N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern
|
||||
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
|
||||
let missing_parenthesis = match (&expected.kind(), fields, had_err) {
|
||||
let missing_parentheses = match (&expected.kind(), fields, had_err) {
|
||||
// #67037: only do this if we could successfully type-check the expected type against
|
||||
// the tuple struct pattern. Otherwise the substs could get out of range on e.g.,
|
||||
// `let P() = U;` where `P != U` with `struct P<T>(T);`.
|
||||
|
@ -1014,13 +1015,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
_ => false,
|
||||
};
|
||||
if missing_parenthesis {
|
||||
if missing_parentheses {
|
||||
let (left, right) = match subpats {
|
||||
// This is the zero case; we aim to get the "hi" part of the `QPath`'s
|
||||
// span as the "lo" and then the "hi" part of the pattern's span as the "hi".
|
||||
// This looks like:
|
||||
//
|
||||
// help: missing parenthesis
|
||||
// help: missing parentheses
|
||||
// |
|
||||
// L | let A(()) = A(());
|
||||
// | ^ ^
|
||||
|
@ -1029,17 +1030,63 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// last sub-pattern. In the case of `A(x)` the first and last may coincide.
|
||||
// This looks like:
|
||||
//
|
||||
// help: missing parenthesis
|
||||
// help: missing parentheses
|
||||
// |
|
||||
// L | let A((x, y)) = A((1, 2));
|
||||
// | ^ ^
|
||||
[first, ..] => (first.span.shrink_to_lo(), subpats.last().unwrap().span),
|
||||
};
|
||||
err.multipart_suggestion(
|
||||
"missing parenthesis",
|
||||
"missing parentheses",
|
||||
vec![(left, "(".to_string()), (right.shrink_to_hi(), ")".to_string())],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else if fields.len() > subpats.len() {
|
||||
let after_fields_span = if pat_span == DUMMY_SP {
|
||||
pat_span
|
||||
} else {
|
||||
pat_span.with_hi(pat_span.hi() - BytePos(1)).shrink_to_hi()
|
||||
};
|
||||
let all_fields_span = match subpats {
|
||||
[] => after_fields_span,
|
||||
[field] => field.span,
|
||||
[first, .., last] => first.span.to(last.span),
|
||||
};
|
||||
|
||||
// Check if all the fields in the pattern are wildcards.
|
||||
let all_wildcards = subpats.iter().all(|pat| matches!(pat.kind, PatKind::Wild));
|
||||
|
||||
let mut wildcard_sugg = vec!["_"; fields.len() - subpats.len()].join(", ");
|
||||
if !subpats.is_empty() {
|
||||
wildcard_sugg = String::from(", ") + &wildcard_sugg;
|
||||
}
|
||||
|
||||
err.span_suggestion_verbose(
|
||||
after_fields_span,
|
||||
"use `_` to explicitly ignore each field",
|
||||
wildcard_sugg,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
||||
// Only suggest `..` if more than one field is missing
|
||||
// or the pattern consists of all wildcards.
|
||||
if fields.len() - subpats.len() > 1 || all_wildcards {
|
||||
if subpats.is_empty() || all_wildcards {
|
||||
err.span_suggestion_verbose(
|
||||
all_fields_span,
|
||||
"use `..` to ignore all fields",
|
||||
String::from(".."),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
err.span_suggestion_verbose(
|
||||
after_fields_span,
|
||||
"use `..` to ignore the rest of the fields",
|
||||
String::from(", .."),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err.emit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue