Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #63575

Merged
merged 48 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3b229f1
check that ptr is valid already when doing Deref, not only when doing…
RalfJung Jul 27, 2019
5800bec
discourage use of ref_to_mplace
RalfJung Jul 28, 2019
3677c5b
the alignment checks on access can no longer fail now
RalfJung Jul 28, 2019
e4c39e1
better name for check_in_alloc
RalfJung Jul 28, 2019
388d99d
fix tests
RalfJung Jul 28, 2019
74fbdb6
move 'get me the access-checked version of an mplace' into separate f…
RalfJung Jul 28, 2019
647c0e0
'Ref' can now be sure it gets a 'Pointer'
RalfJung Jul 28, 2019
a4af9d1
parse_pat_with_range_pat: remove unnecessary assignments.
Centril Aug 12, 2019
90793c0
extract parse_pat_deref
Centril Aug 12, 2019
c69b3ed
extract parse_pat_tuple_or_parens
Centril Aug 12, 2019
3b65133
extract recover_pat_ident_mut_first
Centril Aug 12, 2019
231da7e
extract ban_pat_range_if_ambiguous
Centril Aug 12, 2019
e32bd69
extract parse_pat_mac_invoc
Centril Aug 12, 2019
e6f980f
extract parse_pat_range_starting_with_path
Centril Aug 12, 2019
49740b7
extract parse_pat_range_starting_with_lit
Centril Aug 12, 2019
37f37a5
parser/pat: minor misc cleanup
Centril Aug 12, 2019
ddf734d
extract fatal_unexpected_non_pat
Centril Aug 12, 2019
c8fc4c1
extract parse_pat_{tuple_}struct + recover_one_fewer_dotdot
Centril Aug 12, 2019
71415ef
Parse excess semicolons as empty stmts for linting
nathanwhit Jul 25, 2019
2f6cb5f
Add lint for excess trailing semicolons
nathanwhit Jul 30, 2019
76a1345
Update tests for excess semicolon lint
nathanwhit Jul 30, 2019
b8708e2
When needing type annotations in local bindings, account for impl Tra…
estebank Aug 12, 2019
3b6d46c
Resolve types when suggesting boxed closure
estebank Aug 13, 2019
1e6f753
Fix tidy
estebank Aug 13, 2019
fb2511c
Suggest `Box::new` when appropriate
estebank Aug 13, 2019
13fd466
Point at the right enclosing scope when using `await` in non-async fn
estebank Aug 13, 2019
376636e
syntax: Remove `DummyResult::expn_only`
petrochenkov Aug 13, 2019
939c1cb
review comments
estebank Aug 13, 2019
25d507f
review comment: move test
estebank Aug 13, 2019
0d29142
expand: `expand_fragment` -> `fully_expand_fragment`
petrochenkov Aug 13, 2019
d416ebe
expand: Unimplement `MutVisitor` on `MacroExpander`
petrochenkov Aug 13, 2019
806476c
Suggest giving return type to closures on E0282
estebank Aug 13, 2019
9348af8
Add NodeId for Arm, Field and FieldPat
c410-f3r Aug 14, 2019
264640c
move test that shouldn't be in test/run-pass/
Centril Aug 14, 2019
6a42b0b
Merge Variant and Variant_
c410-f3r Aug 14, 2019
24693d7
Adjust tracking issues for `MaybeUninit<T>` gates
Centril Aug 14, 2019
6c3a98e
review comments
estebank Aug 14, 2019
7178cf5
Rollup merge of #62984 - nathanwhit:extra_semi_lint, r=varkor
Centril Aug 14, 2019
c358476
Rollup merge of #63075 - RalfJung:deref-checks, r=oli-obk
Centril Aug 14, 2019
aaeff01
Rollup merge of #63490 - Centril:cleanup-pat-parser, r=petrochenkov
Centril Aug 14, 2019
d2d49d2
Rollup merge of #63507 - estebank:type-inference-error, r=Centril
Centril Aug 14, 2019
02e2a57
Rollup merge of #63509 - estebank:async-span, r=Centril
Centril Aug 14, 2019
409df9b
Rollup merge of #63528 - petrochenkov:anyany, r=estebank
Centril Aug 14, 2019
83cd4e3
Rollup merge of #63537 - petrochenkov:novisit, r=alexcrichton
Centril Aug 14, 2019
d4ecc6f
Rollup merge of #63542 - c410-f3r:node_ids, r=petrochenkov
Centril Aug 14, 2019
ad44d42
Rollup merge of #63543 - c410-f3r:variant, r=c410-f3r
Centril Aug 14, 2019
d11cf77
Rollup merge of #63560 - Centril:mv-generator-test, r=petrochenkov
Centril Aug 14, 2019
78cd9d1
Rollup merge of #63570 - rust-lang:maybe-uninit-gates, r=RalfJung
Centril Aug 14, 2019
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
39 changes: 6 additions & 33 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ impl MacResult for MacEager {
/// after hitting errors.
#[derive(Copy, Clone)]
pub struct DummyResult {
expr_only: bool,
is_error: bool,
span: Span,
}
Expand All @@ -416,21 +415,12 @@ impl DummyResult {
/// Use this as a return value after hitting any errors and
/// calling `span_err`.
pub fn any(span: Span) -> Box<dyn MacResult+'static> {
Box::new(DummyResult { expr_only: false, is_error: true, span })
Box::new(DummyResult { is_error: true, span })
}

/// Same as `any`, but must be a valid fragment, not error.
pub fn any_valid(span: Span) -> Box<dyn MacResult+'static> {
Box::new(DummyResult { expr_only: false, is_error: false, span })
}

/// Creates a default MacResult that can only be an expression.
///
/// Use this for macros that must expand to an expression, so even
/// if an error is encountered internally, the user will receive
/// an error that they also used it in the wrong place.
pub fn expr(span: Span) -> Box<dyn MacResult+'static> {
Box::new(DummyResult { expr_only: true, is_error: true, span })
Box::new(DummyResult { is_error: false, span })
}

/// A plain dummy expression.
Expand Down Expand Up @@ -472,36 +462,19 @@ impl MacResult for DummyResult {
}

fn make_items(self: Box<DummyResult>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
// this code needs a comment... why not always just return the Some() ?
if self.expr_only {
None
} else {
Some(SmallVec::new())
}
Some(SmallVec::new())
}

fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::ImplItem; 1]>> {
if self.expr_only {
None
} else {
Some(SmallVec::new())
}
Some(SmallVec::new())
}

fn make_trait_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::TraitItem; 1]>> {
if self.expr_only {
None
} else {
Some(SmallVec::new())
}
Some(SmallVec::new())
}

fn make_foreign_items(self: Box<Self>) -> Option<SmallVec<[ast::ForeignItem; 1]>> {
if self.expr_only {
None
} else {
Some(SmallVec::new())
}
Some(SmallVec::new())
}

fn make_stmts(self: Box<DummyResult>) -> Option<SmallVec<[ast::Stmt; 1]>> {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax_ext/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
-> Box<dyn base::MacResult + 'cx> {
let mut inline_asm = match parse_inline_asm(cx, sp, tts) {
Ok(Some(inline_asm)) => inline_asm,
Ok(None) => return DummyResult::expr(sp),
Ok(None) => return DummyResult::any(sp),
Err(mut err) => {
err.emit();
return DummyResult::expr(sp);
return DummyResult::any(sp);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn expand_assert<'cx>(
Ok(assert) => assert,
Err(mut err) => {
err.emit();
return DummyResult::expr(sp);
return DummyResult::any(sp);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn expand_cfg(
}
Err(mut err) => {
err.emit();
DummyResult::expr(sp)
DummyResult::any(sp)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax_ext/concat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use syntax::ast;
use syntax::ext::base;
use syntax::ext::base::{self, DummyResult};
use syntax::symbol::Symbol;
use syntax::tokenstream;

Expand All @@ -12,7 +12,7 @@ pub fn expand_syntax_ext(
) -> Box<dyn base::MacResult + 'static> {
let es = match base::get_exprs_from_tts(cx, sp, tts) {
Some(e) => e,
None => return base::DummyResult::expr(sp),
None => return DummyResult::any(sp),
};
let mut accumulator = String::new();
let mut missing_literal = vec![];
Expand Down Expand Up @@ -55,9 +55,9 @@ pub fn expand_syntax_ext(
let mut err = cx.struct_span_err(missing_literal, "expected a literal");
err.note("only literals (like `\"foo\"`, `42` and `3.14`) can be passed to `concat!()`");
err.emit();
return base::DummyResult::expr(sp);
return DummyResult::any(sp);
} else if has_errors {
return base::DummyResult::expr(sp);
return DummyResult::any(sp);
}
let sp = sp.apply_mark(cx.current_expansion.id);
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator)))
Expand Down
14 changes: 7 additions & 7 deletions src/libsyntax_ext/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>,
tts: &[tokenstream::TokenTree])
-> Box<dyn base::MacResult + 'cx> {
let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") {
None => return DummyResult::expr(sp),
None => return DummyResult::any(sp),
Some(v) => v,
};

Expand Down Expand Up @@ -50,35 +50,35 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt<'_>,
let mut exprs = match get_exprs_from_tts(cx, sp, tts) {
Some(ref exprs) if exprs.is_empty() => {
cx.span_err(sp, "env! takes 1 or 2 arguments");
return DummyResult::expr(sp);
return DummyResult::any(sp);
}
None => return DummyResult::expr(sp),
None => return DummyResult::any(sp),
Some(exprs) => exprs.into_iter(),
};

let var = match expr_to_string(cx, exprs.next().unwrap(), "expected string literal") {
None => return DummyResult::expr(sp),
None => return DummyResult::any(sp),
Some((v, _style)) => v,
};
let msg = match exprs.next() {
None => Symbol::intern(&format!("environment variable `{}` not defined", var)),
Some(second) => {
match expr_to_string(cx, second, "expected string literal") {
None => return DummyResult::expr(sp),
None => return DummyResult::any(sp),
Some((s, _style)) => s,
}
}
};

if exprs.next().is_some() {
cx.span_err(sp, "env! takes 1 or 2 arguments");
return DummyResult::expr(sp);
return DummyResult::any(sp);
}

let e = match env::var(&*var.as_str()) {
Err(_) => {
cx.span_err(sp, &msg.as_str());
return DummyResult::expr(sp);
return DummyResult::any(sp);
}
Ok(s) => cx.expr_str(sp, Symbol::intern(&s)),
};
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ fn expand_format_args_impl<'cx>(
}
Err(mut err) => {
err.emit();
DummyResult::expr(sp)
DummyResult::any(sp)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/libsyntax_ext/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::To
-> Box<dyn base::MacResult+'static> {
let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") {
Some(f) => f,
None => return DummyResult::expr(sp)
None => return DummyResult::any(sp)
};
let file = cx.resolve_path(file, sp);
match fs::read_to_string(&file) {
Expand All @@ -126,11 +126,11 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::To
},
Err(ref e) if e.kind() == ErrorKind::InvalidData => {
cx.span_err(sp, &format!("{} wasn't a utf-8 file", file.display()));
DummyResult::expr(sp)
DummyResult::any(sp)
}
Err(e) => {
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
DummyResult::expr(sp)
DummyResult::any(sp)
}
}
}
Expand All @@ -139,7 +139,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::
-> Box<dyn base::MacResult+'static> {
let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") {
Some(f) => f,
None => return DummyResult::expr(sp)
None => return DummyResult::any(sp)
};
let file = cx.resolve_path(file, sp);
match fs::read(&file) {
Expand All @@ -158,7 +158,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::
},
Err(e) => {
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
DummyResult::expr(sp)
DummyResult::any(sp)
}
}
}