Skip to content

Commit a3ed564

Browse files
committed
Auto merge of #81660 - jonas-schievink:rollup-fz2lh78, r=jonas-schievink
Rollup of 11 pull requests Successful merges: - #80629 (Add lint for 2229 migrations) - #81022 (Add Frames Iterator for Backtrace) - #81481 (move some tests) - #81485 (Add some tests for associated-type-bounds issues) - #81492 (rustdoc: Note why `rustdoc::html::markdown` is public) - #81577 (const_evaluatable: consider sub-expressions to be evaluatable) - #81599 (Implement `TrustedLen` for `Fuse<I: TrustedLen>`) - #81608 (Improve handling of spans around macro result parse errors) - #81609 (Remove the remains of query categories) - #81630 (Fix overflowing text on mobile when sidebar is displayed) - #81631 (Remove unneeded `mut` variable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f6cb45a + 73f859e commit a3ed564

File tree

42 files changed

+2480
-1633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2480
-1633
lines changed

compiler/rustc_expand/src/expand.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
896896
fragment
897897
}
898898
Err(mut err) => {
899-
err.set_span(span);
899+
if err.span.is_dummy() {
900+
err.set_span(span);
901+
}
900902
annotate_err_with_kind(&mut err, kind, span);
901903
err.emit();
902904
self.cx.trace_macros_diag();

compiler/rustc_lint_defs/src/builtin.rs

+46
Original file line numberDiff line numberDiff line change
@@ -2968,6 +2968,7 @@ declare_lint_pass! {
29682968
UNSUPPORTED_NAKED_FUNCTIONS,
29692969
MISSING_ABI,
29702970
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2971+
DISJOINT_CAPTURE_DROP_REORDER,
29712972
]
29722973
}
29732974

@@ -2994,6 +2995,51 @@ declare_lint! {
29942995
"detects doc comments that aren't used by rustdoc"
29952996
}
29962997

2998+
declare_lint! {
2999+
/// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely
3000+
/// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop
3001+
/// order of at least one path starting at this variable.
3002+
///
3003+
/// ### Example
3004+
///
3005+
/// ```rust,compile_fail
3006+
/// # #![deny(disjoint_capture_drop_reorder)]
3007+
/// # #![allow(unused)]
3008+
/// struct FancyInteger(i32);
3009+
///
3010+
/// impl Drop for FancyInteger {
3011+
/// fn drop(&mut self) {
3012+
/// println!("Just dropped {}", self.0);
3013+
/// }
3014+
/// }
3015+
///
3016+
/// struct Point { x: FancyInteger, y: FancyInteger }
3017+
///
3018+
/// fn main() {
3019+
/// let p = Point { x: FancyInteger(10), y: FancyInteger(20) };
3020+
///
3021+
/// let c = || {
3022+
/// let x = p.x;
3023+
/// };
3024+
///
3025+
/// c();
3026+
///
3027+
/// // ... More code ...
3028+
/// }
3029+
/// ```
3030+
///
3031+
/// {{produces}}
3032+
///
3033+
/// ### Explanation
3034+
///
3035+
/// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if
3036+
/// the feature `capture_disjoint_fields` is enabled.
3037+
pub DISJOINT_CAPTURE_DROP_REORDER,
3038+
Allow,
3039+
"Drop reorder because of `capture_disjoint_fields`"
3040+
3041+
}
3042+
29973043
declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
29983044

29993045
declare_lint! {

compiler/rustc_macros/src/query.rs

+52-73
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,6 @@ impl<T: Parse> Parse for List<T> {
189189
}
190190
}
191191

192-
/// A named group containing queries.
193-
///
194-
/// For now, the name is not used any more, but the capability remains interesting for future
195-
/// developments of the query system.
196-
struct Group {
197-
#[allow(unused)]
198-
name: Ident,
199-
queries: List<Query>,
200-
}
201-
202-
impl Parse for Group {
203-
fn parse(input: ParseStream<'_>) -> Result<Self> {
204-
let name: Ident = input.parse()?;
205-
let content;
206-
braced!(content in input);
207-
Ok(Group { name, queries: content.parse()? })
208-
}
209-
}
210-
211192
struct QueryModifiers {
212193
/// The description of the query.
213194
desc: (Option<Ident>, Punctuated<Expr, Token![,]>),
@@ -450,72 +431,70 @@ fn add_query_description_impl(
450431
}
451432

452433
pub fn rustc_queries(input: TokenStream) -> TokenStream {
453-
let groups = parse_macro_input!(input as List<Group>);
434+
let queries = parse_macro_input!(input as List<Query>);
454435

455436
let mut query_stream = quote! {};
456437
let mut query_description_stream = quote! {};
457438
let mut dep_node_def_stream = quote! {};
458439
let mut cached_queries = quote! {};
459440

460-
for group in groups.0 {
461-
for mut query in group.queries.0 {
462-
let modifiers = process_modifiers(&mut query);
463-
let name = &query.name;
464-
let arg = &query.arg;
465-
let result_full = &query.result;
466-
let result = match query.result {
467-
ReturnType::Default => quote! { -> () },
468-
_ => quote! { #result_full },
469-
};
441+
for mut query in queries.0 {
442+
let modifiers = process_modifiers(&mut query);
443+
let name = &query.name;
444+
let arg = &query.arg;
445+
let result_full = &query.result;
446+
let result = match query.result {
447+
ReturnType::Default => quote! { -> () },
448+
_ => quote! { #result_full },
449+
};
470450

471-
if modifiers.cache.is_some() {
472-
cached_queries.extend(quote! {
473-
#name,
474-
});
475-
}
451+
if modifiers.cache.is_some() {
452+
cached_queries.extend(quote! {
453+
#name,
454+
});
455+
}
476456

477-
let mut attributes = Vec::new();
457+
let mut attributes = Vec::new();
478458

479-
// Pass on the fatal_cycle modifier
480-
if modifiers.fatal_cycle {
481-
attributes.push(quote! { fatal_cycle });
482-
};
483-
// Pass on the storage modifier
484-
if let Some(ref ty) = modifiers.storage {
485-
attributes.push(quote! { storage(#ty) });
486-
};
487-
// Pass on the cycle_delay_bug modifier
488-
if modifiers.cycle_delay_bug {
489-
attributes.push(quote! { cycle_delay_bug });
490-
};
491-
// Pass on the no_hash modifier
492-
if modifiers.no_hash {
493-
attributes.push(quote! { no_hash });
494-
};
495-
// Pass on the anon modifier
496-
if modifiers.anon {
497-
attributes.push(quote! { anon });
498-
};
499-
// Pass on the eval_always modifier
500-
if modifiers.eval_always {
501-
attributes.push(quote! { eval_always });
502-
};
459+
// Pass on the fatal_cycle modifier
460+
if modifiers.fatal_cycle {
461+
attributes.push(quote! { fatal_cycle });
462+
};
463+
// Pass on the storage modifier
464+
if let Some(ref ty) = modifiers.storage {
465+
attributes.push(quote! { storage(#ty) });
466+
};
467+
// Pass on the cycle_delay_bug modifier
468+
if modifiers.cycle_delay_bug {
469+
attributes.push(quote! { cycle_delay_bug });
470+
};
471+
// Pass on the no_hash modifier
472+
if modifiers.no_hash {
473+
attributes.push(quote! { no_hash });
474+
};
475+
// Pass on the anon modifier
476+
if modifiers.anon {
477+
attributes.push(quote! { anon });
478+
};
479+
// Pass on the eval_always modifier
480+
if modifiers.eval_always {
481+
attributes.push(quote! { eval_always });
482+
};
503483

504-
let attribute_stream = quote! {#(#attributes),*};
505-
let doc_comments = query.doc_comments.iter();
506-
// Add the query to the group
507-
query_stream.extend(quote! {
508-
#(#doc_comments)*
509-
[#attribute_stream] fn #name(#arg) #result,
510-
});
484+
let attribute_stream = quote! {#(#attributes),*};
485+
let doc_comments = query.doc_comments.iter();
486+
// Add the query to the group
487+
query_stream.extend(quote! {
488+
#(#doc_comments)*
489+
[#attribute_stream] fn #name(#arg) #result,
490+
});
511491

512-
// Create a dep node for the query
513-
dep_node_def_stream.extend(quote! {
514-
[#attribute_stream] #name(#arg),
515-
});
492+
// Create a dep node for the query
493+
dep_node_def_stream.extend(quote! {
494+
[#attribute_stream] #name(#arg),
495+
});
516496

517-
add_query_description_impl(&query, modifiers, &mut query_description_stream);
518-
}
497+
add_query_description_impl(&query, modifiers, &mut query_description_stream);
519498
}
520499

521500
TokenStream::from(quote! {

0 commit comments

Comments
 (0)