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 15 pull requests #80276

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0698922
Deprecate compare_and_swap on all atomic types
faern Nov 20, 2020
7bd770c
Add documentation on migrating away from compare_and_swap
faern Nov 20, 2020
df2ef1d
Migrate standard library away from compare_and_swap
faern Nov 20, 2020
90e6eeb
Add doc aliases to compare_exchange[_weak]
faern Nov 22, 2020
ed7b244
Fix documentation typo
faern Nov 22, 2020
7a40b6d
Improve documentation on `success` and `failure` arguments
faern Nov 22, 2020
50b2ade
Revert the usage of compare_exchange_weak
faern Nov 22, 2020
3b8617b
Added [T; N]::zip()
usbalbin Nov 26, 2020
2f35fb1
Remove redundant tests
usbalbin Nov 27, 2020
06ca6bb
Add tests
Nadrieril Nov 22, 2020
d1a50ff
Rename the `overlapping_patterns` lint to `overlapping_range_endpoints`
Nadrieril Oct 22, 2020
c89d439
Be consistent about linting singletons
Nadrieril Oct 22, 2020
94ad5e1
Improve error message
Nadrieril Oct 22, 2020
5687c16
`overlapping_range_endpoints` does not belong in the `unused` lint group
Nadrieril Nov 22, 2020
be2c8f2
Update zip for better codegen, see discussion
usbalbin Dec 16, 2020
baa5e47
Update doc comment
usbalbin Dec 16, 2020
8b37259
Added reference to tracking issue
usbalbin Dec 16, 2020
830ceaa
Remap instrument-coverage line numbers in doctests
Swatinem Dec 6, 2020
5b6c175
Tweak diagnostics
Nadrieril Dec 19, 2020
52b717f
Edit rustc_middle::lint::LintSource docs
pierwill Dec 19, 2020
4fffa74
docs: Edit rustc_middle::ty::query::on_disk_cache
pierwill Dec 19, 2020
01d7f87
Reserve necessary space for params in generics_of
bugadani Dec 19, 2020
c127530
Fix labels for 'Library Tracking Issue' template
camelid Dec 20, 2020
e614a72
Fix rustc-std-workspace-core documentation
GreenRecycleBin Dec 20, 2020
51d1806
docs: Fix outdated crate reference
pierwill Dec 20, 2020
9f8c8e4
Add module-level docs to rustc_middle::ty
pierwill Dec 20, 2020
f9fa3fe
add an attribute to inner doctest fn
Swatinem Dec 20, 2020
32baf23
Fix typo
pierwill Dec 20, 2020
dc58fc4
Remove `I-prioritize` from Zulip topic
camelid Dec 20, 2020
087101e
make path normalization compatible with mac python2
Swatinem Dec 21, 2020
a272d62
Implemented a compiler diagnostic for move async mistake
diondokter Dec 18, 2020
dffa1e2
Remove redundant test
bugadani Dec 21, 2020
6e5f5e1
Rollup merge of #78242 - Nadrieril:rename-overlapping_endpoints-lint,…
Dylan-DPC Dec 21, 2020
aec379f
Rollup merge of #79261 - faern:deprecate-compare-and-swap, r=Amanieu
Dylan-DPC Dec 21, 2020
f9b9e5d
Rollup merge of #79451 - usbalbin:array_zip, r=m-ou-se
Dylan-DPC Dec 21, 2020
341b76c
Rollup merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinem
Dylan-DPC Dec 21, 2020
233aa15
Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwco
Dylan-DPC Dec 21, 2020
b86a966
Rollup merge of #80203 - pierwill:pierwill-rustcmiddle-lint, r=oli-obk
Dylan-DPC Dec 21, 2020
d4133df
Rollup merge of #80204 - pierwill:pierwill-rustcmiddle-ondisk, r=varkor
Dylan-DPC Dec 21, 2020
2063b6f
Rollup merge of #80208 - bugadani:generics-of-alloc, r=matthewjasper
Dylan-DPC Dec 21, 2020
dde9d69
Rollup merge of #80219 - camelid:library_tracking_issue-labels, r=m-o…
Dylan-DPC Dec 21, 2020
945ebe7
Rollup merge of #80222 - GreenRecycleBin:daniel/fix-rustc-std-workspa…
Dylan-DPC Dec 21, 2020
2925484
Rollup merge of #80223 - pierwill:patch-10, r=lcnr
Dylan-DPC Dec 21, 2020
1ae2913
Rollup merge of #80225 - pierwill:patch-11, r=lcnr
Dylan-DPC Dec 21, 2020
698e258
Rollup merge of #80241 - pierwill:patch-12, r=lcnr
Dylan-DPC Dec 21, 2020
d0e2518
Rollup merge of #80248 - camelid:prioritize-zulip-topic, r=Mark-Simul…
Dylan-DPC Dec 21, 2020
02b2798
Rollup merge of #80266 - bugadani:dup-test, r=jyn514
Dylan-DPC Dec 21, 2020
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/library_tracking_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Library Tracking Issue
about: A tracking issue for an unstable library feature.
title: Tracking Issue for XXX
labels: C-tracking-issue T-libs
labels: C-tracking-issue, T-libs
---
<!--
Thank you for creating a tracking issue!
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
UNUSED_MUT,
UNREACHABLE_CODE,
UNREACHABLE_PATTERNS,
OVERLAPPING_PATTERNS,
UNUSED_MUST_USE,
UNUSED_UNSAFE,
PATH_STATEMENTS,
Expand Down Expand Up @@ -335,6 +334,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
store.register_renamed("redundant_semicolon", "redundant_semicolons");
store.register_renamed("intra_doc_link_resolution_failure", "broken_intra_doc_links");
store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");
store.register_removed("unknown_features", "replaced by an error");
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
store.register_removed("negate_unsigned", "cast a signed value instead");
Expand Down
17 changes: 8 additions & 9 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ declare_lint! {
}

declare_lint! {
/// The `overlapping_patterns` lint detects `match` arms that have
/// [range patterns] that overlap.
/// The `overlapping_range_endpoints` lint detects `match` arms that have [range patterns] that
/// overlap on their endpoints.
///
/// [range patterns]: https://doc.rust-lang.org/nightly/reference/patterns.html#range-patterns
///
Expand All @@ -607,13 +607,12 @@ declare_lint! {
///
/// ### Explanation
///
/// It is likely a mistake to have range patterns in a match expression
/// that overlap. Check that the beginning and end values are what you
/// expect, and keep in mind that with `..=` the left and right bounds are
/// inclusive.
pub OVERLAPPING_PATTERNS,
/// It is likely a mistake to have range patterns in a match expression that overlap in this
/// way. Check that the beginning and end values are what you expect, and keep in mind that
/// with `..=` the left and right bounds are inclusive.
pub OVERLAPPING_RANGE_ENDPOINTS,
Warn,
"detects overlapping patterns"
"detects range patterns with overlapping endpoints"
}

declare_lint! {
Expand Down Expand Up @@ -2809,7 +2808,7 @@ declare_lint_pass! {
DEAD_CODE,
UNREACHABLE_CODE,
UNREACHABLE_PATTERNS,
OVERLAPPING_PATTERNS,
OVERLAPPING_RANGE_ENDPOINTS,
BINDINGS_WITH_VARIANT_NAME,
UNUSED_MACROS,
WARNINGS,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! - **MIR.** The "mid-level (M) intermediate representation (IR)" is
//! defined in the `mir` module. This module contains only the
//! *definition* of the MIR; the passes that transform and operate
//! on MIR are found in `librustc_mir` crate.
//! on MIR are found in `rustc_mir` crate.
//! - **Types.** The internal representation of types used in rustc is
//! defined in the `ty` module. This includes the **type context**
//! (or `tcx`), which is the central context during most of
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub enum LintSource {
Node(Symbol, Span, Option<Symbol> /* RFC 2383 reason */),

/// Lint level was set by a command-line flag.
/// The provided `Level` is the level specified on the command line -
/// the actual level may be lower due to `--cap-lints`
/// The provided `Level` is the level specified on the command line.
/// (The actual level may be lower due to `--cap-lints`.)
CommandLine(Symbol, Level),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct DefIdForest {
/// If A and B are DefIds in the `DefIdForest`, and A is a descendant
/// of B, then only B will be in `root_ids`.
/// We use a `SmallVec` here because (for its use for caching inhabitedness)
/// its rare that this will contain even two IDs.
/// it's rare that this will contain even two IDs.
root_ids: SmallVec<[DefId; 1]>,
}

Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//! Defines how the compiler represents types internally.
//!
//! Two important entities in this module are:
//!
//! - [`rustc_middle::ty::Ty`], used to represent the semantics of a type.
//! - [`rustc_middle::ty::TyCtxt`], the central data structure in the compiler.
//!
//! For more information, see ["The `ty` module: representing types"] in the ructc-dev-guide.
//!
//! ["The `ty` module: representing types"]: https://rustc-dev-guide.rust-lang.org/ty.html

// ignore-tidy-filelength
pub use self::fold::{TypeFoldable, TypeFolder, TypeVisitor};
pub use self::AssocItemContainer::*;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl<'sess> OnDiskCache<'sess> {

//- DECODING -------------------------------------------------------------------

/// A decoder that can read from the incr. comp. cache. It is similar to the one
/// A decoder that can read from the incremental compilation cache. It is similar to the one
/// we use for crate metadata decoding in that it can rebase spans and eventually
/// will also handle things that contain `Ty` instances.
crate struct CacheDecoder<'a, 'tcx> {
Expand Down Expand Up @@ -936,7 +936,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [Span] {

//- ENCODING -------------------------------------------------------------------

/// An encoder that can write the incr. comp. cache.
/// An encoder that can write to the incremental compilation cache.
struct CacheEncoder<'a, 'tcx, E: OpaqueEncoder> {
tcx: TyCtxt<'tcx>,
encoder: &'a mut E,
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_mir/src/transform/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use rustc_middle::mir::{
};
use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::DefId;
use rustc_span::source_map::SourceMap;
use rustc_span::{CharPos, Pos, SourceFile, Span, Symbol};

/// A simple error message wrapper for `coverage::Error`s.
Expand Down Expand Up @@ -311,7 +312,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
self.mir_body,
counter_kind,
self.bcb_leader_bb(bcb),
Some(make_code_region(file_name, &self.source_file, span, body_span)),
Some(make_code_region(source_map, file_name, &self.source_file, span, body_span)),
);
}
}
Expand Down Expand Up @@ -489,6 +490,7 @@ fn inject_intermediate_expression(mir_body: &mut mir::Body<'tcx>, expression: Co

/// Convert the Span into its file name, start line and column, and end line and column
fn make_code_region(
source_map: &SourceMap,
file_name: Symbol,
source_file: &Lrc<SourceFile>,
span: Span,
Expand All @@ -508,6 +510,8 @@ fn make_code_region(
} else {
source_file.lookup_file_pos(span.hi())
};
let start_line = source_map.doctest_offset_line(&source_file.name, start_line);
let end_line = source_map.doctest_offset_line(&source_file.name, end_line);
CodeRegion {
file_name,
start_line: start_line as u32,
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl IntRange {
// 2 -------- // 2 -------
let (lo, hi) = self.boundaries();
let (other_lo, other_hi) = other.boundaries();
lo == other_hi || hi == other_lo
(lo == other_hi || hi == other_lo) && !self.is_singleton() && !other.is_singleton()
}

fn to_pat<'tcx>(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Pat<'tcx> {
Expand Down Expand Up @@ -273,7 +273,7 @@ impl IntRange {
let mut borders: Vec<_> = row_borders.chain(self_borders).collect();
borders.sort_unstable();

self.lint_overlapping_patterns(pcx, hir_id, overlaps);
self.lint_overlapping_range_endpoints(pcx, hir_id, overlaps);

// We're going to iterate through every adjacent pair of borders, making sure that
// each represents an interval of nonnegative length, and convert each such
Expand All @@ -296,30 +296,30 @@ impl IntRange {
.collect()
}

fn lint_overlapping_patterns(
fn lint_overlapping_range_endpoints(
&self,
pcx: PatCtxt<'_, '_, '_>,
hir_id: Option<HirId>,
overlaps: Vec<(IntRange, Span)>,
) {
if let (true, Some(hir_id)) = (!overlaps.is_empty(), hir_id) {
pcx.cx.tcx.struct_span_lint_hir(
lint::builtin::OVERLAPPING_PATTERNS,
lint::builtin::OVERLAPPING_RANGE_ENDPOINTS,
hir_id,
pcx.span,
|lint| {
let mut err = lint.build("multiple patterns covering the same range");
err.span_label(pcx.span, "overlapping patterns");
let mut err = lint.build("multiple patterns overlap on their endpoints");
for (int_range, span) in overlaps {
// Use the real type for user display of the ranges:
err.span_label(
span,
&format!(
"this range overlaps on `{}`",
int_range.to_pat(pcx.cx.tcx, pcx.ty),
"this range overlaps on `{}`...",
int_range.to_pat(pcx.cx.tcx, pcx.ty)
),
);
}
err.span_label(pcx.span, "... with this range");
err.note("you likely meant to write mutually exclusive ranges");
err.emit();
},
);
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,4 +1912,22 @@ impl<'a> Parser<'a> {
*self = snapshot;
Err(err)
}

/// Get the diagnostics for the cases where `move async` is found.
///
/// `move_async_span` starts at the 'm' of the move keyword and ends with the 'c' of the async keyword
pub(super) fn incorrect_move_async_order_found(
&self,
move_async_span: Span,
) -> DiagnosticBuilder<'a> {
let mut err =
self.struct_span_err(move_async_span, "the order of `move` and `async` is incorrect");
err.span_suggestion_verbose(
move_async_span,
"try switching the order",
"async move".to_owned(),
Applicability::MaybeIncorrect,
);
err
}
}
18 changes: 14 additions & 4 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ impl<'a> Parser<'a> {
self.sess.gated_spans.gate(sym::async_closure, span);
}

let capture_clause = self.parse_capture_clause();
let capture_clause = self.parse_capture_clause()?;
let decl = self.parse_fn_block_decl()?;
let decl_hi = self.prev_token.span;
let body = match decl.output {
Expand All @@ -1626,8 +1626,18 @@ impl<'a> Parser<'a> {
}

/// Parses an optional `move` prefix to a closure-like construct.
fn parse_capture_clause(&mut self) -> CaptureBy {
if self.eat_keyword(kw::Move) { CaptureBy::Value } else { CaptureBy::Ref }
fn parse_capture_clause(&mut self) -> PResult<'a, CaptureBy> {
if self.eat_keyword(kw::Move) {
// Check for `move async` and recover
if self.check_keyword(kw::Async) {
let move_async_span = self.token.span.with_lo(self.prev_token.span.data().lo);
Err(self.incorrect_move_async_order_found(move_async_span))
} else {
Ok(CaptureBy::Value)
}
} else {
Ok(CaptureBy::Ref)
}
}

/// Parses the `|arg, arg|` header of a closure.
Expand Down Expand Up @@ -2019,7 +2029,7 @@ impl<'a> Parser<'a> {
fn parse_async_block(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
let lo = self.token.span;
self.expect_keyword(kw::Async)?;
let capture_clause = self.parse_capture_clause();
let capture_clause = self.parse_capture_clause()?;
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
attrs.extend(iattrs);
let kind = ExprKind::Async(capture_clause, DUMMY_NODE_ID, body);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl std::fmt::Display for FileName {
use FileName::*;
match *self {
Real(RealFileName::Named(ref path)) => write!(fmt, "{}", path.display()),
// FIXME: might be nice to display both compoments of Devirtualized.
// FIXME: might be nice to display both components of Devirtualized.
// But for now (to backport fix for issue #70924), best to not
// perturb diagnostics so its obvious test suite still works.
Real(RealFileName::Devirtualized { ref local_path, virtual_name: _ }) => {
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,11 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
generics.parent_count + generics.params.len()
});

let mut params: Vec<_> = opt_self.into_iter().collect();
let mut params: Vec<_> = Vec::with_capacity(ast_generics.params.len() + has_self as usize);

if let Some(opt_self) = opt_self {
params.push(opt_self);
}

let early_lifetimes = early_bound_lifetimes_from_generics(tcx, ast_generics);
params.extend(early_lifetimes.enumerate().map(|(i, param)| ty::GenericParamDef {
Expand Down
31 changes: 31 additions & 0 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,37 @@ impl<T, const N: usize> [T; N] {
unsafe { crate::mem::transmute_copy::<_, [U; N]>(&dst) }
}

/// 'Zips up' two arrays into a single array of pairs.
///
/// `zip()` returns a new array where every element is a tuple where the
/// first element comes from the first array, and the second element comes
/// from the second array. In other words, it zips two arrays together,
/// into a single one.
///
/// # Examples
///
/// ```
/// #![feature(array_zip)]
/// let x = [1, 2, 3];
/// let y = [4, 5, 6];
/// let z = x.zip(y);
/// assert_eq!(z, [(1, 4), (2, 5), (3, 6)]);
/// ```
#[unstable(feature = "array_zip", issue = "80094")]
pub fn zip<U>(self, rhs: [U; N]) -> [(T, U); N] {
use crate::mem::MaybeUninit;

let mut dst = MaybeUninit::uninit_array::<N>();
for (i, (lhs, rhs)) in IntoIter::new(self).zip(IntoIter::new(rhs)).enumerate() {
dst[i].write((lhs, rhs));
}
// FIXME: Convert to crate::mem::transmute once it works with generics.
// unsafe { crate::mem::transmute::<[MaybeUninit<U>; N], [U; N]>(dst) }
// SAFETY: At this point we've properly initialized the whole array
// and we just need to cast it to the correct type.
unsafe { crate::mem::transmute_copy::<_, [(T, U); N]>(&dst) }
}

/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
#[unstable(feature = "array_methods", issue = "76118")]
pub fn as_slice(&self) -> &[T] {
Expand Down
Loading