Skip to content

Commit

Permalink
Remove some useless code.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoTestard committed Apr 21, 2016
1 parent 8b40531 commit 21bf716
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 37 deletions.
10 changes: 6 additions & 4 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {

ast::ExprKind::InPlace(placer, value_expr) => {
// Ensure feature-gate is enabled
feature_gate::check_for_placement_in(
fld.cx.ecfg.features,
&fld.cx.parse_sess.span_diagnostic,
expr_span);
if !fld.cx.ecfg.features.unwrap().placement_in_syntax {
feature_gate::emit_feature_err(
&fld.cx.parse_sess.span_diagnostic, "placement_in_syntax", expr_span,
feature_gate::GateIssue::Language, feature_gate::EXPLAIN_PLACEMENT_IN
);
}

let placer = fld.fold_expr(placer);
let value_expr = fld.fold_expr(value_expr);
Expand Down
42 changes: 9 additions & 33 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,39 +654,6 @@ impl GatedCfg {
}
}

const EXPLAIN_BOX_SYNTAX: &'static str =
"box expression syntax is experimental; you can call `Box::new` instead.";

const EXPLAIN_PLACEMENT_IN: &'static str =
"placement-in expression syntax is experimental and subject to change.";

const EXPLAIN_PUSHPOP_UNSAFE: &'static str =
"push/pop_unsafe macros are experimental and subject to change.";

const EXPLAIN_STMT_ATTR_SYNTAX: &'static str =
"attributes on non-item statements and expressions are experimental.";

pub fn check_for_box_syntax(f: Option<&Features>, diag: &Handler, span: Span) {
if let Some(&Features { box_syntax: true, .. }) = f {
return;
}
emit_feature_err(diag, "box_syntax", span, GateIssue::Language, EXPLAIN_BOX_SYNTAX);
}

pub fn check_for_placement_in(f: Option<&Features>, diag: &Handler, span: Span) {
if let Some(&Features { placement_in_syntax: true, .. }) = f {
return;
}
emit_feature_err(diag, "placement_in_syntax", span, GateIssue::Language, EXPLAIN_PLACEMENT_IN);
}

pub fn check_for_pushpop_syntax(f: Option<&Features>, diag: &Handler, span: Span) {
if let Some(&Features { pushpop_unsafe: true, .. }) = f {
return;
}
emit_feature_err(diag, "pushpop_unsafe", span, GateIssue::Language, EXPLAIN_PUSHPOP_UNSAFE);
}

struct Context<'a> {
features: &'a Features,
span_handler: &'a Handler,
Expand Down Expand Up @@ -809,6 +776,12 @@ pub fn emit_feature_err(diag: &Handler, feature: &str, span: Span, issue: GateIs
err.emit();
}

const EXPLAIN_BOX_SYNTAX: &'static str =
"box expression syntax is experimental; you can call `Box::new` instead.";

const EXPLAIN_STMT_ATTR_SYNTAX: &'static str =
"attributes on non-item statements and expressions are experimental.";

pub const EXPLAIN_ASM: &'static str =
"inline assembly is not stable enough for use and is subject to change";

Expand All @@ -829,6 +802,9 @@ pub const EXPLAIN_CUSTOM_DERIVE: &'static str =
pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str =
"attributes of the form `#[derive_*]` are reserved for the compiler";

pub const EXPLAIN_PLACEMENT_IN: &'static str =
"placement-in expression syntax is experimental and subject to change.";

struct PostExpansionVisitor<'a> {
context: &'a Context<'a>,
}
Expand Down

0 comments on commit 21bf716

Please sign in to comment.