Skip to content

Rollup of 6 pull requests #60898

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 23 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
08cd34e
Switch to SPDX 2.1 license expression
dtolnay May 9, 2019
7c55b48
Fix .natvis visualizers.
MaulingMonkey May 9, 2019
01bc58c
remove compiletest's dependency on `filetime`
euclio May 13, 2019
6d207f5
Get ty from local_decls instead of using Place
spastorino May 15, 2019
d763faf
Parse alternative incorrect uses of await and recover
estebank May 16, 2019
ee02661
Split parser logic to its own method
estebank May 16, 2019
01c6689
Simplify span usage for incorrect await
estebank May 16, 2019
91c36c4
tidy fix
estebank May 16, 2019
c616605
Point at enclosing fn/closure when it's not async
estebank May 16, 2019
0183a57
readd match await test case
estebank May 16, 2019
b9d6fe3
Review comments
estebank May 16, 2019
27a2881
Fix span for await macro call
estebank May 16, 2019
4117c6d
Move some parser recovery methods to diagnostics
estebank May 16, 2019
5f93834
Add entry-like methods to HashSet
cuviper May 16, 2019
c084d0e
review comments
estebank May 16, 2019
5e2c9d3
Add a hash_set_entry tracking issue
cuviper May 16, 2019
9161a4d
Comment why get_or_insert returns &T
cuviper May 16, 2019
5972408
Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakis
Centril May 17, 2019
a925973
Rollup merge of #60687 - MaulingMonkey:pr-fix-natvis-files, r=alexcri…
Centril May 17, 2019
23d91e2
Rollup merge of #60805 - euclio:filetime-dep, r=Mark-Simulacrum
Centril May 17, 2019
71cd93a
Rollup merge of #60862 - spastorino:get-ty-from-local_decls, r=oli-obk
Centril May 17, 2019
70b38d1
Rollup merge of #60873 - estebank:bad-await, r=Centril
Centril May 17, 2019
a80a1d0
Rollup merge of #60894 - cuviper:hash_set_entry, r=cramertj,Centril
Centril May 17, 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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ version = "0.0.0"
dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
12 changes: 6 additions & 6 deletions src/etc/natvis/liballoc.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
<ArrayItems>
<Size>len</Size>
<ValuePointer>buf.ptr.pointer.__0</ValuePointer>
<ValuePointer>buf.ptr.pointer</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="alloc::vec_deque::VecDeque&lt;*&gt;">
<Type Name="alloc::collections::vec_deque::VecDeque&lt;*&gt;">
<DisplayString>{{ size={tail &lt;= head ? head - tail : buf.cap - tail + head} }}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">tail &lt;= head ? head - tail : buf.cap - tail + head</Item>
Expand All @@ -24,19 +24,19 @@
<If Condition="i == head">
<Break/>
</If>
<Item>buf.ptr.pointer.__0 + i</Item>
<Item>buf.ptr.pointer[i]</Item>
<Exec>i = (i + 1 == buf.cap ? 0 : i + 1)</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
<Type Name="alloc::linked_list::LinkedList&lt;*&gt;">
<Type Name="alloc::collections::linked_list::LinkedList&lt;*&gt;">
<DisplayString>{{ size={len} }}</DisplayString>
<Expand>
<LinkedListItems>
<Size>len</Size>
<HeadPointer>*(alloc::linked_list::Node&lt;$T1&gt; **)&amp;head</HeadPointer>
<NextPointer>*(alloc::linked_list::Node&lt;$T1&gt; **)&amp;next</NextPointer>
<HeadPointer>*(alloc::collections::linked_list::Node&lt;$T1&gt; **)&amp;head</HeadPointer>
<NextPointer>*(alloc::collections::linked_list::Node&lt;$T1&gt; **)&amp;next</NextPointer>
<ValueNode>element</ValueNode>
</LinkedListItems>
</Expand>
Expand Down
8 changes: 4 additions & 4 deletions src/etc/natvis/libcore.natvis
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="core::ptr::Unique&lt;*&gt;">
<DisplayString>{{ Unique {*pointer.__0} }}</DisplayString>
<DisplayString>{{ Unique {pointer} }}</DisplayString>
<Expand>
<Item Name="[ptr]">pointer.__0</Item>
<Item Name="[ptr]">pointer</Item>
</Expand>
</Type>
<Type Name="core::ptr::Shared&lt;*&gt;">
<DisplayString>{{ Shared {*pointer.__0} }}</DisplayString>
<DisplayString>{{ Shared {pointer} }}</DisplayString>
<Expand>
<Item Name="[ptr]">pointer.__0</Item>
<Item Name="[ptr]">pointer</Item>
</Expand>
</Type>
<Type Name="core::option::Option&lt;*&gt;">
Expand Down
17 changes: 15 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub struct LoweringContext<'a> {
is_generator: bool,
is_async_body: bool,

/// Used to get the current `fn`'s def span to point to when using `await`
/// outside of an `async fn`.
current_item: Option<Span>,

catch_scopes: Vec<NodeId>,
loop_scopes: Vec<NodeId>,
is_in_loop_condition: bool,
Expand Down Expand Up @@ -250,6 +254,7 @@ pub fn lower_crate(
node_id_to_hir_id: IndexVec::new(),
is_generator: false,
is_async_body: false,
current_item: None,
is_in_trait_impl: false,
lifetimes_to_define: Vec::new(),
is_collecting_in_band_lifetimes: false,
Expand Down Expand Up @@ -3116,6 +3121,7 @@ impl<'a> LoweringContext<'a> {
ItemKind::Fn(ref decl, ref header, ref generics, ref body) => {
let fn_def_id = self.resolver.definitions().local_def_id(id);
self.with_new_scopes(|this| {
this.current_item = Some(ident.span);
let mut lower_fn = |decl: &FnDecl| {
// Note: we don't need to change the return type from `T` to
// `impl Future<Output = T>` here because lower_body
Expand Down Expand Up @@ -3654,6 +3660,7 @@ impl<'a> LoweringContext<'a> {
} else {
lower_method(sig)
};
self.current_item = Some(i.span);

(generics, hir::ImplItemKind::Method(sig, body_id))
}
Expand Down Expand Up @@ -4270,6 +4277,7 @@ impl<'a> LoweringContext<'a> {
let fn_decl = self.lower_fn_decl(decl, None, false, None);

self.with_new_scopes(|this| {
this.current_item = Some(fn_decl_span);
let mut is_generator = false;
let body_id = this.lower_body(Some(decl), |this| {
let e = this.lower_expr(body);
Expand Down Expand Up @@ -5551,13 +5559,18 @@ impl<'a> LoweringContext<'a> {
// }
// }
if !self.is_async_body {
span_err!(
let mut err = struct_span_err!(
self.sess,
await_span,
E0728,
"`await` is only allowed inside `async` functions and blocks"
);
self.sess.abort_if_errors();
err.span_label(await_span, "only allowed inside `async` functions and blocks");
if let Some(item_sp) = self.current_item {
err.span_label(item_sp, "this is not `async`");
}
err.emit();
return hir::ExprKind::Err;
}
let span = self.sess.source_map().mark_span_with_reason(
CompilerDesugaringKind::Await,
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_codegen_ssa/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
}

PlaceContext::MutatingUse(MutatingUseContext::Drop) => {
let ty = mir::Place::Base(mir::PlaceBase::Local(local)).ty(self.fx.mir,
self.fx.cx.tcx());
let ty = self.fx.monomorphize(&ty.ty);
let ty = self.fx.mir.local_decls[local].ty;
let ty = self.fx.monomorphize(&ty);

// Only need the place if we're actually dropping it.
if self.fx.cx.type_needs_drop(ty) {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["The Rust Project Developers"]
name = "std"
version = "0.0.0"
build = "build.rs"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "The Rust Standard Library"
edition = "2018"
Expand Down
56 changes: 56 additions & 0 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,62 @@ impl<T, S> HashSet<T, S>
self.map.get_key_value(value).map(|(k, _)| k)
}

/// Inserts the given `value` into the set if it is not present, then
/// returns a reference to the value in the set.
///
/// # Examples
///
/// ```
/// #![feature(hash_set_entry)]
///
/// use std::collections::HashSet;
///
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// assert_eq!(set.len(), 3);
/// assert_eq!(set.get_or_insert(2), &2);
/// assert_eq!(set.get_or_insert(100), &100);
/// assert_eq!(set.len(), 4); // 100 was inserted
/// ```
#[inline]
#[unstable(feature = "hash_set_entry", issue = "60896")]
pub fn get_or_insert(&mut self, value: T) -> &T {
// Although the raw entry gives us `&mut T`, we only return `&T` to be consistent with
// `get`. Key mutation is "raw" because you're not supposed to affect `Eq` or `Hash`.
self.map.raw_entry_mut().from_key(&value).or_insert(value, ()).0
}

/// Inserts a value computed from `f` into the set if the given `value` is
/// not present, then returns a reference to the value in the set.
///
/// # Examples
///
/// ```
/// #![feature(hash_set_entry)]
///
/// use std::collections::HashSet;
///
/// let mut set: HashSet<String> = ["cat", "dog", "horse"]
/// .iter().map(|&pet| pet.to_owned()).collect();
///
/// assert_eq!(set.len(), 3);
/// for &pet in &["cat", "dog", "fish"] {
/// let value = set.get_or_insert_with(pet, str::to_owned);
/// assert_eq!(value, pet);
/// }
/// assert_eq!(set.len(), 4); // a new "fish" was inserted
/// ```
#[inline]
#[unstable(feature = "hash_set_entry", issue = "60896")]
pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T
where T: Borrow<Q>,
Q: Hash + Eq,
F: FnOnce(&Q) -> T
{
// Although the raw entry gives us `&mut T`, we only return `&T` to be consistent with
// `get`. Key mutation is "raw" because you're not supposed to affect `Eq` or `Hash`.
self.map.raw_entry_mut().from_key(value).or_insert_with(|| (f(value), ())).0
}

/// Returns `true` if `self` has no elements in common with `other`.
/// This is equivalent to checking for an empty intersection.
///
Expand Down
Loading