Skip to content

Commit 423e3d2

Browse files
committed
Auto merge of #156893 - JonathanBrouwer:rollup-KrnXZ2W, r=JonathanBrouwer
Rollup of 5 pull requests Successful merges: - #142611 (Do not suggest compatible variants inside macro) - #156692 (compiletest: Prepare all simple `//@ needs-*` conditions in advance) - #156847 (Fix suggestion of unused variables with raw identifier in struct pattern) - #156876 (Remove useless -Zunpretty=identified option) - #156884 (Revert "Allow `global_asm!` in statement positions")
2 parents 609b8c5 + 5de5cc7 commit 423e3d2

20 files changed

Lines changed: 371 additions & 377 deletions

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_parse_format as parse;
1010
use rustc_session::lint;
1111
use rustc_span::{ErrorGuaranteed, InnerSpan, Span, Symbol, sym};
1212
use rustc_target::asm::InlineAsmArch;
13-
use smallvec::{SmallVec, smallvec};
13+
use smallvec::smallvec;
1414

1515
use crate::errors;
1616
use crate::util::{ExprToSpannedString, expr_to_spanned_string};
@@ -26,24 +26,6 @@ struct ValidatedAsmArgs {
2626
pub options_spans: Vec<Span>,
2727
}
2828

29-
struct MacGlobalAsm {
30-
item: ast::Item,
31-
}
32-
33-
impl MacResult for MacGlobalAsm {
34-
fn make_items(self: Box<Self>) -> Option<SmallVec<[Box<ast::Item>; 1]>> {
35-
Some(smallvec![Box::new(self.item)])
36-
}
37-
38-
fn make_stmts(self: Box<Self>) -> Option<SmallVec<[ast::Stmt; 1]>> {
39-
Some(smallvec![ast::Stmt {
40-
id: ast::DUMMY_NODE_ID,
41-
span: self.item.span,
42-
kind: ast::StmtKind::Item(Box::new(self.item)),
43-
}])
44-
}
45-
}
46-
4729
fn parse_args<'a>(
4830
ecx: &ExtCtxt<'a>,
4931
sp: Span,
@@ -668,20 +650,18 @@ pub(super) fn expand_global_asm<'cx>(
668650
return ExpandResult::Retry(());
669651
};
670652
match mac {
671-
Ok(inline_asm) => Box::new(MacGlobalAsm {
672-
item: ast::Item {
673-
attrs: ast::AttrVec::new(),
674-
id: ast::DUMMY_NODE_ID,
675-
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
676-
vis: ast::Visibility {
677-
span: sp.shrink_to_lo(),
678-
kind: ast::VisibilityKind::Inherited,
679-
tokens: None,
680-
},
681-
span: sp,
653+
Ok(inline_asm) => MacEager::items(smallvec![Box::new(ast::Item {
654+
attrs: ast::AttrVec::new(),
655+
id: ast::DUMMY_NODE_ID,
656+
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
657+
vis: ast::Visibility {
658+
span: sp.shrink_to_lo(),
659+
kind: ast::VisibilityKind::Inherited,
682660
tokens: None,
683661
},
684-
}),
662+
span: sp,
663+
tokens: None,
664+
})]),
685665
Err(guar) => DummyResult::any(sp, guar),
686666
}
687667
}

compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
239239
let annotation: Box<dyn pprust_ast::PpAnn> = match s {
240240
Normal => Box::new(AstNoAnn),
241241
Expanded => Box::new(AstNoAnn),
242-
Identified => Box::new(AstIdentifiedAnn),
243242
ExpandedIdentified => Box::new(AstIdentifiedAnn),
244243
ExpandedHygiene => Box::new(AstHygieneAnn { sess }),
245244
};

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,12 +2707,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27072707
Some(CtorKind::Const) => unreachable!("unit variants don't have fields"),
27082708
};
27092709

2710-
// Suggest constructor as deep into the block tree as possible.
2711-
// This fixes https://github.com/rust-lang/rust/issues/101065,
2712-
// and also just helps make the most minimal suggestions.
2710+
// Suggest constructor as deep into the block tree as possible,
2711+
// but don't cross macro contexts. This fixes #101065 while
2712+
// keeping suggestions out of macro definitions (#142359).
27132713
let mut expr = expr;
27142714
while let hir::ExprKind::Block(block, _) = &expr.kind
27152715
&& let Some(expr_) = &block.expr
2716+
&& expr_.span.eq_ctxt(expr.span)
27162717
{
27172718
expr = expr_
27182719
}

compiler/rustc_mir_transform/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub(crate) enum UnusedVariableSugg {
249249
shorthands: Vec<Span>,
250250
#[suggestion_part(code = "_")]
251251
non_shorthands: Vec<Span>,
252-
name: Symbol,
252+
name: String,
253253
},
254254

255255
#[multipart_suggestion(

compiler/rustc_mir_transform/src/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
10681068

10691069
let sugg = if any_shorthand {
10701070
errors::UnusedVariableSugg::TryIgnore {
1071-
name,
1071+
name: name.to_ident_string(),
10721072
shorthands: introductions
10731073
.iter()
10741074
.filter_map(

compiler/rustc_session/src/config.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,6 @@ fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> O
27872787

27882788
let first = match unstable_opts.unpretty.as_deref()? {
27892789
"normal" => Source(PpSourceMode::Normal),
2790-
"identified" => Source(PpSourceMode::Identified),
27912790
"expanded" => Source(PpSourceMode::Expanded),
27922791
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
27932792
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
@@ -2803,7 +2802,7 @@ fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> O
28032802
"stable-mir" => StableMir,
28042803
"mir-cfg" => MirCFG,
28052804
name => early_dcx.early_fatal(format!(
2806-
"argument to `unpretty` must be one of `normal`, `identified`, \
2805+
"argument to `unpretty` must be one of `normal`, \
28072806
`expanded`, `expanded,identified`, `expanded,hygiene`, \
28082807
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
28092808
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
@@ -2933,8 +2932,6 @@ pub enum PpSourceMode {
29332932
Normal,
29342933
/// `-Zunpretty=expanded`
29352934
Expanded,
2936-
/// `-Zunpretty=identified`
2937-
Identified,
29382935
/// `-Zunpretty=expanded,identified`
29392936
ExpandedIdentified,
29402937
/// `-Zunpretty=expanded,hygiene`
@@ -2982,7 +2979,7 @@ impl PpMode {
29822979
use PpMode::*;
29832980
use PpSourceMode::*;
29842981
match *self {
2985-
Source(Normal | Identified) | AstTree => false,
2982+
Source(Normal) | AstTree => false,
29862983

29872984
Source(Expanded | ExpandedIdentified | ExpandedHygiene)
29882985
| AstTreeExpanded

compiler/rustc_session/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ written to standard error output)"),
27232723
"take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
27242724
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
27252725
"present the input source, unstable (and less-pretty) variants;
2726-
`normal`, `identified`,
2726+
`normal`,
27272727
`expanded`, `expanded,identified`,
27282728
`expanded,hygiene` (with internal representations),
27292729
`ast-tree` (raw AST before expansion),

src/tools/compiletest/src/directives.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::directives::directive_names::{
1616
pub(crate) use crate::directives::file::FileDirectives;
1717
use crate::directives::handlers::DIRECTIVE_HANDLERS_MAP;
1818
use crate::directives::line::DirectiveLine;
19-
use crate::directives::needs::CachedNeedsConditions;
19+
use crate::directives::needs::PreparedNeedsConditions;
2020
use crate::edition::{Edition, parse_edition};
2121
use crate::errors::ErrorKind;
2222
use crate::executor::{CollectedTestDesc, ShouldFail};
@@ -40,14 +40,14 @@ pub(crate) struct DirectivesCache {
4040
/// "Conditions" used by `ignore-*` and `only-*` directives, prepared in
4141
/// advance so that they don't have to be evaluated repeatedly.
4242
cfg_conditions: cfg::PreparedConditions,
43-
needs: CachedNeedsConditions,
43+
needs: PreparedNeedsConditions,
4444
}
4545

4646
impl DirectivesCache {
4747
pub(crate) fn load(config: &Config) -> Self {
4848
Self {
4949
cfg_conditions: cfg::prepare_conditions(config),
50-
needs: CachedNeedsConditions::load(config),
50+
needs: needs::prepare_needs_conditions(config),
5151
}
5252
}
5353
}

0 commit comments

Comments
 (0)