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 11 pull requests #63575

Merged
merged 48 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3b229f1
check that ptr is valid already when doing Deref, not only when doing…
RalfJung Jul 27, 2019
5800bec
discourage use of ref_to_mplace
RalfJung Jul 28, 2019
3677c5b
the alignment checks on access can no longer fail now
RalfJung Jul 28, 2019
e4c39e1
better name for check_in_alloc
RalfJung Jul 28, 2019
388d99d
fix tests
RalfJung Jul 28, 2019
74fbdb6
move 'get me the access-checked version of an mplace' into separate f…
RalfJung Jul 28, 2019
647c0e0
'Ref' can now be sure it gets a 'Pointer'
RalfJung Jul 28, 2019
a4af9d1
parse_pat_with_range_pat: remove unnecessary assignments.
Centril Aug 12, 2019
90793c0
extract parse_pat_deref
Centril Aug 12, 2019
c69b3ed
extract parse_pat_tuple_or_parens
Centril Aug 12, 2019
3b65133
extract recover_pat_ident_mut_first
Centril Aug 12, 2019
231da7e
extract ban_pat_range_if_ambiguous
Centril Aug 12, 2019
e32bd69
extract parse_pat_mac_invoc
Centril Aug 12, 2019
e6f980f
extract parse_pat_range_starting_with_path
Centril Aug 12, 2019
49740b7
extract parse_pat_range_starting_with_lit
Centril Aug 12, 2019
37f37a5
parser/pat: minor misc cleanup
Centril Aug 12, 2019
ddf734d
extract fatal_unexpected_non_pat
Centril Aug 12, 2019
c8fc4c1
extract parse_pat_{tuple_}struct + recover_one_fewer_dotdot
Centril Aug 12, 2019
71415ef
Parse excess semicolons as empty stmts for linting
nathanwhit Jul 25, 2019
2f6cb5f
Add lint for excess trailing semicolons
nathanwhit Jul 30, 2019
76a1345
Update tests for excess semicolon lint
nathanwhit Jul 30, 2019
b8708e2
When needing type annotations in local bindings, account for impl Tra…
estebank Aug 12, 2019
3b6d46c
Resolve types when suggesting boxed closure
estebank Aug 13, 2019
1e6f753
Fix tidy
estebank Aug 13, 2019
fb2511c
Suggest `Box::new` when appropriate
estebank Aug 13, 2019
13fd466
Point at the right enclosing scope when using `await` in non-async fn
estebank Aug 13, 2019
376636e
syntax: Remove `DummyResult::expn_only`
petrochenkov Aug 13, 2019
939c1cb
review comments
estebank Aug 13, 2019
25d507f
review comment: move test
estebank Aug 13, 2019
0d29142
expand: `expand_fragment` -> `fully_expand_fragment`
petrochenkov Aug 13, 2019
d416ebe
expand: Unimplement `MutVisitor` on `MacroExpander`
petrochenkov Aug 13, 2019
806476c
Suggest giving return type to closures on E0282
estebank Aug 13, 2019
9348af8
Add NodeId for Arm, Field and FieldPat
c410-f3r Aug 14, 2019
264640c
move test that shouldn't be in test/run-pass/
Centril Aug 14, 2019
6a42b0b
Merge Variant and Variant_
c410-f3r Aug 14, 2019
24693d7
Adjust tracking issues for `MaybeUninit<T>` gates
Centril Aug 14, 2019
6c3a98e
review comments
estebank Aug 14, 2019
7178cf5
Rollup merge of #62984 - nathanwhit:extra_semi_lint, r=varkor
Centril Aug 14, 2019
c358476
Rollup merge of #63075 - RalfJung:deref-checks, r=oli-obk
Centril Aug 14, 2019
aaeff01
Rollup merge of #63490 - Centril:cleanup-pat-parser, r=petrochenkov
Centril Aug 14, 2019
d2d49d2
Rollup merge of #63507 - estebank:type-inference-error, r=Centril
Centril Aug 14, 2019
02e2a57
Rollup merge of #63509 - estebank:async-span, r=Centril
Centril Aug 14, 2019
409df9b
Rollup merge of #63528 - petrochenkov:anyany, r=estebank
Centril Aug 14, 2019
83cd4e3
Rollup merge of #63537 - petrochenkov:novisit, r=alexcrichton
Centril Aug 14, 2019
d4ecc6f
Rollup merge of #63542 - c410-f3r:node_ids, r=petrochenkov
Centril Aug 14, 2019
ad44d42
Rollup merge of #63543 - c410-f3r:variant, r=c410-f3r
Centril Aug 14, 2019
d11cf77
Rollup merge of #63560 - Centril:mv-generator-test, r=petrochenkov
Centril Aug 14, 2019
78cd9d1
Rollup merge of #63570 - rust-lang:maybe-uninit-gates, r=RalfJung
Centril Aug 14, 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
12 changes: 6 additions & 6 deletions src/libcore/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<T> MaybeUninit<T> {
/// without dropping it, so be careful not to use this twice unless you want to
/// skip running the destructor. For your convenience, this also returns a mutable
/// reference to the (now safely initialized) contents of `self`.
#[unstable(feature = "maybe_uninit_extra", issue = "53491")]
#[unstable(feature = "maybe_uninit_extra", issue = "63567")]
#[inline(always)]
pub fn write(&mut self, val: T) -> &mut T {
unsafe {
Expand Down Expand Up @@ -502,7 +502,7 @@ impl<T> MaybeUninit<T> {
/// // We now created two copies of the same vector, leading to a double-free when
/// // they both get dropped!
/// ```
#[unstable(feature = "maybe_uninit_extra", issue = "53491")]
#[unstable(feature = "maybe_uninit_extra", issue = "63567")]
#[inline(always)]
pub unsafe fn read(&self) -> T {
intrinsics::panic_if_uninhabited::<T>();
Expand All @@ -516,7 +516,7 @@ impl<T> MaybeUninit<T> {
/// It is up to the caller to guarantee that the `MaybeUninit<T>` really is in an initialized
/// state. Calling this when the content is not yet fully initialized causes undefined
/// behavior.
#[unstable(feature = "maybe_uninit_ref", issue = "53491")]
#[unstable(feature = "maybe_uninit_ref", issue = "63568")]
#[inline(always)]
pub unsafe fn get_ref(&self) -> &T {
&*self.value
Expand All @@ -532,21 +532,21 @@ impl<T> MaybeUninit<T> {
// FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references
// to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make
// a final decision about the rules before stabilization.
#[unstable(feature = "maybe_uninit_ref", issue = "53491")]
#[unstable(feature = "maybe_uninit_ref", issue = "63568")]
#[inline(always)]
pub unsafe fn get_mut(&mut self) -> &mut T {
&mut *self.value
}

/// Gets a pointer to the first element of the array.
#[unstable(feature = "maybe_uninit_slice", issue = "53491")]
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
#[inline(always)]
pub fn first_ptr(this: &[MaybeUninit<T>]) -> *const T {
this as *const [MaybeUninit<T>] as *const T
}

/// Gets a mutable pointer to the first element of the array.
#[unstable(feature = "maybe_uninit_slice", issue = "53491")]
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
#[inline(always)]
pub fn first_ptr_mut(this: &mut [MaybeUninit<T>]) -> *mut T {
this as *mut [MaybeUninit<T>] as *mut T
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
fn is_c_like_enum(item: &hir::Item) -> bool {
if let hir::ItemKind::Enum(ref def, _) = item.node {
for variant in &def.variants {
match variant.node.data {
match variant.data {
hir::VariantData::Unit(..) => { /* continue */ }
_ => { return false; }
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,15 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
variant: &'v Variant,
generics: &'v Generics,
parent_item_id: HirId) {
visitor.visit_ident(variant.node.ident);
visitor.visit_id(variant.node.id);
visitor.visit_variant_data(&variant.node.data,
variant.node.ident.name,
visitor.visit_ident(variant.ident);
visitor.visit_id(variant.id);
visitor.visit_variant_data(&variant.data,
variant.ident.name,
generics,
parent_item_id,
variant.span);
walk_list!(visitor, visit_anon_const, &variant.node.disr_expr);
walk_list!(visitor, visit_attribute, &variant.node.attrs);
walk_list!(visitor, visit_anon_const, &variant.disr_expr);
walk_list!(visitor, visit_attribute, &variant.attrs);
}

pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
Expand Down
5 changes: 4 additions & 1 deletion src/librustc/hir/lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ impl LoweringContext<'_> {
let fn_decl = self.lower_fn_decl(decl, None, false, None);

self.with_new_scopes(|this| {
let prev = this.current_item;
this.current_item = Some(fn_decl_span);
let mut generator_kind = None;
let body_id = this.lower_fn_body(decl, |this| {
Expand All @@ -690,8 +691,10 @@ impl LoweringContext<'_> {
generator_kind,
movability,
);
let capture_clause = this.lower_capture_clause(capture_clause);
this.current_item = prev;
hir::ExprKind::Closure(
this.lower_capture_clause(capture_clause),
capture_clause,
fn_decl,
body_id,
fn_decl_span,
Expand Down
14 changes: 6 additions & 8 deletions src/librustc/hir/lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,12 @@ impl LoweringContext<'_> {
}

fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
Spanned {
node: hir::VariantKind {
ident: v.node.ident,
id: self.lower_node_id(v.node.id),
attrs: self.lower_attrs(&v.node.attrs),
data: self.lower_variant_data(&v.node.data),
disr_expr: v.node.disr_expr.as_ref().map(|e| self.lower_anon_const(e)),
},
hir::Variant {
attrs: self.lower_attrs(&v.attrs),
data: self.lower_variant_data(&v.data),
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const(e)),
id: self.lower_node_id(v.id),
ident: v.ident,
span: v.span,
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,11 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
}

fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: HirId) {
self.insert(v.span, v.node.id, Node::Variant(v));
self.with_parent(v.node.id, |this| {
self.insert(v.span, v.id, Node::Variant(v));
self.with_parent(v.id, |this| {
// Register the constructor of this variant.
if let Some(ctor_hir_id) = v.node.data.ctor_hir_id() {
this.insert(v.span, ctor_hir_id, Node::Ctor(&v.node.data));
if let Some(ctor_hir_id) = v.data.ctor_hir_id() {
this.insert(v.span, ctor_hir_id, Node::Ctor(&v.data));
}
intravisit::walk_variant(this, v, g, item_id);
});
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}

fn visit_variant(&mut self, v: &'a Variant, g: &'a Generics, item_id: NodeId) {
let def = self.create_def(v.node.id,
DefPathData::TypeNs(v.node.ident.as_interned_str()),
let def = self.create_def(v.id,
DefPathData::TypeNs(v.ident.as_interned_str()),
v.span);
self.with_parent(def, |this| {
if let Some(ctor_hir_id) = v.node.data.ctor_id() {
if let Some(ctor_hir_id) = v.data.ctor_id() {
this.create_def(ctor_hir_id, DefPathData::Ctor, v.span);
}
visit::walk_variant(this, v, g, item_id)
Expand Down
42 changes: 32 additions & 10 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,34 @@ impl<'hir> Map<'hir> {
}
}

pub fn is_const_scope(&self, hir_id: HirId) -> bool {
self.walk_parent_nodes(hir_id, |node| match *node {
Node::Item(Item { node: ItemKind::Const(_, _), .. }) => true,
Node::Item(Item { node: ItemKind::Fn(_, header, _, _), .. }) => header.is_const(),
/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
/// Used exclusively for diagnostics, to avoid suggestion function calls.
pub fn is_const_context(&self, hir_id: HirId) -> bool {
let parent_id = self.get_parent_item(hir_id);
match self.get(parent_id) {
Node::Item(&Item {
node: ItemKind::Const(..),
..
})
| Node::TraitItem(&TraitItem {
node: TraitItemKind::Const(..),
..
})
| Node::ImplItem(&ImplItem {
node: ImplItemKind::Const(..),
..
})
| Node::AnonConst(_)
| Node::Item(&Item {
node: ItemKind::Static(..),
..
}) => true,
Node::Item(&Item {
node: ItemKind::Fn(_, header, ..),
..
}) => header.constness == Constness::Const,
_ => false,
}, |_| false).map(|id| id != CRATE_HIR_ID).unwrap_or(false)
}
}

/// If there is some error when walking the parents (e.g., a node does not
Expand Down Expand Up @@ -885,7 +907,7 @@ impl<'hir> Map<'hir> {
_ => bug!("struct ID bound to non-struct {}", self.node_to_string(id))
}
}
Some(Node::Variant(variant)) => &variant.node.data,
Some(Node::Variant(variant)) => &variant.data,
Some(Node::Ctor(data)) => data,
_ => bug!("expected struct or variant, found {}", self.node_to_string(id))
}
Expand Down Expand Up @@ -918,7 +940,7 @@ impl<'hir> Map<'hir> {
Node::ForeignItem(fi) => fi.ident.name,
Node::ImplItem(ii) => ii.ident.name,
Node::TraitItem(ti) => ti.ident.name,
Node::Variant(v) => v.node.ident.name,
Node::Variant(v) => v.ident.name,
Node::Field(f) => f.ident.name,
Node::Lifetime(lt) => lt.name.ident().name,
Node::GenericParam(param) => param.name.ident().name,
Expand All @@ -939,7 +961,7 @@ impl<'hir> Map<'hir> {
Some(Node::ForeignItem(fi)) => Some(&fi.attrs[..]),
Some(Node::TraitItem(ref ti)) => Some(&ti.attrs[..]),
Some(Node::ImplItem(ref ii)) => Some(&ii.attrs[..]),
Some(Node::Variant(ref v)) => Some(&v.node.attrs[..]),
Some(Node::Variant(ref v)) => Some(&v.attrs[..]),
Some(Node::Field(ref f)) => Some(&f.attrs[..]),
Some(Node::Expr(ref e)) => Some(&*e.attrs),
Some(Node::Stmt(ref s)) => Some(s.node.attrs()),
Expand Down Expand Up @@ -1133,7 +1155,7 @@ impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.name() }

impl Named for Item { fn name(&self) -> Name { self.ident.name } }
impl Named for ForeignItem { fn name(&self) -> Name { self.ident.name } }
impl Named for VariantKind { fn name(&self) -> Name { self.ident.name } }
impl Named for Variant { fn name(&self) -> Name { self.ident.name } }
impl Named for StructField { fn name(&self) -> Name { self.ident.name } }
impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } }
impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } }
Expand Down Expand Up @@ -1310,7 +1332,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
}
Some(Node::Variant(ref variant)) => {
format!("variant {} in {}{}",
variant.node.ident,
variant.ident,
path_str(), id_str)
}
Some(Node::Field(ref field)) => {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ pub enum ExprKind {
Match(P<Expr>, HirVec<Arm>, MatchSource),
/// A closure (e.g., `move |a, b, c| {a + b + c}`).
///
/// The final span is the span of the argument block `|...|`.
/// The `Span` is the argument block `|...|`.
///
/// This may also be a generator literal or an `async block` as indicated by the
/// `Option<GeneratorMovability>`.
Expand Down Expand Up @@ -2193,7 +2193,7 @@ pub struct EnumDef {
}

#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct VariantKind {
pub struct Variant {
/// Name of the variant.
#[stable_hasher(project(name))]
pub ident: Ident,
Expand All @@ -2205,10 +2205,10 @@ pub struct VariantKind {
pub data: VariantData,
/// Explicit discriminant (e.g., `Foo = 1`).
pub disr_expr: Option<AnonConst>,
/// Span
pub span: Span
}

pub type Variant = Spanned<VariantKind>;

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum UseKind {
/// One import, e.g., `use foo::bar` or `use foo::bar as baz`.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ impl<'a> State<'a> {
for v in variants {
self.space_if_not_bol();
self.maybe_print_comment(v.span.lo());
self.print_outer_attributes(&v.node.attrs);
self.print_outer_attributes(&v.attrs);
self.ibox(INDENT_UNIT);
self.print_variant(v);
self.s.word(",");
Expand Down Expand Up @@ -829,8 +829,8 @@ impl<'a> State<'a> {
pub fn print_variant(&mut self, v: &hir::Variant) {
self.head("");
let generics = hir::Generics::empty();
self.print_struct(&v.node.data, &generics, v.node.ident.name, v.span, false);
if let Some(ref d) = v.node.disr_expr {
self.print_struct(&v.data, &generics, v.ident.name, v.span, false);
if let Some(ref d) = v.disr_expr {
self.s.space();
self.word_space("=");
self.print_anon_const(d);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
}
}

impl_stable_hash_for_spanned!(hir::VariantKind);
impl_stable_hash_for_spanned!(hir::Variant);


impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
Expand Down
Loading