Skip to content

Commit

Permalink
Auto merge of #72844 - Dylan-DPC:rollup-i51qv5z, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #72776 (fulfill: try using SmallVec or Box for stalled_on)
 - #72818 (Clean up E0622 explanation)
 - #72823 (Add descriptions for all queries)
 - #72832 (RELEASES.md: Expand `cargo tree` note to mention `cargo tree -d`)
 - #72834 (Rephrase term 'non-pointer type')

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jun 1, 2020
2 parents 0d93d3f + 16b4dc0 commit b85e3fe
Show file tree
Hide file tree
Showing 23 changed files with 278 additions and 184 deletions.
2 changes: 2 additions & 0 deletions RELEASES.md
Expand Up @@ -85,6 +85,8 @@ Cargo
│ │ │ └── version_check v0.1.5
...
```
You can also display dependencies on multiple versions of the same crate with
`cargo tree -d` (short for `cargo tree --duplicates`).

Misc
----
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/ops/deref.rs
Expand Up @@ -18,8 +18,8 @@
///
/// If `T` implements `Deref<Target = U>`, and `x` is a value of type `T`, then:
///
/// * In immutable contexts, `*x` on non-pointer types is equivalent to
/// `*Deref::deref(&x)`.
/// * In immutable contexts, `*x` (where `T` is neither a reference nor a raw pointer)
/// is equivalent to `*Deref::deref(&x)`.
/// * Values of type `&T` are coerced to values of type `&U`
/// * `T` implicitly implements all the (immutable) methods of the type `U`.
///
Expand Down Expand Up @@ -115,8 +115,8 @@ impl<T: ?Sized> Deref for &mut T {
/// If `T` implements `DerefMut<Target = U>`, and `x` is a value of type `T`,
/// then:
///
/// * In mutable contexts, `*x` on non-pointer types is equivalent to
/// `*DerefMut::deref_mut(&mut x)`.
/// * In mutable contexts, `*x` (where `T` is neither a reference nor a raw pointer)
/// is equivalent to `*DerefMut::deref_mut(&mut x)`.
/// * Values of type `&mut T` are coerced to values of type `&mut U`
/// * `T` implicitly implements all the (mutable) methods of the type `U`.
///
Expand Down
14 changes: 11 additions & 3 deletions src/librustc_error_codes/error_codes/E0622.md
Expand Up @@ -5,13 +5,21 @@ Erroneous code example:
```compile_fail,E0622
#![feature(intrinsics)]
extern "rust-intrinsic" {
pub static breakpoint : unsafe extern "rust-intrinsic" fn();
// error: intrinsic must be a function
pub static breakpoint : fn(); // error: intrinsic must be a function
}
fn main() { unsafe { breakpoint(); } }
```

An intrinsic is a function available for use in a given programming language
whose implementation is handled specially by the compiler. In order to fix this
error, just declare a function.
error, just declare a function. Example:

```no_run
#![feature(intrinsics)]
extern "rust-intrinsic" {
pub fn breakpoint(); // ok!
}
fn main() { unsafe { breakpoint(); } }
```
57 changes: 28 additions & 29 deletions src/librustc_macros/src/query.rs
Expand Up @@ -199,7 +199,7 @@ impl Parse for Group {

struct QueryModifiers {
/// The description of the query.
desc: Option<(Option<Ident>, Punctuated<Expr, Token![,]>)>,
desc: (Option<Ident>, Punctuated<Expr, Token![,]>),

/// Use this type for the in-memory cache.
storage: Option<Type>,
Expand Down Expand Up @@ -295,6 +295,9 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
}
}
}
let desc = desc.unwrap_or_else(|| {
panic!("no description provided for query `{}`", query.name);
});
QueryModifiers {
load_cached,
storage,
Expand All @@ -319,7 +322,7 @@ fn add_query_description_impl(
let key = &query.key.0;

// Find out if we should cache the query on disk
let cache = modifiers.cache.as_ref().map(|(args, expr)| {
let cache = if let Some((args, expr)) = modifiers.cache.as_ref() {
let try_load_from_disk = if let Some((tcx, id, block)) = modifiers.load_cached.as_ref() {
// Use custom code to load the query from disk
quote! {
Expand Down Expand Up @@ -373,36 +376,32 @@ fn add_query_description_impl(

#try_load_from_disk
}
});

if cache.is_none() && modifiers.load_cached.is_some() {
panic!("load_cached modifier on query `{}` without a cache modifier", name);
}
} else {
if modifiers.load_cached.is_some() {
panic!("load_cached modifier on query `{}` without a cache modifier", name);
}
quote! {}
};

let (tcx, desc) = modifiers.desc;
let tcx = tcx.as_ref().map(|t| quote! { #t }).unwrap_or(quote! { _ });

let desc = quote! {
#[allow(unused_variables)]
fn describe(
#tcx: TyCtxt<'tcx>,
#key: #arg,
) -> Cow<'static, str> {
format!(#desc).into()
}
};

let desc = modifiers.desc.as_ref().map(|(tcx, desc)| {
let tcx = tcx.as_ref().map(|t| quote! { #t }).unwrap_or(quote! { _ });
quote! {
#[allow(unused_variables)]
fn describe(
#tcx: TyCtxt<'tcx>,
#key: #arg,
) -> Cow<'static, str> {
format!(#desc).into()
}
impls.extend(quote! {
impl<'tcx> QueryDescription<TyCtxt<'tcx>> for queries::#name<'tcx> {
#desc
#cache
}
});

if desc.is_some() || cache.is_some() {
let cache = cache.unwrap_or(quote! {});
let desc = desc.unwrap_or(quote! {});

impls.extend(quote! {
impl<'tcx> QueryDescription<TyCtxt<'tcx>> for queries::#name<'tcx> {
#desc
#cache
}
});
}
}

pub fn rustc_queries(input: TokenStream) -> TokenStream {
Expand Down

0 comments on commit b85e3fe

Please sign in to comment.