Skip to content

Commit b85e3fe

Browse files
committed
Auto merge of #72844 - Dylan-DPC:rollup-i51qv5z, r=Dylan-DPC
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
2 parents 0d93d3f + 16b4dc0 commit b85e3fe

23 files changed

+278
-184
lines changed

RELEASES.md

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ Cargo
8585
│ │ │ └── version_check v0.1.5
8686
...
8787
```
88+
You can also display dependencies on multiple versions of the same crate with
89+
`cargo tree -d` (short for `cargo tree --duplicates`).
8890

8991
Misc
9092
----

src/libcore/ops/deref.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
///
1919
/// If `T` implements `Deref<Target = U>`, and `x` is a value of type `T`, then:
2020
///
21-
/// * In immutable contexts, `*x` on non-pointer types is equivalent to
22-
/// `*Deref::deref(&x)`.
21+
/// * In immutable contexts, `*x` (where `T` is neither a reference nor a raw pointer)
22+
/// is equivalent to `*Deref::deref(&x)`.
2323
/// * Values of type `&T` are coerced to values of type `&U`
2424
/// * `T` implicitly implements all the (immutable) methods of the type `U`.
2525
///
@@ -115,8 +115,8 @@ impl<T: ?Sized> Deref for &mut T {
115115
/// If `T` implements `DerefMut<Target = U>`, and `x` is a value of type `T`,
116116
/// then:
117117
///
118-
/// * In mutable contexts, `*x` on non-pointer types is equivalent to
119-
/// `*DerefMut::deref_mut(&mut x)`.
118+
/// * In mutable contexts, `*x` (where `T` is neither a reference nor a raw pointer)
119+
/// is equivalent to `*DerefMut::deref_mut(&mut x)`.
120120
/// * Values of type `&mut T` are coerced to values of type `&mut U`
121121
/// * `T` implicitly implements all the (mutable) methods of the type `U`.
122122
///

src/librustc_error_codes/error_codes/E0622.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ Erroneous code example:
55
```compile_fail,E0622
66
#![feature(intrinsics)]
77
extern "rust-intrinsic" {
8-
pub static breakpoint : unsafe extern "rust-intrinsic" fn();
9-
// error: intrinsic must be a function
8+
pub static breakpoint : fn(); // error: intrinsic must be a function
109
}
1110
1211
fn main() { unsafe { breakpoint(); } }
1312
```
1413

1514
An intrinsic is a function available for use in a given programming language
1615
whose implementation is handled specially by the compiler. In order to fix this
17-
error, just declare a function.
16+
error, just declare a function. Example:
17+
18+
```no_run
19+
#![feature(intrinsics)]
20+
extern "rust-intrinsic" {
21+
pub fn breakpoint(); // ok!
22+
}
23+
24+
fn main() { unsafe { breakpoint(); } }
25+
```

src/librustc_macros/src/query.rs

+28-29
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl Parse for Group {
199199

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

204204
/// Use this type for the in-memory cache.
205205
storage: Option<Type>,
@@ -295,6 +295,9 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
295295
}
296296
}
297297
}
298+
let desc = desc.unwrap_or_else(|| {
299+
panic!("no description provided for query `{}`", query.name);
300+
});
298301
QueryModifiers {
299302
load_cached,
300303
storage,
@@ -319,7 +322,7 @@ fn add_query_description_impl(
319322
let key = &query.key.0;
320323

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

374377
#try_load_from_disk
375378
}
376-
});
377-
378-
if cache.is_none() && modifiers.load_cached.is_some() {
379-
panic!("load_cached modifier on query `{}` without a cache modifier", name);
380-
}
379+
} else {
380+
if modifiers.load_cached.is_some() {
381+
panic!("load_cached modifier on query `{}` without a cache modifier", name);
382+
}
383+
quote! {}
384+
};
385+
386+
let (tcx, desc) = modifiers.desc;
387+
let tcx = tcx.as_ref().map(|t| quote! { #t }).unwrap_or(quote! { _ });
388+
389+
let desc = quote! {
390+
#[allow(unused_variables)]
391+
fn describe(
392+
#tcx: TyCtxt<'tcx>,
393+
#key: #arg,
394+
) -> Cow<'static, str> {
395+
format!(#desc).into()
396+
}
397+
};
381398

382-
let desc = modifiers.desc.as_ref().map(|(tcx, desc)| {
383-
let tcx = tcx.as_ref().map(|t| quote! { #t }).unwrap_or(quote! { _ });
384-
quote! {
385-
#[allow(unused_variables)]
386-
fn describe(
387-
#tcx: TyCtxt<'tcx>,
388-
#key: #arg,
389-
) -> Cow<'static, str> {
390-
format!(#desc).into()
391-
}
399+
impls.extend(quote! {
400+
impl<'tcx> QueryDescription<TyCtxt<'tcx>> for queries::#name<'tcx> {
401+
#desc
402+
#cache
392403
}
393404
});
394-
395-
if desc.is_some() || cache.is_some() {
396-
let cache = cache.unwrap_or(quote! {});
397-
let desc = desc.unwrap_or(quote! {});
398-
399-
impls.extend(quote! {
400-
impl<'tcx> QueryDescription<TyCtxt<'tcx>> for queries::#name<'tcx> {
401-
#desc
402-
#cache
403-
}
404-
});
405-
}
406405
}
407406

408407
pub fn rustc_queries(input: TokenStream) -> TokenStream {

0 commit comments

Comments
 (0)