diff options
| author | bors <bors@rust-lang.org> | 2021-01-31 03:05:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-31 03:05:09 +0000 |
| commit | 7850c28a5ff0c21f658b869138d3b8658b21a554 (patch) | |
| tree | 3db651c094d64a56272738c2f5dcfda11c4bef66 /compiler | |
| parent | b3897e3d1302391ed02efbac1dce8073646b8173 (diff) | |
| parent | 8b281d9cd7dac7a2bd3a40027c93f5c74d2f9c24 (diff) | |
| download | rust-7850c28a5ff0c21f658b869138d3b8658b21a554.tar.gz rust-7850c28a5ff0c21f658b869138d3b8658b21a554.zip | |
Auto merge of #81578 - jonas-schievink:rollup-yhiyowl, r=jonas-schievink
Rollup of 18 pull requests
Successful merges:
- #78044 (Implement io::Seek for io::Empty)
- #79285 (Stabilize Arc::{increment,decrement}_strong_count)
- #80053 (stabilise `cargo test -- --include-ignored`)
- #80279 (Implement missing `AsMut<str>` for `str`)
- #80470 (Stabilize by-value `[T; N]` iterator `core::array::IntoIter`)
- #80945 (Add Box::downcast() for dyn Any + Send + Sync)
- #81048 (Stabilize `core::slice::fill_with`)
- #81198 (Remove requirement that forces symmetric and transitive PartialEq impls to exist)
- #81422 (Account for existing `_` field pattern when suggesting `..`)
- #81472 (Clone entire `TokenCursor` when collecting tokens)
- #81484 (Optimize decimal formatting of 128-bit integers)
- #81491 (Balance sidebar `Deref` cycle check with main content)
- #81509 (Add a regression test for ICE of bad_placeholder_type)
- #81547 (Edit rustc_typeck top-level docs)
- #81550 (Replace predecessor with range in collections documentation)
- #81558 (Fix ascii art text wrapping in mobile)
- #81562 (Clarify that InPlaceIterable guarantees extend to all advancing iterator methods.)
- #81563 (Improve docblock readability on small screen)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_arena/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/mod.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/pat.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/lib.rs | 7 |
8 files changed, 23 insertions, 29 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 54552b499be..651f4c6fabd 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -11,11 +11,9 @@ html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/", test(no_crate_inject, attr(deny(warnings))) )] -#![feature(array_value_iter_slice)] #![feature(dropck_eyepatch)] #![feature(new_uninit)] #![feature(maybe_uninit_slice)] -#![feature(array_value_iter)] #![cfg_attr(bootstrap, feature(min_const_generics))] #![feature(min_specialization)] #![cfg_attr(test, feature(test))] diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 6d95da02151..8f2e49e299c 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -30,7 +30,6 @@ //! get confused if the spans from leaf AST nodes occur in multiple places //! in the HIR, especially for multiple identifiers. -#![feature(array_value_iter)] #![feature(crate_visibility_modifier)] #![feature(or_patterns)] #![recursion_limit = "256"] diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 8b55ec6c705..efc516a662f 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -2,7 +2,6 @@ //! //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html -#![feature(array_value_iter)] #![feature(crate_visibility_modifier)] #![feature(const_fn)] // For the unsizing cast on `&[]` #![feature(const_panic)] diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index c575c821964..e2af63d1744 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1254,15 +1254,7 @@ impl<'a> Parser<'a> { f: impl FnOnce(&mut Self) -> PResult<'a, (R, TrailingToken)>, ) -> PResult<'a, R> { let start_token = (self.token.clone(), self.token_spacing); - let cursor_snapshot = TokenCursor { - frame: self.token_cursor.frame.clone(), - // We only ever capture tokens within our current frame, - // so we can just use an empty frame stack - stack: vec![], - desugar_doc_comments: self.token_cursor.desugar_doc_comments, - num_next_calls: self.token_cursor.num_next_calls, - append_unglued_token: self.token_cursor.append_unglued_token.clone(), - }; + let cursor_snapshot = self.token_cursor.clone(); let (mut ret, trailing_token) = f(self)?; diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 42509cd8975..e1f8d59991f 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -11,7 +11,6 @@ //! This API is completely unstable and subject to change. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] -#![feature(array_value_iter)] #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(drain_filter)] diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index c8c6fa12fae..dc3e3b4e738 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -52,13 +52,13 @@ The types of top-level items, which never contain unbound type variables, are stored directly into the `tcx` typeck_results. N.B., a type variable is not the same thing as a type parameter. A -type variable is rather an "instance" of a type parameter: that is, -given a generic function `fn foo<T>(t: T)`: while checking the +type variable is an instance of a type parameter. That is, +given a generic function `fn foo<T>(t: T)`, while checking the function `foo`, the type `ty_param(0)` refers to the type `T`, which -is treated in abstract. When `foo()` is called, however, `T` will be +is treated in abstract. However, when `foo()` is called, `T` will be substituted for a fresh type variable `N`. This variable will eventually be resolved to some concrete type (which might itself be -type parameter). +a type parameter). */ diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 1c1f7f7886f..d7e69668e5e 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1041,12 +1041,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { 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() - }; + } else if fields.len() > subpats.len() && pat_span != DUMMY_SP { + let after_fields_span = pat_span.with_hi(pat_span.hi() - BytePos(1)).shrink_to_hi(); let all_fields_span = match subpats { [] => after_fields_span, [field] => field.span, @@ -1055,7 +1051,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check if all the fields in the pattern are wildcards. let all_wildcards = subpats.iter().all(|pat| matches!(pat.kind, PatKind::Wild)); + let first_tail_wildcard = + subpats.iter().enumerate().fold(None, |acc, (pos, pat)| match (acc, &pat.kind) { + (None, PatKind::Wild) => Some(pos), + (Some(_), PatKind::Wild) => acc, + _ => None, + }); + let tail_span = match first_tail_wildcard { + None => after_fields_span, + Some(0) => subpats[0].span.to(after_fields_span), + Some(pos) => subpats[pos - 1].span.shrink_to_hi().to(after_fields_span), + }; + // FIXME: heuristic-based suggestion to check current types for where to add `_`. let mut wildcard_sugg = vec!["_"; fields.len() - subpats.len()].join(", "); if !subpats.is_empty() { wildcard_sugg = String::from(", ") + &wildcard_sugg; @@ -1080,7 +1088,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } else { err.span_suggestion_verbose( - after_fields_span, + tail_span, "use `..` to ignore the rest of the fields", String::from(", .."), Applicability::MaybeIncorrect, diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index ad92d816c98..fd44bafab6f 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -7,9 +7,9 @@ The type checker is responsible for: 1. Determining the type of each expression. 2. Resolving methods and traits. 3. Guaranteeing that most type rules are met. ("Most?", you say, "why most?" - Well, dear reader, read on) + Well, dear reader, read on.) -The main entry point is `check_crate()`. Type checking operates in +The main entry point is [`check_crate()`]. Type checking operates in several major phases: 1. The collect phase first passes over all items and determines their @@ -25,7 +25,7 @@ several major phases: containing function). Inference is used to supply types wherever they are unknown. The actual checking of a function itself has several phases (check, regionck, writeback), as discussed in the - documentation for the `check` module. + documentation for the [`check`] module. The type checker is defined into various submodules which are documented independently: @@ -56,7 +56,6 @@ This API is completely unstable and subject to change. */ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] -#![feature(array_value_iter)] #![feature(bool_to_option)] #![feature(box_syntax)] #![feature(crate_visibility_modifier)] |
