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 12 pull requests #69795

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
940f657
Parse & reject postfix operators after casts
daboross Feb 9, 2020
5ce9b80
Refactor out error case & apply suggestions.
daboross Feb 16, 2020
4fc0532
Type ascription outputs a Type, not Cast
daboross Feb 16, 2020
0cf2049
Keep better fix suggestion if type ascription is likely unintended
daboross Feb 16, 2020
f82ca8b
Add more error cases to issue 35813 tests
daboross Feb 16, 2020
5dd6464
Fix related type ascription tests.
daboross Feb 16, 2020
e3eefe2
Remove extra debug print in unreachable!
daboross Feb 16, 2020
c2d7ffb
Remove trailing whitespace
daboross Feb 16, 2020
8ef3da0
Fix test stderr after rebasing on master.
daboross Feb 16, 2020
fa1f547
Add more double cast + method call tests
daboross Feb 22, 2020
f434c6e
Use multipart suggestion
daboross Feb 22, 2020
453c505
Replace ptr hashing with ptr casting
daboross Feb 25, 2020
7859f0e
Make PlaceRef lifetimes of Place::as_ref be both 'tcx
spastorino Mar 3, 2020
812e62f
Make PlaceRef lifetimes of LocalAnalyzer::process_place be both 'tcx
spastorino Mar 3, 2020
d3e5177
Use .next() instead of .nth(0) on iterators.
matthiaskrgr Mar 3, 2020
98c7ed6
DefKind::Method -> DefKind::AssocFn
mark-i-m Mar 3, 2020
3aeb9f0
rename TraitItemKind::Method -> Fn
mark-i-m Mar 3, 2020
1a1dcfa
Make PlaceRef lifetimes of codegen_place be both 'tcx
spastorino Mar 3, 2020
2af5e87
Make PlaceRef lifetimes of monomorphized_place_ty be both 'tcx
spastorino Mar 3, 2020
a20d54f
Make PlaceRef lifetimes of RootPlace be both 'tcx
spastorino Mar 3, 2020
5456114
test(pattern): add tests for combinations of pattern features
thekuom Mar 4, 2020
b4788a7
test(pattern): harden tests for or-patterns with slice-patterns
thekuom Mar 4, 2020
ea7b3c3
fix tidy error
thekuom Mar 4, 2020
842af36
Make PlaceRef lifetimes of borrow_conflict_place be both 'tcx
spastorino Mar 4, 2020
f54e863
Make PlaceRef lifetimes of move_error_reported be both 'tcx
spastorino Mar 4, 2020
6200f5c
Make PlaceRef lifetimes of uninitialized_error_reported be both 'tcx
spastorino Mar 4, 2020
e32ee55
Make PlaceRef lifetimes of move_path_closest_to be both 'tcx
spastorino Mar 4, 2020
634a167
Make PlaceRef lifetimes of move_path_for_place be both 'tcx
spastorino Mar 4, 2020
53be0cc
Use subslice patterns in slice methods
cuviper Mar 4, 2020
c6f1244
Make PlaceRef lifetimes of is_upvar_field_projection be both 'tcx
spastorino Mar 4, 2020
6f23650
Make PlaceRef lifetimes of add_moved_or_invoked_closure_note be both …
spastorino Mar 4, 2020
eb67eca
Make PlaceRef lifetimes of describe_field be both 'tcx
spastorino Mar 4, 2020
a30f55f
Make PlaceRef lifetimes of borrowed_content_source be both 'tcx
spastorino Mar 4, 2020
bd4dad4
Make PlaceRef lifetimes of move_spans be both 'tcx
spastorino Mar 4, 2020
46d85e5
Make PlaceRef lifetimes of closure_span be both 'tcx
spastorino Mar 4, 2020
a32afa3
Make PlaceRef lifetimes of classify_drop_access_kind be both 'tcx
spastorino Mar 4, 2020
a5d1e18
Make PlaceRef lifetimes of is_prefix_of be both 'tcx
spastorino Mar 4, 2020
2cb2559
Make PlaceRef lifetimes of in_projection be both 'tcx
spastorino Mar 4, 2020
b11cd0b
PlaceRef<'a, 'tcx> -> PlaceRef<'tcx>
spastorino Mar 4, 2020
9afbf28
Update deprecation version to 1.42 for Error::description
dylnuge Mar 6, 2020
5d308ae
ast: `Mac`/`Macro` -> `MacCall`
petrochenkov Feb 29, 2020
2d0c5b4
rustc_expand: Factor out `Annotatable::into_tokens` to a separate method
petrochenkov Mar 3, 2020
83980ac
Don't redundantly repeat field names (clippy::redundant_field_names)
matthiaskrgr Mar 6, 2020
1631b4d
Avoid using `unwrap()` in suggestions
JohnTitor Mar 5, 2020
3d67649
Add a regression test
JohnTitor Mar 6, 2020
125159f
When encountering an Item in a pat context, point at the item def
estebank Dec 30, 2019
39ca644
Rollup merge of #67741 - estebank:point-at-pat-def, r=Centril
Centril Mar 7, 2020
bb0959d
Rollup merge of #68985 - daboross:fix-35813, r=Centril
Centril Mar 7, 2020
4e6fddf
Rollup merge of #69589 - petrochenkov:maccall, r=Centril
Centril Mar 7, 2020
11f08b2
Rollup merge of #69656 - matthiaskrgr:iter_nth_zero, r=oli-obk
Centril Mar 7, 2020
e3def0e
Rollup merge of #69674 - mark-i-m:assoc-fn, r=Centril
Centril Mar 7, 2020
d1bb2a6
Rollup merge of #69680 - petrochenkov:nont4, r=Centril
Centril Mar 7, 2020
4f87d9f
Rollup merge of #69690 - thekuom:test/67311-extend-bindings-after-at-…
Centril Mar 7, 2020
2a87b39
Rollup merge of #69706 - cuviper:subslice-methods, r=Centril
Centril Mar 7, 2020
2603a19
Rollup merge of #69714 - spastorino:place-ref-lifetime, r=oli-obk
Centril Mar 7, 2020
6a9ec75
Rollup merge of #69727 - JohnTitor:sugg-unwrap, r=estebank
Centril Mar 7, 2020
49eae8a
Rollup merge of #69754 - Dylnuge:dylnuge/dep-version, r=Mark-Simulacrum
Centril Mar 7, 2020
46266c1
Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cra…
Centril Mar 7, 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 src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ impl<T> LinkedList<T> {
let it = self.head;
let old_len = self.len;

DrainFilter { list: self, it: it, pred: filter, idx: 0, old_len: old_len }
DrainFilter { list: self, it, pred: filter, idx: 0, old_len }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ struct SetLenOnDrop<'a> {
impl<'a> SetLenOnDrop<'a> {
#[inline]
fn new(len: &'a mut usize) -> Self {
SetLenOnDrop { local_len: *len, len: len }
SetLenOnDrop { local_len: *len, len }
}

#[inline]
Expand Down
30 changes: 8 additions & 22 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn first(&self) -> Option<&T> {
self.get(0)
if let [first, ..] = self { Some(first) } else { None }
}

/// Returns a mutable pointer to the first element of the slice, or `None` if it is empty.
Expand All @@ -121,7 +121,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn first_mut(&mut self) -> Option<&mut T> {
self.get_mut(0)
if let [first, ..] = self { Some(first) } else { None }
}

/// Returns the first and all the rest of the elements of the slice, or `None` if it is empty.
Expand All @@ -139,7 +139,7 @@ impl<T> [T] {
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_first(&self) -> Option<(&T, &[T])> {
if self.is_empty() { None } else { Some((&self[0], &self[1..])) }
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}

/// Returns the first and all the rest of the elements of the slice, or `None` if it is empty.
Expand All @@ -159,12 +159,7 @@ impl<T> [T] {
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_first_mut(&mut self) -> Option<(&mut T, &mut [T])> {
if self.is_empty() {
None
} else {
let split = self.split_at_mut(1);
Some((&mut split.0[0], split.1))
}
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}

/// Returns the last and all the rest of the elements of the slice, or `None` if it is empty.
Expand All @@ -182,8 +177,7 @@ impl<T> [T] {
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_last(&self) -> Option<(&T, &[T])> {
let len = self.len();
if len == 0 { None } else { Some((&self[len - 1], &self[..(len - 1)])) }
if let [init @ .., last] = self { Some((last, init)) } else { None }
}

/// Returns the last and all the rest of the elements of the slice, or `None` if it is empty.
Expand All @@ -203,13 +197,7 @@ impl<T> [T] {
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_last_mut(&mut self) -> Option<(&mut T, &mut [T])> {
let len = self.len();
if len == 0 {
None
} else {
let split = self.split_at_mut(len - 1);
Some((&mut split.1[0], split.0))
}
if let [init @ .., last] = self { Some((last, init)) } else { None }
}

/// Returns the last element of the slice, or `None` if it is empty.
Expand All @@ -226,8 +214,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn last(&self) -> Option<&T> {
let last_idx = self.len().checked_sub(1)?;
self.get(last_idx)
if let [.., last] = self { Some(last) } else { None }
}

/// Returns a mutable pointer to the last item in the slice.
Expand All @@ -245,8 +232,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn last_mut(&mut self) -> Option<&mut T> {
let last_idx = self.len().checked_sub(1)?;
self.get_mut(last_idx)
if let [.., last] = self { Some(last) } else { None }
}

/// Returns a reference to an element or subslice depending on the type of
Expand Down
17 changes: 7 additions & 10 deletions src/libproc_macro/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ pub struct Diagnostic {
}

macro_rules! diagnostic_child_methods {
($spanned:ident, $regular:ident, $level:expr) => (
($spanned:ident, $regular:ident, $level:expr) => {
/// Adds a new child diagnostic message to `self` with the level
/// identified by this method's name with the given `spans` and
/// `message`.
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
pub fn $spanned<S, T>(mut self, spans: S, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>
where
S: MultiSpan,
T: Into<String>,
{
self.children.push(Diagnostic::spanned(spans, $level, message));
self
Expand All @@ -74,7 +76,7 @@ macro_rules! diagnostic_child_methods {
self.children.push(Diagnostic::new($level, message));
self
}
)
};
}

/// Iterator over the children diagnostics of a `Diagnostic`.
Expand All @@ -96,7 +98,7 @@ impl Diagnostic {
/// Creates a new diagnostic with the given `level` and `message`.
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic {
Diagnostic { level: level, message: message.into(), spans: vec![], children: vec![] }
Diagnostic { level, message: message.into(), spans: vec![], children: vec![] }
}

/// Creates a new diagnostic with the given `level` and `message` pointing to
Expand All @@ -107,12 +109,7 @@ impl Diagnostic {
S: MultiSpan,
T: Into<String>,
{
Diagnostic {
level: level,
message: message.into(),
spans: spans.into_spans(),
children: vec![],
}
Diagnostic { level, message: message.into(), spans: spans.into_spans(), children: vec![] }
}

diagnostic_child_methods!(span_error, error, Level::Error);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> {
impl MaybeFnLike for hir::TraitItem<'_> {
fn is_fn_like(&self) -> bool {
match self.kind {
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
_ => false,
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> {
_ => bug!("item FnLikeNode that is not fn-like"),
},
Node::TraitItem(ti) => match ti.kind {
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
}
_ => bug!("trait method FnLikeNode that is not fn-like"),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl DefPath {
}
}
data.reverse();
DefPath { data: data, krate: krate }
DefPath { data, krate }
}

/// Returns a string representation of the `DefPath` without
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> {
},

Node::TraitItem(ref item) => match item.kind {
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
_ => None,
},

Expand All @@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> {
},

Node::TraitItem(item) => match &item.kind {
TraitItemKind::Method(sig, _) => Some(sig),
TraitItemKind::Fn(sig, _) => Some(sig),
_ => None,
},

Expand All @@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> {

Node::TraitItem(item) => match item.kind {
TraitItemKind::Const(_, Some(body))
| TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
| TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body),
_ => None,
},

Expand Down Expand Up @@ -326,12 +326,12 @@ impl<'hir> Map<'hir> {
},
Node::TraitItem(item) => match item.kind {
TraitItemKind::Const(..) => DefKind::AssocConst,
TraitItemKind::Method(..) => DefKind::Method,
TraitItemKind::Fn(..) => DefKind::AssocFn,
TraitItemKind::Type(..) => DefKind::AssocTy,
},
Node::ImplItem(item) => match item.kind {
ImplItemKind::Const(..) => DefKind::AssocConst,
ImplItemKind::Method(..) => DefKind::Method,
ImplItemKind::Method(..) => DefKind::AssocFn,
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
},
Expand Down Expand Up @@ -472,7 +472,7 @@ impl<'hir> Map<'hir> {
| Node::AnonConst(_) => BodyOwnerKind::Const,
Node::Ctor(..)
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. })
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
Expand Down Expand Up @@ -800,7 +800,7 @@ impl<'hir> Map<'hir> {
_ => false,
},
Node::TraitItem(ti) => match ti.kind {
TraitItemKind::Method(..) => true,
TraitItemKind::Fn(..) => true,
_ => false,
},
Node::ImplItem(ii) => match ii.kind {
Expand Down Expand Up @@ -1311,7 +1311,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
Some(Node::TraitItem(ti)) => {
let kind = match ti.kind {
TraitItemKind::Const(..) => "assoc constant",
TraitItemKind::Method(..) => "trait method",
TraitItemKind::Fn(..) => "trait method",
TraitItemKind::Type(..) => "assoc type",
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub enum EvalResult {
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
// Check if `def_id` is a trait method.
match tcx.def_kind(def_id) {
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
// Trait methods do not declare visibility (even
// for visibility info in cstore). Use containing
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ impl<'tcx> Debug for TerminatorKind<'tcx> {
match successor_count {
0 => Ok(()),

1 => write!(fmt, " -> {:?}", self.successors().nth(0).unwrap()),
1 => write!(fmt, " -> {:?}", self.successors().next().unwrap()),

_ => {
write!(fmt, " -> [")?;
Expand Down Expand Up @@ -1827,9 +1827,9 @@ rustc_index::newtype_index! {
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct PlaceRef<'a, 'tcx> {
pub struct PlaceRef<'tcx> {
pub local: Local,
pub projection: &'a [PlaceElem<'tcx>],
pub projection: &'tcx [PlaceElem<'tcx>],
}

impl<'tcx> Place<'tcx> {
Expand Down Expand Up @@ -1864,7 +1864,7 @@ impl<'tcx> Place<'tcx> {
self.as_ref().as_local()
}

pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
pub fn as_ref(&self) -> PlaceRef<'tcx> {
PlaceRef { local: self.local, projection: &self.projection }
}
}
Expand All @@ -1875,7 +1875,7 @@ impl From<Local> for Place<'_> {
}
}

impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
impl<'tcx> PlaceRef<'tcx> {
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
/// a single deref of a local.
//
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub enum Visibility {

impl<'tcx> CodegenUnit<'tcx> {
pub fn new(name: Symbol) -> CodegenUnit<'tcx> {
CodegenUnit { name: name, items: Default::default(), size_estimate: None }
CodegenUnit { name, items: Default::default(), size_estimate: None }
}

pub fn name(&self) -> Symbol {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
nested,
}) => tcx.lift(&substs).map(|substs| {
traits::VtableGenerator(traits::VtableGeneratorData {
generator_def_id: generator_def_id,
substs: substs,
nested: nested,
generator_def_id,
substs,
nested,
})
}),
traits::VtableClosure(traits::VtableClosureData { closure_def_id, substs, nested }) => {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> {
}

match self.type_dependent_defs().get(expr.hir_id) {
Some(Ok((DefKind::Method, _))) => true,
Some(Ok((DefKind::AssocFn, _))) => true,
_ => false,
}
}
Expand Down Expand Up @@ -2256,22 +2256,22 @@ impl<'tcx> TyCtxt<'tcx> {

#[inline]
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ref(r, TypeAndMut { ty: ty, mutbl: hir::Mutability::Mut })
self.mk_ref(r, TypeAndMut { ty, mutbl: hir::Mutability::Mut })
}

#[inline]
pub fn mk_imm_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ref(r, TypeAndMut { ty: ty, mutbl: hir::Mutability::Not })
self.mk_ref(r, TypeAndMut { ty, mutbl: hir::Mutability::Not })
}

#[inline]
pub fn mk_mut_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ptr(TypeAndMut { ty: ty, mutbl: hir::Mutability::Mut })
self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Mut })
}

#[inline]
pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ptr(TypeAndMut { ty: ty, mutbl: hir::Mutability::Not })
self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Not })
}

#[inline]
Expand Down Expand Up @@ -2393,7 +2393,7 @@ impl<'tcx> TyCtxt<'tcx> {

#[inline]
pub fn mk_ty_param(self, index: u32, name: Symbol) -> Ty<'tcx> {
self.mk_ty(Param(ParamTy { index, name: name }))
self.mk_ty(Param(ParamTy { index, name }))
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<'tcx> Instance<'tcx> {
def_id,
substs
);
Instance { def: InstanceDef::Item(def_id), substs: substs }
Instance { def: InstanceDef::Item(def_id), substs }
}

pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {
Expand Down
Loading