Skip to content

Commit e38fb30

Browse files
committed
Auto merge of rust-lang#81018 - m-ou-se:rollup-7202dc7, r=m-ou-se
Rollup of 17 pull requests Successful merges: - rust-lang#79982 (Add missing methods to unix ExitStatusExt) - rust-lang#80017 (Suggest `_` and `..` if a pattern has too few fields) - rust-lang#80169 (Recommend panic::resume_unwind instead of panicking.) - rust-lang#80217 (Add a `std::io::read_to_string` function) - rust-lang#80444 (Add as_ref and as_mut methods for Bound) - rust-lang#80567 (Add Iterator::intersperse_with) - rust-lang#80829 (Get rid of `DepConstructor`) - rust-lang#80895 (Fix handling of malicious Readers in read_to_end) - rust-lang#80966 (Deprecate atomic::spin_loop_hint in favour of hint::spin_loop) - rust-lang#80969 (Use better ICE message when no MIR is available) - rust-lang#80972 (Remove unstable deprecated Vec::remove_item) - rust-lang#80973 (Update books) - rust-lang#80980 (Fixed incorrect doc comment) - rust-lang#80981 (Fix -Cpasses=list and llvm version print with -vV) - rust-lang#80985 (Fix stabilisation version of slice_strip) - rust-lang#80990 (llvm: Remove the unused context from CreateDebugLocation) - rust-lang#80991 (Fix formatting specifiers doc links) Failed merges: - rust-lang#80944 (Use Option::map_or instead of `.map(..).unwrap_or(..)`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4275ef6 + 9c75ee6 commit e38fb30

File tree

42 files changed

+798
-163
lines changed

Some content is hidden

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

42 files changed

+798
-163
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
552552

553553
unsafe {
554554
llvm::LLVMRustDIBuilderCreateDebugLocation(
555-
utils::debug_context(self).llcontext,
556555
line.unwrap_or(UNKNOWN_LINE_NUMBER),
557556
col.unwrap_or(UNKNOWN_COLUMN_NUMBER),
558557
scope,

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,6 @@ extern "C" {
21022102
);
21032103

21042104
pub fn LLVMRustDIBuilderCreateDebugLocation(
2105-
Context: &'a Context,
21062105
Line: c_uint,
21072106
Column: c_uint,
21082107
Scope: &'a DIScope,

compiler/rustc_driver/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
798798
println!("commit-date: {}", unw(util::commit_date_str()));
799799
println!("host: {}", config::host_triple());
800800
println!("release: {}", unw(util::release_str()));
801-
if cfg!(llvm) {
801+
if cfg!(feature = "llvm") {
802802
get_builtin_codegen_backend("llvm")().print_version();
803803
}
804804
}
@@ -1087,7 +1087,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10871087
}
10881088

10891089
if cg_flags.iter().any(|x| *x == "passes=list") {
1090-
if cfg!(llvm) {
1090+
if cfg!(feature = "llvm") {
10911091
get_builtin_codegen_backend("llvm")().print_passes();
10921092
}
10931093
return None;

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -994,11 +994,9 @@ LLVMRustDICompositeTypeReplaceArrays(LLVMRustDIBuilderRef Builder,
994994
}
995995

996996
extern "C" LLVMMetadataRef
997-
LLVMRustDIBuilderCreateDebugLocation(LLVMContextRef ContextRef, unsigned Line,
998-
unsigned Column, LLVMMetadataRef Scope,
997+
LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column,
998+
LLVMMetadataRef Scope,
999999
LLVMMetadataRef InlinedAt) {
1000-
LLVMContext &Context = *unwrap(ContextRef);
1001-
10021000
DebugLoc debug_loc = DebugLoc::get(Line, Column, unwrapDIPtr<MDNode>(Scope),
10031001
unwrapDIPtr<MDNode>(InlinedAt));
10041002

compiler/rustc_middle/src/dep_graph/dep_node.rs

+13-32
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
//! contained no `DefId` for thing that had been removed.
3030
//!
3131
//! `DepNode` definition happens in the `define_dep_nodes!()` macro. This macro
32-
//! defines the `DepKind` enum and a corresponding `dep_constructor` module. The
33-
//! `dep_constructor` module links a `DepKind` to the parameters that are needed at
34-
//! runtime in order to construct a valid `DepNode` fingerprint.
32+
//! defines the `DepKind` enum. Each `DepKind` has its own parameters that are
33+
//! needed at runtime in order to construct a valid `DepNode` fingerprint.
34+
//! However, only `CompileCodegenUnit` is constructed explicitly (with
35+
//! `make_compile_codegen_unit`).
3536
//!
3637
//! Because the macro sees what parameters a given `DepKind` requires, it can
3738
//! "infer" some properties for each kind of `DepNode`:
@@ -44,22 +45,14 @@
4445
//! `DefId` it was computed from. In other cases, too much information gets
4546
//! lost during fingerprint computation.
4647
//!
47-
//! The `dep_constructor` module, together with `DepNode::new()`, ensures that only
48+
//! `make_compile_codegen_unit`, together with `DepNode::new()`, ensures that only
4849
//! valid `DepNode` instances can be constructed. For example, the API does not
4950
//! allow for constructing parameterless `DepNode`s with anything other
5051
//! than a zeroed out fingerprint. More generally speaking, it relieves the
5152
//! user of the `DepNode` API of having to know how to compute the expected
5253
//! fingerprint for a given set of node parameters.
5354
54-
use crate::mir::interpret::{GlobalId, LitToConstInput};
55-
use crate::traits;
56-
use crate::traits::query::{
57-
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
58-
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
59-
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
60-
};
61-
use crate::ty::subst::{GenericArg, SubstsRef};
62-
use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
55+
use crate::ty::TyCtxt;
6356

6457
use rustc_data_structures::fingerprint::Fingerprint;
6558
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
@@ -338,25 +331,6 @@ macro_rules! define_dep_nodes {
338331
$($variant),*
339332
}
340333

341-
#[allow(non_camel_case_types)]
342-
pub mod dep_constructor {
343-
use super::*;
344-
345-
$(
346-
#[inline(always)]
347-
#[allow(unreachable_code, non_snake_case)]
348-
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
349-
// tuple args
350-
$({
351-
erase!($tuple_arg_ty);
352-
return DepNode::construct(_tcx, DepKind::$variant, &arg)
353-
})*
354-
355-
return DepNode::construct(_tcx, DepKind::$variant, &())
356-
}
357-
)*
358-
}
359-
360334
fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
361335
match label {
362336
$(stringify!($variant) => Ok(DepKind::$variant),)*
@@ -384,9 +358,16 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
384358

385359
[anon] TraitSelect,
386360

361+
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
387362
[] CompileCodegenUnit(Symbol),
388363
]);
389364

365+
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
366+
// Be very careful changing this type signature!
367+
crate fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
368+
DepNode::construct(tcx, DepKind::CompileCodegenUnit, &name)
369+
}
370+
390371
pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
391372

392373
// We keep a lot of `DepNode`s in memory during compilation. It's not

compiler/rustc_middle/src/dep_graph/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ pub use rustc_query_system::dep_graph::{
1313
WorkProduct, WorkProductId,
1414
};
1515

16-
pub use dep_node::{dep_constructor, label_strs, DepKind, DepNode, DepNodeExt};
16+
crate use dep_node::make_compile_codegen_unit;
17+
pub use dep_node::{label_strs, DepKind, DepNode, DepNodeExt};
1718

1819
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
1920
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;

compiler/rustc_middle/src/mir/mono.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::dep_graph::{dep_constructor, DepNode, WorkProduct, WorkProductId};
1+
use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
22
use crate::ich::{NodeIdHashingMode, StableHashingContext};
33
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
44
use rustc_attr::InlineAttr;
@@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> {
362362
}
363363

364364
pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode {
365-
dep_constructor::CompileCodegenUnit(tcx, self.name())
365+
crate::dep_graph::make_compile_codegen_unit(tcx, self.name())
366366
}
367367
}
368368

compiler/rustc_mir/src/monomorphize/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
823823
}
824824

825825
if !tcx.is_mir_available(def_id) {
826-
bug!("cannot create local mono-item for {:?}", def_id)
826+
bug!("no MIR available for {:?}", def_id);
827827
}
828828

829829
true

compiler/rustc_typeck/src/check/pat.rs

+52-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_span::hygiene::DesugaringKind;
1515
use rustc_span::lev_distance::find_best_match_for_name;
1616
use rustc_span::source_map::{Span, Spanned};
1717
use rustc_span::symbol::Ident;
18+
use rustc_span::{BytePos, DUMMY_SP};
1819
use rustc_trait_selection::traits::{ObligationCause, Pattern};
1920

2021
use std::cmp;
@@ -1001,7 +1002,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10011002
// More generally, the expected type wants a tuple variant with one field of an
10021003
// N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern
10031004
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
1004-
let missing_parenthesis = match (&expected.kind(), fields, had_err) {
1005+
let missing_parentheses = match (&expected.kind(), fields, had_err) {
10051006
// #67037: only do this if we could successfully type-check the expected type against
10061007
// the tuple struct pattern. Otherwise the substs could get out of range on e.g.,
10071008
// `let P() = U;` where `P != U` with `struct P<T>(T);`.
@@ -1014,13 +1015,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10141015
}
10151016
_ => false,
10161017
};
1017-
if missing_parenthesis {
1018+
if missing_parentheses {
10181019
let (left, right) = match subpats {
10191020
// This is the zero case; we aim to get the "hi" part of the `QPath`'s
10201021
// span as the "lo" and then the "hi" part of the pattern's span as the "hi".
10211022
// This looks like:
10221023
//
1023-
// help: missing parenthesis
1024+
// help: missing parentheses
10241025
// |
10251026
// L | let A(()) = A(());
10261027
// | ^ ^
@@ -1029,17 +1030,63 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10291030
// last sub-pattern. In the case of `A(x)` the first and last may coincide.
10301031
// This looks like:
10311032
//
1032-
// help: missing parenthesis
1033+
// help: missing parentheses
10331034
// |
10341035
// L | let A((x, y)) = A((1, 2));
10351036
// | ^ ^
10361037
[first, ..] => (first.span.shrink_to_lo(), subpats.last().unwrap().span),
10371038
};
10381039
err.multipart_suggestion(
1039-
"missing parenthesis",
1040+
"missing parentheses",
10401041
vec![(left, "(".to_string()), (right.shrink_to_hi(), ")".to_string())],
10411042
Applicability::MachineApplicable,
10421043
);
1044+
} else if fields.len() > subpats.len() {
1045+
let after_fields_span = if pat_span == DUMMY_SP {
1046+
pat_span
1047+
} else {
1048+
pat_span.with_hi(pat_span.hi() - BytePos(1)).shrink_to_hi()
1049+
};
1050+
let all_fields_span = match subpats {
1051+
[] => after_fields_span,
1052+
[field] => field.span,
1053+
[first, .., last] => first.span.to(last.span),
1054+
};
1055+
1056+
// Check if all the fields in the pattern are wildcards.
1057+
let all_wildcards = subpats.iter().all(|pat| matches!(pat.kind, PatKind::Wild));
1058+
1059+
let mut wildcard_sugg = vec!["_"; fields.len() - subpats.len()].join(", ");
1060+
if !subpats.is_empty() {
1061+
wildcard_sugg = String::from(", ") + &wildcard_sugg;
1062+
}
1063+
1064+
err.span_suggestion_verbose(
1065+
after_fields_span,
1066+
"use `_` to explicitly ignore each field",
1067+
wildcard_sugg,
1068+
Applicability::MaybeIncorrect,
1069+
);
1070+
1071+
// Only suggest `..` if more than one field is missing
1072+
// or the pattern consists of all wildcards.
1073+
if fields.len() - subpats.len() > 1 || all_wildcards {
1074+
if subpats.is_empty() || all_wildcards {
1075+
err.span_suggestion_verbose(
1076+
all_fields_span,
1077+
"use `..` to ignore all fields",
1078+
String::from(".."),
1079+
Applicability::MaybeIncorrect,
1080+
);
1081+
} else {
1082+
err.span_suggestion_verbose(
1083+
after_fields_span,
1084+
"use `..` to ignore the rest of the fields",
1085+
String::from(", .."),
1086+
Applicability::MaybeIncorrect,
1087+
);
1088+
}
1089+
}
10431090
}
10441091

10451092
err.emit();

library/alloc/src/sync/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ fn test_weak_count_locked() {
370370
let n = Arc::weak_count(&a2);
371371
assert!(n < 2, "bad weak count: {}", n);
372372
#[cfg(miri)] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
373-
atomic::spin_loop_hint();
373+
std::hint::spin_loop();
374374
}
375375
t.join().unwrap();
376376
}

library/alloc/src/vec/mod.rs

-21
Original file line numberDiff line numberDiff line change
@@ -1953,27 +1953,6 @@ impl<T: PartialEq, A: Allocator> Vec<T, A> {
19531953
}
19541954
}
19551955

1956-
impl<T, A: Allocator> Vec<T, A> {
1957-
/// Removes the first instance of `item` from the vector if the item exists.
1958-
///
1959-
/// This method will be removed soon.
1960-
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
1961-
#[rustc_deprecated(
1962-
reason = "Removing the first item equal to a needle is already easily possible \
1963-
with iterators and the current Vec methods. Furthermore, having a method for \
1964-
one particular case of removal (linear search, only the first item, no swap remove) \
1965-
but not for others is inconsistent. This method will be removed soon.",
1966-
since = "1.46.0"
1967-
)]
1968-
pub fn remove_item<V>(&mut self, item: &V) -> Option<T>
1969-
where
1970-
T: PartialEq<V>,
1971-
{
1972-
let pos = self.iter().position(|x| *x == *item)?;
1973-
Some(self.remove(pos))
1974-
}
1975-
}
1976-
19771956
////////////////////////////////////////////////////////////////////////////////
19781957
// Internal methods and functions
19791958
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)