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 17 pull requests #81018

Merged
merged 64 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
3ea744e
Recommend panic::resume_unwind instead of panicking.
frewsxcv Dec 18, 2020
1f9a8a1
Add a `std::io::read_to_string` function
camelid Nov 5, 2020
4ee6d1b
Add description independent of `Read::read_to_string`
camelid Dec 30, 2020
588786a
Add error docs
camelid Dec 30, 2020
7ed824e
Add Iterator::intersperse_with
lukaslueg Dec 31, 2020
7a0ada0
Remove FIXME-notes
lukaslueg Jan 6, 2021
f7d261c
Get rid of `DepConstructor`
jyn514 Jan 8, 2021
ebe402d
Fix handling of malicious Readers in read_to_end
sfackler Jan 11, 2021
a9ef798
clean up control flow
sfackler Jan 11, 2021
5cb8303
make check a bit more clear
sfackler Jan 11, 2021
e6c07b0
clarify docs a bit
sfackler Jan 11, 2021
7463292
Add docs on performance
camelid Jan 12, 2021
16692ab
Suggest `_` and `..` if a pattern has too few fields
camelid Dec 13, 2020
5fe61a7
Simplify code
camelid Dec 19, 2020
f3d9df5
Suggest `Variant(..)` if all of the mentioned fields are `_`
camelid Dec 19, 2020
a5e8e6e
Pluralize 'parenthesis' correctly
camelid Dec 19, 2020
fe82cc3
Specialize `..` help message for all fields vs. the rest
camelid Dec 19, 2020
9959d6d
Only suggest `..` if more than one field is missing
camelid Dec 20, 2020
1bce775
Add a test case with lots of whitespace
camelid Jan 13, 2021
d7307a7
Always show suggestions in their own subwindows
camelid Jan 13, 2021
c3f7429
Use better ICE message when no MIR is available
camelid Jan 13, 2021
7e83fec
remove unstable deprecated Vec::remove_item
KodrAus Jan 13, 2021
6bfd987
Update books
ehuss Jan 13, 2021
e8c8793
Include `..` suggestion if fields are all wildcards
camelid Jan 13, 2021
d65cb6e
deprecate atomic::spin_loop_hint in favour of hint::spin_loop
KodrAus Jan 13, 2021
697b20f
Fixed incorrect doc comment
trevarj Jan 13, 2021
64c1b0d
Fix -Cpasses=list and llvm version print with -vV
bjorn3 Jan 13, 2021
5b1316f
unix ExitStatus: Do not treat WIFSTOPPED as WIFSIGNALED
ijackson Dec 12, 2020
12d62aa
unix ExitStatus: Clarify docs for .signal()
ijackson Dec 12, 2020
530270f
unix ExitStatus: Provide .into_raw()
ijackson Dec 12, 2020
3f05051
unix ExitStatus: Provide .core_dumped
ijackson Dec 12, 2020
f060b9e
unix ExitStatus: Provide .stopped_signal()
ijackson Dec 12, 2020
42ea8f6
unix ExitStatus: Provide .continued()
ijackson Dec 12, 2020
29c851a
Replace `Ie` with `In other words`
ijackson Dec 13, 2020
06a405c
Replace `Ie` with `In other words`
ijackson Dec 13, 2020
fa68567
unix ExitStatus: Add tracking issue to new methods
ijackson Jan 4, 2021
7012194
ExitStatusExt unix: Retrospectively seal this trait
ijackson Jan 4, 2021
f3e7199
ExitStatusExt windows: Retrospectively seal this trait
ijackson Jan 4, 2021
efddf59
Fix typo saeled -> sealed
dtolnay Jan 11, 2021
05a88aa
ExitStatusExt: Fix build on Fuchsia
ijackson Jan 13, 2021
b59fa3d
Fix stabilisation version of slice_strip
ijackson Jan 13, 2021
9528988
Add doc intralinks
lukaslueg Jan 13, 2021
0342fd1
Remove the unused context from CreateDebugLocation
cuviper Jan 13, 2021
391b4cc
Fix formatting specifiers doc link
calebsander Jan 13, 2021
9b2f085
Improve Iterator::intersperse_ docs
lukaslueg Jan 13, 2021
eb72dc5
Add as_ref and as_mut methods for Bound
glittershark Dec 28, 2020
a8d0161
Fix typos in Fuchsia unix_process_wait_more
dtolnay Jan 14, 2021
8ac21fb
Rollup merge of #79982 - ijackson:exit-status, r=dtolnay
m-ou-se Jan 14, 2021
d3b3106
Rollup merge of #80017 - camelid:sugg-rest-pattern, r=estebank
m-ou-se Jan 14, 2021
930371b
Rollup merge of #80169 - frewsxcv:frewsxcv-docs-fix, r=jyn514
m-ou-se Jan 14, 2021
9fc298c
Rollup merge of #80217 - camelid:io-read_to_string, r=m-ou-se
m-ou-se Jan 14, 2021
3308b43
Rollup merge of #80444 - glittershark:bound-as-ref, r=dtolnay
m-ou-se Jan 14, 2021
446ed77
Rollup merge of #80567 - lukaslueg:intersperse_with, r=m-ou-se
m-ou-se Jan 14, 2021
9e9aba8
Rollup merge of #80829 - jyn514:dep-constructor, r=michaelwoerister
m-ou-se Jan 14, 2021
ce48709
Rollup merge of #80895 - sfackler:read-to-end-ub, r=m-ou-se
m-ou-se Jan 14, 2021
7855a73
Rollup merge of #80966 - KodrAus:deprecate/spin_loop_hint, r=m-ou-se
m-ou-se Jan 14, 2021
90cc815
Rollup merge of #80969 - camelid:monomorph-ice-msg, r=nagisa
m-ou-se Jan 14, 2021
9bfe6f1
Rollup merge of #80972 - KodrAus:deprecate/remove_item, r=nagisa
m-ou-se Jan 14, 2021
3fe37c3
Rollup merge of #80973 - ehuss:update-books, r=ehuss
m-ou-se Jan 14, 2021
d5e55ce
Rollup merge of #80980 - trevarj:patch-1, r=nagisa
m-ou-se Jan 14, 2021
ce3bc76
Rollup merge of #80981 - bjorn3:bjorn3-patch-1, r=jonas-schievink
m-ou-se Jan 14, 2021
c504e89
Rollup merge of #80985 - ijackson:slice-strip-fix, r=jyn514
m-ou-se Jan 14, 2021
494cb3c
Rollup merge of #80990 - cuviper:unused-debug-context, r=nagisa
m-ou-se Jan 14, 2021
9c75ee6
Rollup merge of #80991 - calebsander:fix/fmt-link, r=m-ou-se
m-ou-se Jan 14, 2021
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
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,6 @@ extern "C" {
);

pub fn LLVMRustDIBuilderCreateDebugLocation(
Context: &'a Context,
Line: c_uint,
Column: c_uint,
Scope: &'a DIScope,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
45 changes: 13 additions & 32 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand All @@ -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};
Expand Down Expand Up @@ -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),)*
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mono.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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())
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 52 additions & 5 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);`.
Expand All @@ -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(());
// | ^ ^
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/sync/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn test_weak_count_locked() {
let n = Arc::weak_count(&a2);
assert!(n < 2, "bad weak count: {}", n);
#[cfg(miri)] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
atomic::spin_loop_hint();
std::hint::spin_loop();
}
t.join().unwrap();
}
Expand Down
21 changes: 0 additions & 21 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1953,27 +1953,6 @@ impl<T: PartialEq, A: Allocator> Vec<T, A> {
}
}

impl<T, A: Allocator> Vec<T, A> {
/// Removes the first instance of `item` from the vector if the item exists.
///
/// This method will be removed soon.
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
#[rustc_deprecated(
reason = "Removing the first item equal to a needle is already easily possible \
with iterators and the current Vec methods. Furthermore, having a method for \
one particular case of removal (linear search, only the first item, no swap remove) \
but not for others is inconsistent. This method will be removed soon.",
since = "1.46.0"
)]
pub fn remove_item<V>(&mut self, item: &V) -> Option<T>
where
T: PartialEq<V>,
{
let pos = self.iter().position(|x| *x == *item)?;
Some(self.remove(pos))
}
}

////////////////////////////////////////////////////////////////////////////////
// Internal methods and functions
////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading