Skip to content

Rollup of 5 pull requests #72844

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 10 commits into from
Jun 1, 2020
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading