Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_parse_format as parse;
use rustc_session::lint;
use rustc_span::{ErrorGuaranteed, InnerSpan, Span, Symbol, sym};
use rustc_target::asm::InlineAsmArch;
use smallvec::{SmallVec, smallvec};
use smallvec::smallvec;

use crate::errors;
use crate::util::{ExprToSpannedString, expr_to_spanned_string};
Expand All @@ -26,24 +26,6 @@ struct ValidatedAsmArgs {
pub options_spans: Vec<Span>,
}

struct MacGlobalAsm {
item: ast::Item,
}

impl MacResult for MacGlobalAsm {
fn make_items(self: Box<Self>) -> Option<SmallVec<[Box<ast::Item>; 1]>> {
Some(smallvec![Box::new(self.item)])
}

fn make_stmts(self: Box<Self>) -> Option<SmallVec<[ast::Stmt; 1]>> {
Some(smallvec![ast::Stmt {
id: ast::DUMMY_NODE_ID,
span: self.item.span,
kind: ast::StmtKind::Item(Box::new(self.item)),
}])
}
}

fn parse_args<'a>(
ecx: &ExtCtxt<'a>,
sp: Span,
Expand Down Expand Up @@ -668,20 +650,18 @@ pub(super) fn expand_global_asm<'cx>(
return ExpandResult::Retry(());
};
match mac {
Ok(inline_asm) => Box::new(MacGlobalAsm {
item: ast::Item {
attrs: ast::AttrVec::new(),
id: ast::DUMMY_NODE_ID,
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
vis: ast::Visibility {
span: sp.shrink_to_lo(),
kind: ast::VisibilityKind::Inherited,
tokens: None,
},
span: sp,
Ok(inline_asm) => MacEager::items(smallvec![Box::new(ast::Item {
attrs: ast::AttrVec::new(),
id: ast::DUMMY_NODE_ID,
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
vis: ast::Visibility {
span: sp.shrink_to_lo(),
kind: ast::VisibilityKind::Inherited,
tokens: None,
},
}),
span: sp,
tokens: None,
})]),
Err(guar) => DummyResult::any(sp, guar),
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
let annotation: Box<dyn pprust_ast::PpAnn> = match s {
Normal => Box::new(AstNoAnn),
Expanded => Box::new(AstNoAnn),
Identified => Box::new(AstIdentifiedAnn),
ExpandedIdentified => Box::new(AstIdentifiedAnn),
ExpandedHygiene => Box::new(AstHygieneAnn { sess }),
};
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2707,12 +2707,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Some(CtorKind::Const) => unreachable!("unit variants don't have fields"),
};

// Suggest constructor as deep into the block tree as possible.
// This fixes https://github.com/rust-lang/rust/issues/101065,
// and also just helps make the most minimal suggestions.
// Suggest constructor as deep into the block tree as possible,
// but don't cross macro contexts. This fixes #101065 while
// keeping suggestions out of macro definitions (#142359).
let mut expr = expr;
while let hir::ExprKind::Block(block, _) = &expr.kind
&& let Some(expr_) = &block.expr
&& expr_.span.eq_ctxt(expr.span)
{
expr = expr_
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub(crate) enum UnusedVariableSugg {
shorthands: Vec<Span>,
#[suggestion_part(code = "_")]
non_shorthands: Vec<Span>,
name: Symbol,
name: String,
},

#[multipart_suggestion(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {

let sugg = if any_shorthand {
errors::UnusedVariableSugg::TryIgnore {
name,
name: name.to_ident_string(),
shorthands: introductions
.iter()
.filter_map(
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2787,7 +2787,6 @@ fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> O

let first = match unstable_opts.unpretty.as_deref()? {
"normal" => Source(PpSourceMode::Normal),
"identified" => Source(PpSourceMode::Identified),
"expanded" => Source(PpSourceMode::Expanded),
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
Expand All @@ -2803,7 +2802,7 @@ fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> O
"stable-mir" => StableMir,
"mir-cfg" => MirCFG,
name => early_dcx.early_fatal(format!(
"argument to `unpretty` must be one of `normal`, `identified`, \
"argument to `unpretty` must be one of `normal`, \
`expanded`, `expanded,identified`, `expanded,hygiene`, \
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
Expand Down Expand Up @@ -2933,8 +2932,6 @@ pub enum PpSourceMode {
Normal,
/// `-Zunpretty=expanded`
Expanded,
/// `-Zunpretty=identified`
Identified,
/// `-Zunpretty=expanded,identified`
ExpandedIdentified,
/// `-Zunpretty=expanded,hygiene`
Expand Down Expand Up @@ -2982,7 +2979,7 @@ impl PpMode {
use PpMode::*;
use PpSourceMode::*;
match *self {
Source(Normal | Identified) | AstTree => false,
Source(Normal) | AstTree => false,

Source(Expanded | ExpandedIdentified | ExpandedHygiene)
| AstTreeExpanded
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2723,7 +2723,7 @@ written to standard error output)"),
"take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
"present the input source, unstable (and less-pretty) variants;
`normal`, `identified`,
`normal`,
`expanded`, `expanded,identified`,
`expanded,hygiene` (with internal representations),
`ast-tree` (raw AST before expansion),
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::directives::directive_names::{
pub(crate) use crate::directives::file::FileDirectives;
use crate::directives::handlers::DIRECTIVE_HANDLERS_MAP;
use crate::directives::line::DirectiveLine;
use crate::directives::needs::CachedNeedsConditions;
use crate::directives::needs::PreparedNeedsConditions;
use crate::edition::{Edition, parse_edition};
use crate::errors::ErrorKind;
use crate::executor::{CollectedTestDesc, ShouldFail};
Expand All @@ -40,14 +40,14 @@ pub(crate) struct DirectivesCache {
/// "Conditions" used by `ignore-*` and `only-*` directives, prepared in
/// advance so that they don't have to be evaluated repeatedly.
cfg_conditions: cfg::PreparedConditions,
needs: CachedNeedsConditions,
needs: PreparedNeedsConditions,
}

impl DirectivesCache {
pub(crate) fn load(config: &Config) -> Self {
Self {
cfg_conditions: cfg::prepare_conditions(config),
needs: CachedNeedsConditions::load(config),
needs: needs::prepare_needs_conditions(config),
}
}
}
Expand Down
Loading
Loading