Skip to content

Rollup of 8 pull requests #36759

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
172d321
Updated "Getting started". Trying to fix #34523
vanjacosic Sep 18, 2016
dc7ed30
Refactor out `parse_struct_expr`.
jseyfried Sep 22, 2016
a0e178d
Parse paths in statement and pattern macro invocations.
jseyfried Sep 22, 2016
6c08d03
Parse paths in item, trait item, and impl item macro invocations.
jseyfried Sep 22, 2016
167f70a
Fix fallout in tests.
jseyfried Sep 22, 2016
1e1804d
Cleanup.
jseyfried Sep 22, 2016
2c85733
Fix indents.
jseyfried Sep 22, 2016
e82d13e
rustdoc css: Put `where` in trait listings on a new line
bluss Sep 23, 2016
8b40ead
Refactor `parse_expansion` out of `ResultAnyMacro`.
jseyfried Sep 23, 2016
4a8467b
Remove `TokResult`.
jseyfried Sep 26, 2016
b90cedd
Refactor `ensure_complete_parse`.
jseyfried Sep 23, 2016
34f4ad1
Add regression test.
jseyfried Sep 26, 2016
51ea050
reject macros with empty repetitions
TimNN Sep 25, 2016
df0e4bf
Move `ensure_complete_parse` into `expand.rs`.
jseyfried Sep 26, 2016
e6e117c
Extend preprocessor LLVM version checks to support LLVM 4.x
shepmaster Sep 24, 2016
09a63c1
Add E0513 error explanation
GuillaumeGomez Sep 25, 2016
1e4e81c
Add compile-fail test for E0513
GuillaumeGomez Sep 25, 2016
96a0f06
Update E0513 to new error format
GuillaumeGomez Sep 25, 2016
0bd7ef0
Remove whitespace from line endings
vanjacosic Sep 26, 2016
157208b
New error format for E0512
alygin Sep 26, 2016
6573053
Rollup merge of #36563 - vanjacosic:patch-1, r=steveklabnik
Sep 26, 2016
f685380
Rollup merge of #36662 - jseyfried:parse_macro_invoc_paths, r=nrc
Sep 26, 2016
ae77889
Rollup merge of #36669 - jseyfried:refactor_tok_result, r=nrc
Sep 26, 2016
1ec306e
Rollup merge of #36676 - bluss:rustdoc-where-css, r=steveklabnik
Sep 26, 2016
c4fc532
Rollup merge of #36721 - TimNN:infinite-emptiness, r=nrc
Sep 26, 2016
5f84df6
Rollup merge of #36723 - GuillaumeGomez:e0513, r=jonathandturner
Sep 26, 2016
b04b23b
Rollup merge of #36742 - shepmaster:llvm-4-preamble, r=alexcrichton
Sep 26, 2016
cd3b3e8
Rollup merge of #36756 - alygin:e0512-new-format, r=jonathandturner
Sep 26, 2016
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
11 changes: 6 additions & 5 deletions src/doc/book/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,13 @@ $ cd hello_world

## Writing and Running a Rust Program

Next, make a new source file and call it *main.rs*. Rust files always end
in a *.rs* extension. If you’re using more than one word in your filename, use
an underscore to separate them; for example, you'd use *hello_world.rs* rather
than *helloworld.rs*.
We need to create a source file for our Rust program. Rust files always end
in a *.rs* extension. If you are using more than one word in your filename,
use an underscore to separate them; for example, you would use
*my_program.rs* rather than *myprogram.rs*.

Now open the *main.rs* file you just created, and type the following code:
Now, make a new file and call it *main.rs*. Open the file and type
the following code:

```rust
fn main() {
Expand Down
9 changes: 7 additions & 2 deletions src/librustc/middle/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
}
};

span_err!(self.infcx.tcx.sess, span, E0512,
struct_span_err!(self.infcx.tcx.sess, span, E0512,
"transmute called with differently sized types: \
{} ({}) to {} ({})",
from, skeleton_string(from, sk_from),
to, skeleton_string(to, sk_to));
to, skeleton_string(to, sk_to))
.span_label(span,
&format!("transmuting between {} and {}",
skeleton_string(from, sk_from),
skeleton_string(to, sk_to)))
.emit();
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
match self.locals.borrow().get(&nid) {
Some(&t) => t,
None => {
span_err!(self.tcx.sess, span, E0513,
"no type for local variable {}",
nid);
struct_span_err!(self.tcx.sess, span, E0513,
"no type for local variable {}",
self.tcx.map.node_to_string(nid))
.span_label(span, &"no type for variable")
.emit();
self.tcx.types.err
}
}
Expand Down
40 changes: 39 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,45 @@ extern "platform-intrinsic" {
```
"##,

E0513: r##"
The type of the variable couldn't be found out.

Erroneous code example:

```compile_fail,E0513
use std::mem;

unsafe {
let size = mem::size_of::<u32>();
mem::transmute_copy::<u32, [u8; size]>(&8_8);
// error: no type for local variable
}
```

To fix this error, please use a constant size instead of `size`. To make
this error more obvious, you could run:

```compile_fail,E0080
use std::mem;

unsafe {
mem::transmute_copy::<u32, [u8; mem::size_of::<u32>()]>(&8_8);
// error: constant evaluation error
}
```

So now, you can fix your code by setting the size directly:

```
use std::mem;

unsafe {
mem::transmute_copy::<u32, [u8; 4]>(&8_8);
// `u32` is 4 bytes so we replace the `mem::size_of` call with its size
}
```
"##,

E0516: r##"
The `typeof` keyword is currently reserved but unimplemented.
Erroneous code example:
Expand Down Expand Up @@ -4064,7 +4103,6 @@ register_diagnostics! {
E0399, // trait items need to be implemented because the associated
// type `{}` was overridden
E0436, // functional record update requires a struct
E0513, // no type for local variable ..
E0521, // redundant default implementations of trait
E0533, // `{}` does not name a unit variant, unit struct or a constant
E0562, // `impl Trait` not allowed outside of function
Expand Down
5 changes: 5 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ h4 > code, h3 > code, .invisible > code {
font-size: 90%;
}

/* Shift where in trait listing down a line */
pre.trait .where::before {
content: '\a ';
}

nav {
border-bottom: 1px solid;
padding-bottom: 10px;
Expand Down
143 changes: 1 addition & 142 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ use errors::DiagnosticBuilder;
use ext::expand::{self, Invocation, Expansion};
use ext::hygiene::Mark;
use fold::{self, Folder};
use parse;
use parse::parser::{self, Parser};
use parse::{self, parser};
use parse::token;
use parse::token::{InternedString, str_to_ident};
use ptr::P;
Expand Down Expand Up @@ -188,146 +187,6 @@ impl<F> AttrProcMacro for F
}
}

pub struct TokResult<'a> {
pub parser: Parser<'a>,
pub span: Span,
}

impl<'a> TokResult<'a> {
// There is quite a lot of overlap here with ParserAnyMacro in ext/tt/macro_rules.rs
// We could probably share more code.
// FIXME(#36641) Unify TokResult and ParserAnyMacro.
fn ensure_complete_parse(&mut self, allow_semi: bool) {
let macro_span = &self.span;
self.parser.ensure_complete_parse(allow_semi, |parser| {
let token_str = parser.this_token_to_string();
let msg = format!("macro expansion ignores token `{}` and any following", token_str);
let span = parser.span;
parser.diagnostic()
.struct_span_err(span, &msg)
.span_note(*macro_span, "caused by the macro expansion here")
.emit();
});
}
}

impl<'a> MacResult for TokResult<'a> {
fn make_items(mut self: Box<Self>) -> Option<SmallVector<P<ast::Item>>> {
if self.parser.sess.span_diagnostic.has_errors() {
return Some(SmallVector::zero());
}

let mut items = SmallVector::zero();
loop {
match self.parser.parse_item() {
Ok(Some(item)) => items.push(item),
Ok(None) => {
self.ensure_complete_parse(false);
return Some(items);
}
Err(mut e) => {
e.emit();
return Some(SmallVector::zero());
}
}
}
}

fn make_impl_items(mut self: Box<Self>) -> Option<SmallVector<ast::ImplItem>> {
let mut items = SmallVector::zero();
loop {
if self.parser.token == token::Eof {
break;
}
match self.parser.parse_impl_item() {
Ok(item) => items.push(item),
Err(mut e) => {
e.emit();
return Some(SmallVector::zero());
}
}
}
self.ensure_complete_parse(false);
Some(items)
}

fn make_trait_items(mut self: Box<Self>) -> Option<SmallVector<ast::TraitItem>> {
let mut items = SmallVector::zero();
loop {
if self.parser.token == token::Eof {
break;
}
match self.parser.parse_trait_item() {
Ok(item) => items.push(item),
Err(mut e) => {
e.emit();
return Some(SmallVector::zero());
}
}
}
self.ensure_complete_parse(false);
Some(items)
}

fn make_expr(mut self: Box<Self>) -> Option<P<ast::Expr>> {
match self.parser.parse_expr() {
Ok(e) => {
self.ensure_complete_parse(true);
Some(e)
}
Err(mut e) => {
e.emit();
Some(DummyResult::raw_expr(self.span))
}
}
}

fn make_pat(mut self: Box<Self>) -> Option<P<ast::Pat>> {
match self.parser.parse_pat() {
Ok(e) => {
self.ensure_complete_parse(false);
Some(e)
}
Err(mut e) => {
e.emit();
Some(P(DummyResult::raw_pat(self.span)))
}
}
}

fn make_stmts(mut self: Box<Self>) -> Option<SmallVector<ast::Stmt>> {
let mut stmts = SmallVector::zero();
loop {
if self.parser.token == token::Eof {
break;
}
match self.parser.parse_full_stmt(false) {
Ok(Some(stmt)) => stmts.push(stmt),
Ok(None) => { /* continue */ }
Err(mut e) => {
e.emit();
return Some(SmallVector::zero());
}
}
}
self.ensure_complete_parse(false);
Some(stmts)
}

fn make_ty(mut self: Box<Self>) -> Option<P<ast::Ty>> {
match self.parser.parse_ty() {
Ok(e) => {
self.ensure_complete_parse(false);
Some(e)
}
Err(mut e) => {
e.emit();
Some(DummyResult::raw_ty(self.span))
}
}
}
}

/// Represents a thing that maps token trees to Macro Results
pub trait TTMacroExpander {
fn expand<'cx>(&self,
Expand Down
Loading