Skip to content

Rollup of 6 pull requests #67505

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

Merged
merged 51 commits into from
Dec 22, 2019
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
44603a5
Reenable static linking of libstdc++ on windows-gnu
mati865 Dec 18, 2019
3a93a0e
HAIR lowering: improve code quality for slices
Centril Dec 19, 2019
7d99e4e
check_pat_slice: shadow 'expected' to make sure it's not used again
Centril Dec 19, 2019
13b7101
`lower_pattern_unadjusted`: remove dead code.
Centril Dec 19, 2019
ceaec1d
`check_pat_slice`: extract `check_aray_pat_len`.
Centril Dec 19, 2019
2a9f1f8
`lower_pattern_unadjusted`: extract common `ty::Error` code.
Centril Dec 19, 2019
3b0af1d
`lower_pattern_unadjusted`: cleanup `Slice(..)` branch.
Centril Dec 19, 2019
be6381e
`lower_pattern_unadjusted`: cleanup `Tuple(..)` branch.
Centril Dec 19, 2019
eb020bc
`lower_pattern_unadjusted`: simplify `Binding(..)` branch.
Centril Dec 19, 2019
d63c324
`lower_pattern_unadjusted`: extract `lower_tuple_subpats`.
Centril Dec 19, 2019
cc3160b
`lower_pattern_unadjusted`: simplify `Or(..)` branch.
Centril Dec 19, 2019
6286a1d
`slice_or_array_pattern`: remove dead code.
Centril Dec 19, 2019
7353ff2
`SliceKind::VarLen`: make doc-comment render correctly.
Centril Dec 20, 2019
f7256d2
Require issue = "none" over issue = "0" in unstable attributes
rossmacarthur Dec 21, 2019
f3ef4a4
extract parse_ty_tuple_or_parens
Centril Dec 8, 2019
c67c30d
refactor parse_ty_tuple_or_parens
Centril Dec 8, 2019
3838b60
parse_ptr -> parse_ty_ptr & refactor
Centril Dec 8, 2019
211560d
extract parse_array_or_slice_ty
Centril Dec 8, 2019
e08886d
extract parse_typeof_ty
Centril Dec 8, 2019
edb7b96
extract parse_impl_ty
Centril Dec 8, 2019
b7071f2
extract parse_dyn_ty
Centril Dec 8, 2019
85d3ed9
extract parse_path_start_ty
Centril Dec 8, 2019
6f1f6a6
extract error_illegal_c_variadic_ty
Centril Dec 8, 2019
3b1fab8
parse_ty_common: .fatal -> .struct_span_err
Centril Dec 8, 2019
3f499a9
parser/ty.rs: minor formatting tweaks
Centril Dec 8, 2019
b484fae
extract error_opt_out_lifetime
Centril Dec 8, 2019
a11252a
extract recover_paren_lifetime
Centril Dec 8, 2019
e61cb44
parse_generic_bounds_common: dedent
Centril Dec 8, 2019
fd89104
extract can_begin_bound
Centril Dec 8, 2019
8a9a992
extract parse_generic_bound
Centril Dec 8, 2019
18e5b2f
functionalize parse_generic_bound
Centril Dec 8, 2019
1cfeb56
parse_generic_bound: leave a FIXME
Centril Dec 8, 2019
50e00c7
extract parse_generic_ty_bound
Centril Dec 8, 2019
4b073a1
extract parse_generic_lt_bound
Centril Dec 8, 2019
f215ca9
simplify negative bound diagnostic
Centril Dec 8, 2019
4625ba4
simplify 'let question = ...;'
Centril Dec 8, 2019
b5f00be
parse_generic_bounds: account for negative lifetime bounds
Centril Dec 8, 2019
f221b39
extract error_negative_bounds
Centril Dec 8, 2019
d010560
document parse_late_bound_lifetime_defs
Centril Dec 8, 2019
d6f37c6
parse_ty_bare_fn: improve docs
Centril Dec 8, 2019
52fa020
unwrap -> expect
Centril Dec 21, 2019
db4818f
span_suggestion_hidden -> tool_only_span_suggestion
Centril Dec 21, 2019
62714f8
Update unstable book build to use NonZeroU32
LeSeulArtichaut Dec 21, 2019
30e84b0
Tweak non_shorthand_field_patterns' suggestion
JohnTitor Dec 21, 2019
a34c267
Warn against relying on ?Sized being last
Mark-Simulacrum Dec 22, 2019
616373e
Rollup merge of #67148 - Centril:ty-polish, r=estebank
Centril Dec 22, 2019
35ff2f1
Rollup merge of #67410 - mati865:mingw_link_fix, r=Mark-Simulacrum
Centril Dec 22, 2019
877dc9d
Rollup merge of #67439 - Centril:clean-hair-slice, r=matthewjasper
Centril Dec 22, 2019
eaeb113
Rollup merge of #67480 - rossmacarthur:fix-41260-avoid-issue-0-part-2…
Centril Dec 22, 2019
c355463
Rollup merge of #67500 - JohnTitor:non-shorthand-field-patterns, r=Ce…
Centril Dec 22, 2019
ca528fc
Rollup merge of #67504 - Mark-Simulacrum:note-data-offset, r=Centril
Centril Dec 22, 2019
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
Prev Previous commit
Next Next commit
slice_or_array_pattern: remove dead code.
After #62550, it is no longer possible for `slice`
to be other than `None | Some(Binding(..) | Wild)`.
In particular, `lower_pat_slice` may never generate
`Some(Array(..) | Slice(..))` and so there is nothing
to flatten into `slice`.
  • Loading branch information
Centril committed Dec 19, 2019
commit 6286a1d7eb68875504536c78f6316cad7e7490b2
43 changes: 1 addition & 42 deletions src/librustc_mir/hair/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
}

hir::PatKind::Slice(ref prefix, ref slice, ref suffix) => {
match ty.kind {
ty::Slice(..) | ty::Array(..) => {}
_ => span_bug!(pat.span, "unexpanded type for vector pattern: {:?}", ty),
}
self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix)
}

Expand Down Expand Up @@ -658,44 +654,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
pats.iter().map(|p| self.lower_pattern(p)).collect()
}

fn lower_opt_pattern(&mut self, pat: &'tcx Option<P<hir::Pat>>) -> Option<Pat<'tcx>>
{
fn lower_opt_pattern(&mut self, pat: &'tcx Option<P<hir::Pat>>) -> Option<Pat<'tcx>> {
pat.as_ref().map(|p| self.lower_pattern(p))
}

fn flatten_nested_slice_patterns(
&mut self,
prefix: Vec<Pat<'tcx>>,
slice: Option<Pat<'tcx>>,
suffix: Vec<Pat<'tcx>>,
) -> (Vec<Pat<'tcx>>, Option<Pat<'tcx>>, Vec<Pat<'tcx>>) {
let orig_slice = match slice {
Some(orig_slice) => orig_slice,
None => return (prefix, slice, suffix)
};
let orig_prefix = prefix;
let orig_suffix = suffix;

// dance because of intentional borrow-checker stupidity.
let kind = *orig_slice.kind;
match kind {
PatKind::Slice { prefix, slice, mut suffix } |
PatKind::Array { prefix, slice, mut suffix } => {
let mut orig_prefix = orig_prefix;

orig_prefix.extend(prefix);
suffix.extend(orig_suffix);

(orig_prefix, slice, suffix)
}
_ => {
(orig_prefix, Some(Pat {
kind: box kind, ..orig_slice
}), orig_suffix)
}
}
}

fn slice_or_array_pattern(
&mut self,
span: Span,
Expand All @@ -707,9 +669,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
let prefix = self.lower_patterns(prefix);
let slice = self.lower_opt_pattern(slice);
let suffix = self.lower_patterns(suffix);
let (prefix, slice, suffix) = self.flatten_nested_slice_patterns(prefix, slice, suffix);

// Some validation:
match ty.kind {
// Matching a slice, `[T]`.
ty::Slice(..) => PatKind::Slice { prefix, slice, suffix },
Expand Down