Merge branch 'master' into pep8-bootstrap
This commit is contained in:
commit
23a5fb811e
|
@ -193,7 +193,7 @@ Snapshot binaries are currently built and tested on several platforms:
|
||||||
You may find that other platforms work, but these are our officially
|
You may find that other platforms work, but these are our officially
|
||||||
supported build environments that are most likely to work.
|
supported build environments that are most likely to work.
|
||||||
|
|
||||||
Rust currently needs between 600MiB and 1.5GiB to build, depending on platform.
|
Rust currently needs between 600MiB and 1.5GiB of RAM to build, depending on platform.
|
||||||
If it hits swap, it will take a very long time to build.
|
If it hits swap, it will take a very long time to build.
|
||||||
|
|
||||||
There is more advice about hacking on Rust in [CONTRIBUTING.md].
|
There is more advice about hacking on Rust in [CONTRIBUTING.md].
|
||||||
|
|
|
@ -39,7 +39,7 @@ The script accepts commands, flags, and arguments to determine what to do:
|
||||||
```
|
```
|
||||||
|
|
||||||
If files are dirty that would normally be rebuilt from stage 0, that can be
|
If files are dirty that would normally be rebuilt from stage 0, that can be
|
||||||
overidden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps
|
overridden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps
|
||||||
that belong to stage n or earlier:
|
that belong to stage n or earlier:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -31,8 +31,6 @@ extern crate bootstrap;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::io;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{Command, ExitStatus};
|
use std::process::{Command, ExitStatus};
|
||||||
|
@ -270,7 +268,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if verbose > 1 {
|
if verbose > 1 {
|
||||||
writeln!(&mut io::stderr(), "rustc command: {:?}", cmd).unwrap();
|
eprintln!("rustc command: {:?}", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually run the compiler!
|
// Actually run the compiler!
|
||||||
|
|
|
@ -499,7 +499,7 @@ class RustBuild(object):
|
||||||
|
|
||||||
If the key does not exists, the result is None:
|
If the key does not exists, the result is None:
|
||||||
|
|
||||||
>>> rb.get_toml("key3") == None
|
>>> rb.get_toml("key3") is None
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
for line in self.config_toml.splitlines():
|
for line in self.config_toml.splitlines():
|
||||||
|
|
|
@ -358,7 +358,7 @@ for target in configured_targets:
|
||||||
|
|
||||||
|
|
||||||
# Here we walk through the constructed configuration we have from the parsed
|
# Here we walk through the constructed configuration we have from the parsed
|
||||||
# command line arguemnts. We then apply each piece of configuration by
|
# command line arguments. We then apply each piece of configuration by
|
||||||
# basically just doing a `sed` to change the various configuration line to what
|
# basically just doing a `sed` to change the various configuration line to what
|
||||||
# we've got configure.
|
# we've got configure.
|
||||||
def to_toml(value):
|
def to_toml(value):
|
||||||
|
@ -372,7 +372,7 @@ def to_toml(value):
|
||||||
elif isinstance(value, str):
|
elif isinstance(value, str):
|
||||||
return "'" + value + "'"
|
return "'" + value + "'"
|
||||||
else:
|
else:
|
||||||
raise 'no toml'
|
raise RuntimeError('no toml')
|
||||||
|
|
||||||
|
|
||||||
def configure_section(lines, config):
|
def configure_section(lines, config):
|
||||||
|
@ -392,9 +392,9 @@ def configure_section(lines, config):
|
||||||
for section_key in config:
|
for section_key in config:
|
||||||
section_config = config[section_key]
|
section_config = config[section_key]
|
||||||
if section_key not in sections:
|
if section_key not in sections:
|
||||||
raise RuntimeError("config key {} not in sections".format(key))
|
raise RuntimeError("config key {} not in sections".format(section_key))
|
||||||
|
|
||||||
if section_key == 'target':
|
if __key == 'target':
|
||||||
for target in section_config:
|
for target in section_config:
|
||||||
configure_section(targets[target], section_config[target])
|
configure_section(targets[target], section_config[target])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -31,7 +31,7 @@ download_sysimage() {
|
||||||
# Keep printing yes to accept the licenses
|
# Keep printing yes to accept the licenses
|
||||||
while true; do echo yes; sleep 10; done | \
|
while true; do echo yes; sleep 10; done | \
|
||||||
/android/sdk/tools/android update sdk -a --no-ui \
|
/android/sdk/tools/android update sdk -a --no-ui \
|
||||||
--filter "$filter"
|
--filter "$filter" --no-https
|
||||||
}
|
}
|
||||||
|
|
||||||
create_avd() {
|
create_avd() {
|
||||||
|
|
|
@ -81,7 +81,7 @@ def execute_command(command_interpreter, command):
|
||||||
|
|
||||||
if res.Succeeded():
|
if res.Succeeded():
|
||||||
if res.HasResult():
|
if res.HasResult():
|
||||||
print(normalize_whitespace(res.GetOutput()), end='\n')
|
print(normalize_whitespace(res.GetOutput() or ''), end='\n')
|
||||||
|
|
||||||
# If the command introduced any breakpoints, make sure to register
|
# If the command introduced any breakpoints, make sure to register
|
||||||
# them with the breakpoint
|
# them with the breakpoint
|
||||||
|
|
|
@ -85,16 +85,23 @@ ident [a-zA-Z\x80-\xff_][a-zA-Z0-9\x80-\xff_]*
|
||||||
<blockcomment>(.|\n) { }
|
<blockcomment>(.|\n) { }
|
||||||
|
|
||||||
_ { return UNDERSCORE; }
|
_ { return UNDERSCORE; }
|
||||||
|
abstract { return ABSTRACT; }
|
||||||
|
alignof { return ALIGNOF; }
|
||||||
as { return AS; }
|
as { return AS; }
|
||||||
|
become { return BECOME; }
|
||||||
box { return BOX; }
|
box { return BOX; }
|
||||||
break { return BREAK; }
|
break { return BREAK; }
|
||||||
|
catch { return CATCH; }
|
||||||
const { return CONST; }
|
const { return CONST; }
|
||||||
continue { return CONTINUE; }
|
continue { return CONTINUE; }
|
||||||
crate { return CRATE; }
|
crate { return CRATE; }
|
||||||
|
default { return DEFAULT; }
|
||||||
|
do { return DO; }
|
||||||
else { return ELSE; }
|
else { return ELSE; }
|
||||||
enum { return ENUM; }
|
enum { return ENUM; }
|
||||||
extern { return EXTERN; }
|
extern { return EXTERN; }
|
||||||
false { return FALSE; }
|
false { return FALSE; }
|
||||||
|
final { return FINAL; }
|
||||||
fn { return FN; }
|
fn { return FN; }
|
||||||
for { return FOR; }
|
for { return FOR; }
|
||||||
if { return IF; }
|
if { return IF; }
|
||||||
|
@ -102,26 +109,36 @@ impl { return IMPL; }
|
||||||
in { return IN; }
|
in { return IN; }
|
||||||
let { return LET; }
|
let { return LET; }
|
||||||
loop { return LOOP; }
|
loop { return LOOP; }
|
||||||
|
macro { return MACRO; }
|
||||||
match { return MATCH; }
|
match { return MATCH; }
|
||||||
mod { return MOD; }
|
mod { return MOD; }
|
||||||
move { return MOVE; }
|
move { return MOVE; }
|
||||||
mut { return MUT; }
|
mut { return MUT; }
|
||||||
|
offsetof { return OFFSETOF; }
|
||||||
|
override { return OVERRIDE; }
|
||||||
priv { return PRIV; }
|
priv { return PRIV; }
|
||||||
proc { return PROC; }
|
proc { return PROC; }
|
||||||
|
pure { return PURE; }
|
||||||
pub { return PUB; }
|
pub { return PUB; }
|
||||||
ref { return REF; }
|
ref { return REF; }
|
||||||
return { return RETURN; }
|
return { return RETURN; }
|
||||||
self { return SELF; }
|
self { return SELF; }
|
||||||
|
sizeof { return SIZEOF; }
|
||||||
static { return STATIC; }
|
static { return STATIC; }
|
||||||
struct { return STRUCT; }
|
struct { return STRUCT; }
|
||||||
|
super { return SUPER; }
|
||||||
trait { return TRAIT; }
|
trait { return TRAIT; }
|
||||||
true { return TRUE; }
|
true { return TRUE; }
|
||||||
type { return TYPE; }
|
type { return TYPE; }
|
||||||
typeof { return TYPEOF; }
|
typeof { return TYPEOF; }
|
||||||
|
union { return UNION; }
|
||||||
unsafe { return UNSAFE; }
|
unsafe { return UNSAFE; }
|
||||||
|
unsized { return UNSIZED; }
|
||||||
use { return USE; }
|
use { return USE; }
|
||||||
|
virtual { return VIRTUAL; }
|
||||||
where { return WHERE; }
|
where { return WHERE; }
|
||||||
while { return WHILE; }
|
while { return WHILE; }
|
||||||
|
yield { return YIELD; }
|
||||||
|
|
||||||
{ident} { return IDENT; }
|
{ident} { return IDENT; }
|
||||||
|
|
||||||
|
@ -194,7 +211,7 @@ while { return WHILE; }
|
||||||
<ltorchar>{ident} { BEGIN(INITIAL); return LIFETIME; }
|
<ltorchar>{ident} { BEGIN(INITIAL); return LIFETIME; }
|
||||||
<ltorchar>\\[nrt\\\x27\x220]\x27 { BEGIN(suffix); return LIT_CHAR; }
|
<ltorchar>\\[nrt\\\x27\x220]\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||||
<ltorchar>\\x[0-9a-fA-F]{2}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
<ltorchar>\\x[0-9a-fA-F]{2}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||||
<ltorchar>\\u\{[0-9a-fA-F]?{6}\}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
<ltorchar>\\u\{([0-9a-fA-F]_*){1,6}\}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||||
<ltorchar>.\x27 { BEGIN(suffix); return LIT_CHAR; }
|
<ltorchar>.\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||||
<ltorchar>[\x80-\xff]{2,4}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
<ltorchar>[\x80-\xff]{2,4}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||||
<ltorchar><<EOF>> { BEGIN(INITIAL); return -1; }
|
<ltorchar><<EOF>> { BEGIN(INITIAL); return -1; }
|
||||||
|
@ -205,7 +222,7 @@ b\x22 { BEGIN(bytestr); yymore(); }
|
||||||
<bytestr><<EOF>> { return -1; }
|
<bytestr><<EOF>> { return -1; }
|
||||||
<bytestr>\\[n\nrt\\\x27\x220] { yymore(); }
|
<bytestr>\\[n\nrt\\\x27\x220] { yymore(); }
|
||||||
<bytestr>\\x[0-9a-fA-F]{2} { yymore(); }
|
<bytestr>\\x[0-9a-fA-F]{2} { yymore(); }
|
||||||
<bytestr>\\u\{[0-9a-fA-F]?{6}\} { yymore(); }
|
<bytestr>\\u\{([0-9a-fA-F]_*){1,6}\} { yymore(); }
|
||||||
<bytestr>\\[^n\nrt\\\x27\x220] { return -1; }
|
<bytestr>\\[^n\nrt\\\x27\x220] { return -1; }
|
||||||
<bytestr>(.|\n) { yymore(); }
|
<bytestr>(.|\n) { yymore(); }
|
||||||
|
|
||||||
|
@ -255,8 +272,8 @@ br/# {
|
||||||
b\x27 { BEGIN(byte); yymore(); }
|
b\x27 { BEGIN(byte); yymore(); }
|
||||||
<byte>\\[nrt\\\x27\x220]\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
<byte>\\[nrt\\\x27\x220]\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||||
<byte>\\x[0-9a-fA-F]{2}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
<byte>\\x[0-9a-fA-F]{2}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||||
<byte>\\u[0-9a-fA-F]{4}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
<byte>\\u([0-9a-fA-F]_*){4}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||||
<byte>\\U[0-9a-fA-F]{8}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
<byte>\\U([0-9a-fA-F]_*){8}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||||
<byte>.\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
<byte>.\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||||
<byte><<EOF>> { BEGIN(INITIAL); return -1; }
|
<byte><<EOF>> { BEGIN(INITIAL); return -1; }
|
||||||
|
|
||||||
|
@ -313,7 +330,7 @@ r/# {
|
||||||
<str><<EOF>> { return -1; }
|
<str><<EOF>> { return -1; }
|
||||||
<str>\\[n\nr\rt\\\x27\x220] { yymore(); }
|
<str>\\[n\nr\rt\\\x27\x220] { yymore(); }
|
||||||
<str>\\x[0-9a-fA-F]{2} { yymore(); }
|
<str>\\x[0-9a-fA-F]{2} { yymore(); }
|
||||||
<str>\\u\{[0-9a-fA-F]?{6}\} { yymore(); }
|
<str>\\u\{([0-9a-fA-F]_*){1,6}\} { yymore(); }
|
||||||
<str>\\[^n\nrt\\\x27\x220] { return -1; }
|
<str>\\[^n\nrt\\\x27\x220] { return -1; }
|
||||||
<str>(.|\n) { yymore(); }
|
<str>(.|\n) { yymore(); }
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,19 @@ extern char *yytext;
|
||||||
// keywords
|
// keywords
|
||||||
%token SELF
|
%token SELF
|
||||||
%token STATIC
|
%token STATIC
|
||||||
|
%token ABSTRACT
|
||||||
|
%token ALIGNOF
|
||||||
%token AS
|
%token AS
|
||||||
|
%token BECOME
|
||||||
%token BREAK
|
%token BREAK
|
||||||
|
%token CATCH
|
||||||
%token CRATE
|
%token CRATE
|
||||||
|
%token DO
|
||||||
%token ELSE
|
%token ELSE
|
||||||
%token ENUM
|
%token ENUM
|
||||||
%token EXTERN
|
%token EXTERN
|
||||||
%token FALSE
|
%token FALSE
|
||||||
|
%token FINAL
|
||||||
%token FN
|
%token FN
|
||||||
%token FOR
|
%token FOR
|
||||||
%token IF
|
%token IF
|
||||||
|
@ -76,19 +82,29 @@ extern char *yytext;
|
||||||
%token IN
|
%token IN
|
||||||
%token LET
|
%token LET
|
||||||
%token LOOP
|
%token LOOP
|
||||||
|
%token MACRO
|
||||||
%token MATCH
|
%token MATCH
|
||||||
%token MOD
|
%token MOD
|
||||||
%token MOVE
|
%token MOVE
|
||||||
%token MUT
|
%token MUT
|
||||||
|
%token OFFSETOF
|
||||||
|
%token OVERRIDE
|
||||||
%token PRIV
|
%token PRIV
|
||||||
%token PUB
|
%token PUB
|
||||||
|
%token PURE
|
||||||
%token REF
|
%token REF
|
||||||
%token RETURN
|
%token RETURN
|
||||||
|
%token SIZEOF
|
||||||
%token STRUCT
|
%token STRUCT
|
||||||
|
%token SUPER
|
||||||
|
%token UNION
|
||||||
|
%token UNSIZED
|
||||||
%token TRUE
|
%token TRUE
|
||||||
%token TRAIT
|
%token TRAIT
|
||||||
%token TYPE
|
%token TYPE
|
||||||
%token UNSAFE
|
%token UNSAFE
|
||||||
|
%token VIRTUAL
|
||||||
|
%token YIELD
|
||||||
%token DEFAULT
|
%token DEFAULT
|
||||||
%token USE
|
%token USE
|
||||||
%token WHILE
|
%token WHILE
|
||||||
|
@ -141,6 +157,10 @@ extern char *yytext;
|
||||||
// 'foo:bar . <' is shifted (in a trait reference occurring in a
|
// 'foo:bar . <' is shifted (in a trait reference occurring in a
|
||||||
// bounds list), parsing as foo:(bar<baz>) rather than (foo:bar)<baz>.
|
// bounds list), parsing as foo:(bar<baz>) rather than (foo:bar)<baz>.
|
||||||
%precedence IDENT
|
%precedence IDENT
|
||||||
|
// Put the weak keywords that can be used as idents here as well
|
||||||
|
%precedence CATCH
|
||||||
|
%precedence DEFAULT
|
||||||
|
%precedence UNION
|
||||||
|
|
||||||
// A couple fake-precedence symbols to use in rules associated with +
|
// A couple fake-precedence symbols to use in rules associated with +
|
||||||
// and < in trailing type contexts. These come up when you have a type
|
// and < in trailing type contexts. These come up when you have a type
|
||||||
|
@ -161,13 +181,13 @@ extern char *yytext;
|
||||||
%precedence FOR
|
%precedence FOR
|
||||||
|
|
||||||
// Binops & unops, and their precedences
|
// Binops & unops, and their precedences
|
||||||
|
%precedence '?'
|
||||||
%precedence BOX
|
%precedence BOX
|
||||||
%precedence BOXPLACE
|
|
||||||
%nonassoc DOTDOT
|
%nonassoc DOTDOT
|
||||||
|
|
||||||
// RETURN needs to be lower-precedence than tokens that start
|
// RETURN needs to be lower-precedence than tokens that start
|
||||||
// prefix_exprs
|
// prefix_exprs
|
||||||
%precedence RETURN
|
%precedence RETURN YIELD
|
||||||
|
|
||||||
%right '=' SHLEQ SHREQ MINUSEQ ANDEQ OREQ PLUSEQ STAREQ SLASHEQ CARETEQ PERCENTEQ
|
%right '=' SHLEQ SHREQ MINUSEQ ANDEQ OREQ PLUSEQ STAREQ SLASHEQ CARETEQ PERCENTEQ
|
||||||
%right LARROW
|
%right LARROW
|
||||||
|
@ -321,6 +341,8 @@ view_path
|
||||||
| path_no_types_allowed MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
|
| path_no_types_allowed MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
|
||||||
| MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $3); }
|
| MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $3); }
|
||||||
| path_no_types_allowed MOD_SEP '*' { $$ = mk_node("ViewPathGlob", 1, $1); }
|
| path_no_types_allowed MOD_SEP '*' { $$ = mk_node("ViewPathGlob", 1, $1); }
|
||||||
|
| MOD_SEP '*' { $$ = mk_atom("ViewPathGlob"); }
|
||||||
|
| '*' { $$ = mk_atom("ViewPathGlob"); }
|
||||||
| '{' '}' { $$ = mk_atom("ViewPathListEmpty"); }
|
| '{' '}' { $$ = mk_atom("ViewPathListEmpty"); }
|
||||||
| '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $2); }
|
| '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $2); }
|
||||||
| '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $2); }
|
| '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $2); }
|
||||||
|
@ -334,6 +356,7 @@ block_item
|
||||||
| item_foreign_mod { $$ = mk_node("ItemForeignMod", 1, $1); }
|
| item_foreign_mod { $$ = mk_node("ItemForeignMod", 1, $1); }
|
||||||
| item_struct
|
| item_struct
|
||||||
| item_enum
|
| item_enum
|
||||||
|
| item_union
|
||||||
| item_trait
|
| item_trait
|
||||||
| item_impl
|
| item_impl
|
||||||
;
|
;
|
||||||
|
@ -387,6 +410,7 @@ struct_decl_field
|
||||||
struct_tuple_fields
|
struct_tuple_fields
|
||||||
: struct_tuple_field { $$ = mk_node("StructFields", 1, $1); }
|
: struct_tuple_field { $$ = mk_node("StructFields", 1, $1); }
|
||||||
| struct_tuple_fields ',' struct_tuple_field { $$ = ext_node($1, 1, $3); }
|
| struct_tuple_fields ',' struct_tuple_field { $$ = ext_node($1, 1, $3); }
|
||||||
|
| %empty { $$ = mk_none(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
struct_tuple_field
|
struct_tuple_field
|
||||||
|
@ -417,6 +441,11 @@ enum_args
|
||||||
| %empty { $$ = mk_none(); }
|
| %empty { $$ = mk_none(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// unions
|
||||||
|
item_union
|
||||||
|
: UNION ident generic_params maybe_where_clause '{' struct_decl_fields '}' { $$ = mk_node("ItemUnion", 0); }
|
||||||
|
| UNION ident generic_params maybe_where_clause '{' struct_decl_fields ',' '}' { $$ = mk_node("ItemUnion", 0); }
|
||||||
|
|
||||||
item_mod
|
item_mod
|
||||||
: MOD ident ';' { $$ = mk_node("ItemMod", 1, $2); }
|
: MOD ident ';' { $$ = mk_node("ItemMod", 1, $2); }
|
||||||
| MOD ident '{' maybe_mod_items '}' { $$ = mk_node("ItemMod", 2, $2, $4); }
|
| MOD ident '{' maybe_mod_items '}' { $$ = mk_node("ItemMod", 2, $2, $4); }
|
||||||
|
@ -475,7 +504,7 @@ visibility
|
||||||
|
|
||||||
idents_or_self
|
idents_or_self
|
||||||
: ident_or_self { $$ = mk_node("IdentsOrSelf", 1, $1); }
|
: ident_or_self { $$ = mk_node("IdentsOrSelf", 1, $1); }
|
||||||
| ident_or_self AS ident { $$ = mk_node("IdentsOrSelf", 2, $1, $3); }
|
| idents_or_self AS ident { $$ = mk_node("IdentsOrSelf", 2, $1, $3); }
|
||||||
| idents_or_self ',' ident_or_self { $$ = ext_node($1, 1, $3); }
|
| idents_or_self ',' ident_or_self { $$ = ext_node($1, 1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -515,6 +544,7 @@ trait_item
|
||||||
: trait_const
|
: trait_const
|
||||||
| trait_type
|
| trait_type
|
||||||
| trait_method
|
| trait_method
|
||||||
|
| maybe_outer_attrs item_macro { $$ = mk_node("TraitMacroItem", 2, $1, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
trait_const
|
trait_const
|
||||||
|
@ -547,36 +577,48 @@ trait_method
|
||||||
;
|
;
|
||||||
|
|
||||||
type_method
|
type_method
|
||||||
: attrs_and_vis maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
|
: maybe_outer_attrs maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
|
||||||
{
|
{
|
||||||
$$ = mk_node("TypeMethod", 6, $1, $2, $4, $5, $6, $7);
|
$$ = mk_node("TypeMethod", 6, $1, $2, $4, $5, $6, $7);
|
||||||
}
|
}
|
||||||
| attrs_and_vis maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
|
| maybe_outer_attrs CONST maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
|
||||||
|
{
|
||||||
|
$$ = mk_node("TypeMethod", 6, $1, $3, $5, $6, $7, $8);
|
||||||
|
}
|
||||||
|
| maybe_outer_attrs maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
|
||||||
{
|
{
|
||||||
$$ = mk_node("TypeMethod", 7, $1, $2, $4, $6, $7, $8, $9);
|
$$ = mk_node("TypeMethod", 7, $1, $2, $4, $6, $7, $8, $9);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
method
|
method
|
||||||
: attrs_and_vis maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
|
: maybe_outer_attrs maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
|
||||||
{
|
{
|
||||||
$$ = mk_node("Method", 7, $1, $2, $4, $5, $6, $7, $8);
|
$$ = mk_node("Method", 7, $1, $2, $4, $5, $6, $7, $8);
|
||||||
}
|
}
|
||||||
| attrs_and_vis maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
|
| maybe_outer_attrs CONST maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
|
||||||
|
{
|
||||||
|
$$ = mk_node("Method", 7, $1, $3, $5, $6, $7, $8, $9);
|
||||||
|
}
|
||||||
|
| maybe_outer_attrs maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
|
||||||
{
|
{
|
||||||
$$ = mk_node("Method", 8, $1, $2, $4, $6, $7, $8, $9, $10);
|
$$ = mk_node("Method", 8, $1, $2, $4, $6, $7, $8, $9, $10);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
impl_method
|
impl_method
|
||||||
: attrs_and_vis maybe_unsafe FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
|
: attrs_and_vis maybe_default maybe_unsafe FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
|
||||||
{
|
{
|
||||||
$$ = mk_node("Method", 7, $1, $2, $4, $5, $6, $7, $8);
|
$$ = mk_node("Method", 8, $1, $2, $3, $5, $6, $7, $8, $9);
|
||||||
}
|
}
|
||||||
| attrs_and_vis maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
|
| attrs_and_vis maybe_default CONST maybe_unsafe FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
|
||||||
{
|
{
|
||||||
$$ = mk_node("Method", 8, $1, $2, $4, $6, $7, $8, $9, $10);
|
$$ = mk_node("Method", 8, $1, $2, $4, $6, $7, $8, $9, $10);
|
||||||
}
|
}
|
||||||
|
| attrs_and_vis maybe_default maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
|
||||||
|
{
|
||||||
|
$$ = mk_node("Method", 9, $1, $2, $3, $5, $7, $8, $9, $10, $11);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
// There are two forms of impl:
|
// There are two forms of impl:
|
||||||
|
@ -638,12 +680,17 @@ impl_item
|
||||||
| impl_type
|
| impl_type
|
||||||
;
|
;
|
||||||
|
|
||||||
|
maybe_default
|
||||||
|
: DEFAULT { $$ = mk_atom("Default"); }
|
||||||
|
| %empty { $$ = mk_none(); }
|
||||||
|
;
|
||||||
|
|
||||||
impl_const
|
impl_const
|
||||||
: attrs_and_vis item_const { $$ = mk_node("ImplConst", 1, $1, $2); }
|
: attrs_and_vis maybe_default item_const { $$ = mk_node("ImplConst", 3, $1, $2, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
impl_type
|
impl_type
|
||||||
: attrs_and_vis TYPE ident generic_params '=' ty_sum ';' { $$ = mk_node("ImplType", 4, $1, $3, $4, $6); }
|
: attrs_and_vis maybe_default TYPE ident generic_params '=' ty_sum ';' { $$ = mk_node("ImplType", 5, $1, $2, $4, $5, $7); }
|
||||||
;
|
;
|
||||||
|
|
||||||
item_fn
|
item_fn
|
||||||
|
@ -651,6 +698,10 @@ item_fn
|
||||||
{
|
{
|
||||||
$$ = mk_node("ItemFn", 5, $2, $3, $4, $5, $6);
|
$$ = mk_node("ItemFn", 5, $2, $3, $4, $5, $6);
|
||||||
}
|
}
|
||||||
|
| CONST FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
|
||||||
|
{
|
||||||
|
$$ = mk_node("ItemFn", 5, $3, $4, $5, $6, $7);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
item_unsafe_fn
|
item_unsafe_fn
|
||||||
|
@ -658,6 +709,10 @@ item_unsafe_fn
|
||||||
{
|
{
|
||||||
$$ = mk_node("ItemUnsafeFn", 5, $3, $4, $5, $6, $7);
|
$$ = mk_node("ItemUnsafeFn", 5, $3, $4, $5, $6, $7);
|
||||||
}
|
}
|
||||||
|
| CONST UNSAFE FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
|
||||||
|
{
|
||||||
|
$$ = mk_node("ItemUnsafeFn", 5, $4, $5, $6, $7, $8);
|
||||||
|
}
|
||||||
| UNSAFE EXTERN maybe_abi FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
|
| UNSAFE EXTERN maybe_abi FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
|
||||||
{
|
{
|
||||||
$$ = mk_node("ItemUnsafeFn", 6, $3, $5, $6, $7, $8, $9);
|
$$ = mk_node("ItemUnsafeFn", 6, $3, $5, $6, $7, $8, $9);
|
||||||
|
@ -723,12 +778,6 @@ inferrable_param
|
||||||
: pat maybe_ty_ascription { $$ = mk_node("InferrableParam", 2, $1, $2); }
|
: pat maybe_ty_ascription { $$ = mk_node("InferrableParam", 2, $1, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
maybe_unboxed_closure_kind
|
|
||||||
: %empty
|
|
||||||
| ':'
|
|
||||||
| '&' maybe_mut ':'
|
|
||||||
;
|
|
||||||
|
|
||||||
maybe_comma_params
|
maybe_comma_params
|
||||||
: ',' { $$ = mk_none(); }
|
: ',' { $$ = mk_none(); }
|
||||||
| ',' params { $$ = $2; }
|
| ',' params { $$ = $2; }
|
||||||
|
@ -784,7 +833,8 @@ ret_ty
|
||||||
;
|
;
|
||||||
|
|
||||||
generic_params
|
generic_params
|
||||||
: '<' lifetimes '>' { $$ = mk_node("Generics", 2, $2, mk_none()); }
|
: '<' '>' { $$ = mk_node("Generics", 2, mk_none(), mk_none()); }
|
||||||
|
| '<' lifetimes '>' { $$ = mk_node("Generics", 2, $2, mk_none()); }
|
||||||
| '<' lifetimes ',' '>' { $$ = mk_node("Generics", 2, $2, mk_none()); }
|
| '<' lifetimes ',' '>' { $$ = mk_node("Generics", 2, $2, mk_none()); }
|
||||||
| '<' lifetimes SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, mk_none()); }
|
| '<' lifetimes SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, mk_none()); }
|
||||||
| '<' lifetimes ',' SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, mk_none()); }
|
| '<' lifetimes ',' SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, mk_none()); }
|
||||||
|
@ -837,6 +887,8 @@ path_no_types_allowed
|
||||||
| MOD_SEP ident { $$ = mk_node("ViewPath", 1, $2); }
|
| MOD_SEP ident { $$ = mk_node("ViewPath", 1, $2); }
|
||||||
| SELF { $$ = mk_node("ViewPath", 1, mk_atom("Self")); }
|
| SELF { $$ = mk_node("ViewPath", 1, mk_atom("Self")); }
|
||||||
| MOD_SEP SELF { $$ = mk_node("ViewPath", 1, mk_atom("Self")); }
|
| MOD_SEP SELF { $$ = mk_node("ViewPath", 1, mk_atom("Self")); }
|
||||||
|
| SUPER { $$ = mk_node("ViewPath", 1, mk_atom("Super")); }
|
||||||
|
| MOD_SEP SUPER { $$ = mk_node("ViewPath", 1, mk_atom("Super")); }
|
||||||
| path_no_types_allowed MOD_SEP ident { $$ = ext_node($1, 1, $3); }
|
| path_no_types_allowed MOD_SEP ident { $$ = ext_node($1, 1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -882,7 +934,7 @@ generic_args
|
||||||
;
|
;
|
||||||
|
|
||||||
generic_values
|
generic_values
|
||||||
: maybe_lifetimes maybe_ty_sums_and_or_bindings { $$ = mk_node("GenericValues", 2, $1, $2); }
|
: maybe_ty_sums_and_or_bindings { $$ = mk_node("GenericValues", 1, $1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
maybe_ty_sums_and_or_bindings
|
maybe_ty_sums_and_or_bindings
|
||||||
|
@ -910,12 +962,11 @@ pat
|
||||||
| ANDAND pat { $$ = mk_node("PatRegion", 1, mk_node("PatRegion", 1, $2)); }
|
| ANDAND pat { $$ = mk_node("PatRegion", 1, mk_node("PatRegion", 1, $2)); }
|
||||||
| '(' ')' { $$ = mk_atom("PatUnit"); }
|
| '(' ')' { $$ = mk_atom("PatUnit"); }
|
||||||
| '(' pat_tup ')' { $$ = mk_node("PatTup", 1, $2); }
|
| '(' pat_tup ')' { $$ = mk_node("PatTup", 1, $2); }
|
||||||
| '(' pat_tup ',' ')' { $$ = mk_node("PatTup", 1, $2); }
|
|
||||||
| '[' pat_vec ']' { $$ = mk_node("PatVec", 1, $2); }
|
| '[' pat_vec ']' { $$ = mk_node("PatVec", 1, $2); }
|
||||||
| lit_or_path
|
| lit_or_path
|
||||||
| lit_or_path DOTDOTDOT lit_or_path { $$ = mk_node("PatRange", 2, $1, $3); }
|
| lit_or_path DOTDOTDOT lit_or_path { $$ = mk_node("PatRange", 2, $1, $3); }
|
||||||
| path_expr '{' pat_struct '}' { $$ = mk_node("PatStruct", 2, $1, $3); }
|
| path_expr '{' pat_struct '}' { $$ = mk_node("PatStruct", 2, $1, $3); }
|
||||||
| path_expr '(' DOTDOT ')' { $$ = mk_node("PatEnum", 1, $1); }
|
| path_expr '(' ')' { $$ = mk_node("PatEnum", 2, $1, mk_none()); }
|
||||||
| path_expr '(' pat_tup ')' { $$ = mk_node("PatEnum", 2, $1, $3); }
|
| path_expr '(' pat_tup ')' { $$ = mk_node("PatEnum", 2, $1, $3); }
|
||||||
| path_expr '!' maybe_ident delimited_token_trees { $$ = mk_node("PatMac", 3, $1, $3, $4); }
|
| path_expr '!' maybe_ident delimited_token_trees { $$ = mk_node("PatMac", 3, $1, $3, $4); }
|
||||||
| binding_mode ident { $$ = mk_node("PatIdent", 2, $1, $2); }
|
| binding_mode ident { $$ = mk_node("PatIdent", 2, $1, $2); }
|
||||||
|
@ -953,6 +1004,7 @@ pat_field
|
||||||
| BOX binding_mode ident { $$ = mk_node("PatField", 3, mk_atom("box"), $2, $3); }
|
| BOX binding_mode ident { $$ = mk_node("PatField", 3, mk_atom("box"), $2, $3); }
|
||||||
| ident ':' pat { $$ = mk_node("PatField", 2, $1, $3); }
|
| ident ':' pat { $$ = mk_node("PatField", 2, $1, $3); }
|
||||||
| binding_mode ident ':' pat { $$ = mk_node("PatField", 3, $1, $2, $4); }
|
| binding_mode ident ':' pat { $$ = mk_node("PatField", 3, $1, $2, $4); }
|
||||||
|
| LIT_INTEGER ':' pat { $$ = mk_node("PatField", 2, mk_atom(yytext), $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
pat_fields
|
pat_fields
|
||||||
|
@ -965,11 +1017,26 @@ pat_struct
|
||||||
| pat_fields ',' { $$ = mk_node("PatStruct", 2, $1, mk_atom("false")); }
|
| pat_fields ',' { $$ = mk_node("PatStruct", 2, $1, mk_atom("false")); }
|
||||||
| pat_fields ',' DOTDOT { $$ = mk_node("PatStruct", 2, $1, mk_atom("true")); }
|
| pat_fields ',' DOTDOT { $$ = mk_node("PatStruct", 2, $1, mk_atom("true")); }
|
||||||
| DOTDOT { $$ = mk_node("PatStruct", 1, mk_atom("true")); }
|
| DOTDOT { $$ = mk_node("PatStruct", 1, mk_atom("true")); }
|
||||||
|
| %empty { $$ = mk_node("PatStruct", 1, mk_none()); }
|
||||||
;
|
;
|
||||||
|
|
||||||
pat_tup
|
pat_tup
|
||||||
: pat { $$ = mk_node("pat_tup", 1, $1); }
|
: pat_tup_elts { $$ = mk_node("PatTup", 2, $1, mk_none()); }
|
||||||
| pat_tup ',' pat { $$ = ext_node($1, 1, $3); }
|
| pat_tup_elts ',' { $$ = mk_node("PatTup", 2, $1, mk_none()); }
|
||||||
|
| pat_tup_elts DOTDOT { $$ = mk_node("PatTup", 2, $1, mk_none()); }
|
||||||
|
| pat_tup_elts ',' DOTDOT { $$ = mk_node("PatTup", 2, $1, mk_none()); }
|
||||||
|
| pat_tup_elts DOTDOT ',' pat_tup_elts { $$ = mk_node("PatTup", 2, $1, $4); }
|
||||||
|
| pat_tup_elts DOTDOT ',' pat_tup_elts ',' { $$ = mk_node("PatTup", 2, $1, $4); }
|
||||||
|
| pat_tup_elts ',' DOTDOT ',' pat_tup_elts { $$ = mk_node("PatTup", 2, $1, $5); }
|
||||||
|
| pat_tup_elts ',' DOTDOT ',' pat_tup_elts ',' { $$ = mk_node("PatTup", 2, $1, $5); }
|
||||||
|
| DOTDOT ',' pat_tup_elts { $$ = mk_node("PatTup", 2, mk_none(), $3); }
|
||||||
|
| DOTDOT ',' pat_tup_elts ',' { $$ = mk_node("PatTup", 2, mk_none(), $3); }
|
||||||
|
| DOTDOT { $$ = mk_node("PatTup", 2, mk_none(), mk_none()); }
|
||||||
|
;
|
||||||
|
|
||||||
|
pat_tup_elts
|
||||||
|
: pat { $$ = mk_node("PatTupElts", 1, $1); }
|
||||||
|
| pat_tup_elts ',' pat { $$ = ext_node($1, 1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
pat_vec
|
pat_vec
|
||||||
|
@ -1010,6 +1077,8 @@ ty_prim
|
||||||
: %prec IDENT path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("global", 1, mk_atom("false")), $1); }
|
: %prec IDENT path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("global", 1, mk_atom("false")), $1); }
|
||||||
| %prec IDENT MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("global", 1, mk_atom("true")), $2); }
|
| %prec IDENT MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("global", 1, mk_atom("true")), $2); }
|
||||||
| %prec IDENT SELF MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("self", 1, mk_atom("true")), $3); }
|
| %prec IDENT SELF MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("self", 1, mk_atom("true")), $3); }
|
||||||
|
| %prec IDENT path_generic_args_without_colons '!' maybe_ident delimited_token_trees { $$ = mk_node("TyMacro", 3, $1, $3, $4); }
|
||||||
|
| %prec IDENT MOD_SEP path_generic_args_without_colons '!' maybe_ident delimited_token_trees { $$ = mk_node("TyMacro", 3, $2, $4, $5); }
|
||||||
| BOX ty { $$ = mk_node("TyBox", 1, $2); }
|
| BOX ty { $$ = mk_node("TyBox", 1, $2); }
|
||||||
| '*' maybe_mut_or_const ty { $$ = mk_node("TyPtr", 2, $2, $3); }
|
| '*' maybe_mut_or_const ty { $$ = mk_node("TyPtr", 2, $2, $3); }
|
||||||
| '&' ty { $$ = mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2); }
|
| '&' ty { $$ = mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2); }
|
||||||
|
@ -1024,7 +1093,6 @@ ty_prim
|
||||||
| TYPEOF '(' expr ')' { $$ = mk_node("TyTypeof", 1, $3); }
|
| TYPEOF '(' expr ')' { $$ = mk_node("TyTypeof", 1, $3); }
|
||||||
| UNDERSCORE { $$ = mk_atom("TyInfer"); }
|
| UNDERSCORE { $$ = mk_atom("TyInfer"); }
|
||||||
| ty_bare_fn
|
| ty_bare_fn
|
||||||
| ty_proc
|
|
||||||
| for_in_type
|
| for_in_type
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1046,17 +1114,12 @@ ty_closure
|
||||||
| OROR maybe_bounds ret_ty { $$ = mk_node("TyClosure", 2, $2, $3); }
|
| OROR maybe_bounds ret_ty { $$ = mk_node("TyClosure", 2, $2, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
ty_proc
|
|
||||||
: PROC generic_params fn_params maybe_bounds ret_ty { $$ = mk_node("TyProc", 4, $2, $3, $4, $5); }
|
|
||||||
;
|
|
||||||
|
|
||||||
for_in_type
|
for_in_type
|
||||||
: FOR '<' maybe_lifetimes '>' for_in_type_suffix { $$ = mk_node("ForInType", 2, $3, $5); }
|
: FOR '<' maybe_lifetimes '>' for_in_type_suffix { $$ = mk_node("ForInType", 2, $3, $5); }
|
||||||
;
|
;
|
||||||
|
|
||||||
for_in_type_suffix
|
for_in_type_suffix
|
||||||
: ty_proc
|
: ty_bare_fn
|
||||||
| ty_bare_fn
|
|
||||||
| trait_ref
|
| trait_ref
|
||||||
| ty_closure
|
| ty_closure
|
||||||
;
|
;
|
||||||
|
@ -1100,13 +1163,23 @@ ty_sums
|
||||||
;
|
;
|
||||||
|
|
||||||
ty_sum
|
ty_sum
|
||||||
: ty { $$ = mk_node("TySum", 1, $1); }
|
: ty_sum_elt { $$ = mk_node("TySum", 1, $1); }
|
||||||
| ty '+' ty_param_bounds { $$ = mk_node("TySum", 2, $1, $3); }
|
| ty_sum '+' ty_sum_elt { $$ = ext_node($1, 1, $3); }
|
||||||
|
;
|
||||||
|
|
||||||
|
ty_sum_elt
|
||||||
|
: ty
|
||||||
|
| lifetime
|
||||||
;
|
;
|
||||||
|
|
||||||
ty_prim_sum
|
ty_prim_sum
|
||||||
: ty_prim { $$ = mk_node("TySum", 1, $1); }
|
: ty_prim_sum_elt { $$ = mk_node("TySum", 1, $1); }
|
||||||
| ty_prim '+' ty_param_bounds { $$ = mk_node("TySum", 2, $1, $3); }
|
| ty_prim_sum '+' ty_prim_sum_elt { $$ = ext_node($1, 1, $3); }
|
||||||
|
;
|
||||||
|
|
||||||
|
ty_prim_sum_elt
|
||||||
|
: ty_prim
|
||||||
|
| lifetime
|
||||||
;
|
;
|
||||||
|
|
||||||
maybe_ty_param_bounds
|
maybe_ty_param_bounds
|
||||||
|
@ -1127,6 +1200,7 @@ boundseq
|
||||||
polybound
|
polybound
|
||||||
: FOR '<' maybe_lifetimes '>' bound { $$ = mk_node("PolyBound", 2, $3, $5); }
|
: FOR '<' maybe_lifetimes '>' bound { $$ = mk_node("PolyBound", 2, $3, $5); }
|
||||||
| bound
|
| bound
|
||||||
|
| '?' FOR '<' maybe_lifetimes '>' bound { $$ = mk_node("PolyBound", 2, $4, $6); }
|
||||||
| '?' bound { $$ = $2; }
|
| '?' bound { $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1244,11 +1318,6 @@ maybe_stmts
|
||||||
// block, nonblock-prefix, and nonblock-nonprefix.
|
// block, nonblock-prefix, and nonblock-nonprefix.
|
||||||
//
|
//
|
||||||
// In non-stmts contexts, expr can relax this trichotomy.
|
// In non-stmts contexts, expr can relax this trichotomy.
|
||||||
//
|
|
||||||
// There is also one other expr subtype: nonparen_expr disallows exprs
|
|
||||||
// surrounded by parens (including tuple expressions), this is
|
|
||||||
// necessary for BOX (place) expressions, so a parens expr following
|
|
||||||
// the BOX is always parsed as the place.
|
|
||||||
|
|
||||||
stmts
|
stmts
|
||||||
: stmt { $$ = mk_node("stmts", 1, $1); }
|
: stmt { $$ = mk_node("stmts", 1, $1); }
|
||||||
|
@ -1256,14 +1325,15 @@ stmts
|
||||||
;
|
;
|
||||||
|
|
||||||
stmt
|
stmt
|
||||||
: let
|
: maybe_outer_attrs let { $$ = $2; }
|
||||||
| stmt_item
|
| stmt_item
|
||||||
| PUB stmt_item { $$ = $2; }
|
| PUB stmt_item { $$ = $2; }
|
||||||
| outer_attrs stmt_item { $$ = $2; }
|
| outer_attrs stmt_item { $$ = $2; }
|
||||||
| outer_attrs PUB stmt_item { $$ = $3; }
|
| outer_attrs PUB stmt_item { $$ = $3; }
|
||||||
| full_block_expr
|
| full_block_expr
|
||||||
| block
|
| maybe_outer_attrs block { $$ = $2; }
|
||||||
| nonblock_expr ';'
|
| nonblock_expr ';'
|
||||||
|
| outer_attrs nonblock_expr ';' { $$ = $2; }
|
||||||
| ';' { $$ = mk_none(); }
|
| ';' { $$ = mk_none(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1296,7 +1366,9 @@ path_expr
|
||||||
// expressions.
|
// expressions.
|
||||||
path_generic_args_with_colons
|
path_generic_args_with_colons
|
||||||
: ident { $$ = mk_node("components", 1, $1); }
|
: ident { $$ = mk_node("components", 1, $1); }
|
||||||
|
| SUPER { $$ = mk_atom("Super"); }
|
||||||
| path_generic_args_with_colons MOD_SEP ident { $$ = ext_node($1, 1, $3); }
|
| path_generic_args_with_colons MOD_SEP ident { $$ = ext_node($1, 1, $3); }
|
||||||
|
| path_generic_args_with_colons MOD_SEP SUPER { $$ = ext_node($1, 1, mk_atom("Super")); }
|
||||||
| path_generic_args_with_colons MOD_SEP generic_args { $$ = ext_node($1, 1, $3); }
|
| path_generic_args_with_colons MOD_SEP generic_args { $$ = ext_node($1, 1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1313,6 +1385,7 @@ nonblock_expr
|
||||||
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
||||||
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
||||||
| path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
|
| path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
|
||||||
|
| nonblock_expr '?' { $$ = mk_node("ExprTry", 1, $1); }
|
||||||
| nonblock_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
| nonblock_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||||
| nonblock_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
| nonblock_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||||
| nonblock_expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
| nonblock_expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
||||||
|
@ -1325,6 +1398,8 @@ nonblock_expr
|
||||||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
||||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
||||||
| BREAK lifetime { $$ = mk_node("ExprBreak", 1, $2); }
|
| BREAK lifetime { $$ = mk_node("ExprBreak", 1, $2); }
|
||||||
|
| YIELD { $$ = mk_node("ExprYield", 0); }
|
||||||
|
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
|
||||||
| nonblock_expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
| nonblock_expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
||||||
| nonblock_expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
| nonblock_expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
||||||
| nonblock_expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
| nonblock_expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
||||||
|
@ -1360,8 +1435,8 @@ nonblock_expr
|
||||||
| DOTDOT expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
| DOTDOT expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
||||||
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
||||||
| nonblock_expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
| nonblock_expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
||||||
| BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
|
| nonblock_expr ':' ty { $$ = mk_node("ExprTypeAscr", 2, $1, $3); }
|
||||||
| %prec BOXPLACE BOX '(' maybe_expr ')' nonblock_expr { $$ = mk_node("ExprBox", 2, $3, $5); }
|
| BOX expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||||
| expr_qualified_path
|
| expr_qualified_path
|
||||||
| nonblock_prefix_expr
|
| nonblock_prefix_expr
|
||||||
;
|
;
|
||||||
|
@ -1373,6 +1448,7 @@ expr
|
||||||
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
||||||
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
||||||
| path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
|
| path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
|
||||||
|
| expr '?' { $$ = mk_node("ExprTry", 1, $1); }
|
||||||
| expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
| expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||||
| expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
| expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||||
| expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
| expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
||||||
|
@ -1385,6 +1461,8 @@ expr
|
||||||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
||||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
||||||
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
|
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
|
||||||
|
| YIELD { $$ = mk_node("ExprYield", 0); }
|
||||||
|
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
|
||||||
| expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
| expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
||||||
| expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
| expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
||||||
| expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
| expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
||||||
|
@ -1420,69 +1498,8 @@ expr
|
||||||
| DOTDOT expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
| DOTDOT expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
||||||
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
||||||
| expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
| expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
||||||
| BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
|
| expr ':' ty { $$ = mk_node("ExprTypeAscr", 2, $1, $3); }
|
||||||
| %prec BOXPLACE BOX '(' maybe_expr ')' expr { $$ = mk_node("ExprBox", 2, $3, $5); }
|
| BOX expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||||
| expr_qualified_path
|
|
||||||
| block_expr
|
|
||||||
| block
|
|
||||||
| nonblock_prefix_expr
|
|
||||||
;
|
|
||||||
|
|
||||||
nonparen_expr
|
|
||||||
: lit { $$ = mk_node("ExprLit", 1, $1); }
|
|
||||||
| %prec IDENT
|
|
||||||
path_expr { $$ = mk_node("ExprPath", 1, $1); }
|
|
||||||
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
|
||||||
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
|
||||||
| path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
|
|
||||||
| nonparen_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
|
||||||
| nonparen_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
|
||||||
| nonparen_expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
|
||||||
| nonparen_expr '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 2, $1, $3); }
|
|
||||||
| '[' vec_expr ']' { $$ = mk_node("ExprVec", 1, $2); }
|
|
||||||
| CONTINUE { $$ = mk_node("ExprAgain", 0); }
|
|
||||||
| CONTINUE ident { $$ = mk_node("ExprAgain", 1, $2); }
|
|
||||||
| RETURN { $$ = mk_node("ExprRet", 0); }
|
|
||||||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
|
||||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
|
||||||
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
|
|
||||||
| nonparen_expr LARROW nonparen_expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
|
||||||
| nonparen_expr '=' nonparen_expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
|
||||||
| nonparen_expr SHLEQ nonparen_expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
|
||||||
| nonparen_expr SHREQ nonparen_expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
|
|
||||||
| nonparen_expr MINUSEQ nonparen_expr { $$ = mk_node("ExprAssignSub", 2, $1, $3); }
|
|
||||||
| nonparen_expr ANDEQ nonparen_expr { $$ = mk_node("ExprAssignBitAnd", 2, $1, $3); }
|
|
||||||
| nonparen_expr OREQ nonparen_expr { $$ = mk_node("ExprAssignBitOr", 2, $1, $3); }
|
|
||||||
| nonparen_expr PLUSEQ nonparen_expr { $$ = mk_node("ExprAssignAdd", 2, $1, $3); }
|
|
||||||
| nonparen_expr STAREQ nonparen_expr { $$ = mk_node("ExprAssignMul", 2, $1, $3); }
|
|
||||||
| nonparen_expr SLASHEQ nonparen_expr { $$ = mk_node("ExprAssignDiv", 2, $1, $3); }
|
|
||||||
| nonparen_expr CARETEQ nonparen_expr { $$ = mk_node("ExprAssignBitXor", 2, $1, $3); }
|
|
||||||
| nonparen_expr PERCENTEQ nonparen_expr { $$ = mk_node("ExprAssignRem", 2, $1, $3); }
|
|
||||||
| nonparen_expr OROR nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiOr"), $1, $3); }
|
|
||||||
| nonparen_expr ANDAND nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAnd"), $1, $3); }
|
|
||||||
| nonparen_expr EQEQ nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiEq"), $1, $3); }
|
|
||||||
| nonparen_expr NE nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiNe"), $1, $3); }
|
|
||||||
| nonparen_expr '<' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLt"), $1, $3); }
|
|
||||||
| nonparen_expr '>' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGt"), $1, $3); }
|
|
||||||
| nonparen_expr LE nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLe"), $1, $3); }
|
|
||||||
| nonparen_expr GE nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGe"), $1, $3); }
|
|
||||||
| nonparen_expr '|' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitOr"), $1, $3); }
|
|
||||||
| nonparen_expr '^' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitXor"), $1, $3); }
|
|
||||||
| nonparen_expr '&' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitAnd"), $1, $3); }
|
|
||||||
| nonparen_expr SHL nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShl"), $1, $3); }
|
|
||||||
| nonparen_expr SHR nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShr"), $1, $3); }
|
|
||||||
| nonparen_expr '+' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAdd"), $1, $3); }
|
|
||||||
| nonparen_expr '-' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiSub"), $1, $3); }
|
|
||||||
| nonparen_expr '*' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiMul"), $1, $3); }
|
|
||||||
| nonparen_expr '/' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiDiv"), $1, $3); }
|
|
||||||
| nonparen_expr '%' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiRem"), $1, $3); }
|
|
||||||
| nonparen_expr DOTDOT { $$ = mk_node("ExprRange", 2, $1, mk_none()); }
|
|
||||||
| nonparen_expr DOTDOT nonparen_expr { $$ = mk_node("ExprRange", 2, $1, $3); }
|
|
||||||
| DOTDOT nonparen_expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
|
||||||
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
|
||||||
| nonparen_expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
|
||||||
| BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
|
|
||||||
| %prec BOXPLACE BOX '(' maybe_expr ')' expr { $$ = mk_node("ExprBox", 1, $3, $5); }
|
|
||||||
| expr_qualified_path
|
| expr_qualified_path
|
||||||
| block_expr
|
| block_expr
|
||||||
| block
|
| block
|
||||||
|
@ -1495,6 +1512,7 @@ expr_nostruct
|
||||||
path_expr { $$ = mk_node("ExprPath", 1, $1); }
|
path_expr { $$ = mk_node("ExprPath", 1, $1); }
|
||||||
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
| SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
|
||||||
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
||||||
|
| expr_nostruct '?' { $$ = mk_node("ExprTry", 1, $1); }
|
||||||
| expr_nostruct '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
| expr_nostruct '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||||
| expr_nostruct '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
| expr_nostruct '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||||
| expr_nostruct '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
| expr_nostruct '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
||||||
|
@ -1507,6 +1525,8 @@ expr_nostruct
|
||||||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
||||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
||||||
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
|
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
|
||||||
|
| YIELD { $$ = mk_node("ExprYield", 0); }
|
||||||
|
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
|
||||||
| expr_nostruct LARROW expr_nostruct { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
| expr_nostruct LARROW expr_nostruct { $$ = mk_node("ExprInPlace", 2, $1, $3); }
|
||||||
| expr_nostruct '=' expr_nostruct { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
| expr_nostruct '=' expr_nostruct { $$ = mk_node("ExprAssign", 2, $1, $3); }
|
||||||
| expr_nostruct SHLEQ expr_nostruct { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
| expr_nostruct SHLEQ expr_nostruct { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
|
||||||
|
@ -1542,8 +1562,8 @@ expr_nostruct
|
||||||
| DOTDOT expr_nostruct { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
| DOTDOT expr_nostruct { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
|
||||||
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
| DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
||||||
| expr_nostruct AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
| expr_nostruct AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
||||||
| BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
|
| expr_nostruct ':' ty { $$ = mk_node("ExprTypeAscr", 2, $1, $3); }
|
||||||
| %prec BOXPLACE BOX '(' maybe_expr ')' expr_nostruct { $$ = mk_node("ExprBox", 1, $3, $5); }
|
| BOX expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||||
| expr_qualified_path
|
| expr_qualified_path
|
||||||
| block_expr
|
| block_expr
|
||||||
| block
|
| block
|
||||||
|
@ -1558,7 +1578,6 @@ nonblock_prefix_expr_nostruct
|
||||||
| ANDAND maybe_mut expr_nostruct { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
|
| ANDAND maybe_mut expr_nostruct { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
|
||||||
| lambda_expr_nostruct
|
| lambda_expr_nostruct
|
||||||
| MOVE lambda_expr_nostruct { $$ = $2; }
|
| MOVE lambda_expr_nostruct { $$ = $2; }
|
||||||
| proc_expr_nostruct
|
|
||||||
;
|
;
|
||||||
|
|
||||||
nonblock_prefix_expr
|
nonblock_prefix_expr
|
||||||
|
@ -1569,7 +1588,6 @@ nonblock_prefix_expr
|
||||||
| ANDAND maybe_mut expr { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
|
| ANDAND maybe_mut expr { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
|
||||||
| lambda_expr
|
| lambda_expr
|
||||||
| MOVE lambda_expr { $$ = $2; }
|
| MOVE lambda_expr { $$ = $2; }
|
||||||
| proc_expr
|
|
||||||
;
|
;
|
||||||
|
|
||||||
expr_qualified_path
|
expr_qualified_path
|
||||||
|
@ -1608,41 +1626,40 @@ lambda_expr
|
||||||
: %prec LAMBDA
|
: %prec LAMBDA
|
||||||
OROR ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $2, $3); }
|
OROR ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $2, $3); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' maybe_unboxed_closure_kind '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $4, $5); }
|
'|' '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $3, $4); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $2, $4, $5); }
|
'|' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $2, $4, $5); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' '&' maybe_mut ':' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $5, $7, $8); }
|
'|' inferrable_params OROR lambda_expr_no_first_bar { $$ = mk_node("ExprFnBlock", 3, $2, mk_none(), $4); }
|
||||||
|
;
|
||||||
|
|
||||||
|
lambda_expr_no_first_bar
|
||||||
|
: %prec LAMBDA
|
||||||
|
'|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $2, $3); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' ':' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $3, $5, $6); }
|
inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $1, $3, $4); }
|
||||||
|
| %prec LAMBDA
|
||||||
|
inferrable_params OROR lambda_expr_no_first_bar { $$ = mk_node("ExprFnBlock", 3, $1, mk_none(), $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
lambda_expr_nostruct
|
lambda_expr_nostruct
|
||||||
: %prec LAMBDA
|
: %prec LAMBDA
|
||||||
OROR expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $2); }
|
OROR expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $2); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' maybe_unboxed_closure_kind '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $4); }
|
'|' '|' ret_ty expr_nostruct { $$ = mk_node("ExprFnBlock", 3, mk_none(), $3, $4); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $2, $4); }
|
'|' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $2, $4); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
'|' '&' maybe_mut ':' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $5, $7); }
|
'|' inferrable_params OROR lambda_expr_nostruct_no_first_bar { $$ = mk_node("ExprFnBlock", 3, $2, mk_none(), $4); }
|
||||||
| %prec LAMBDA
|
|
||||||
'|' ':' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $3, $5); }
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
proc_expr
|
lambda_expr_nostruct_no_first_bar
|
||||||
: %prec LAMBDA
|
: %prec LAMBDA
|
||||||
PROC '(' ')' expr { $$ = mk_node("ExprProc", 2, mk_none(), $4); }
|
'|' ret_ty expr_nostruct { $$ = mk_node("ExprFnBlock", 3, mk_none(), $2, $3); }
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
PROC '(' inferrable_params ')' expr { $$ = mk_node("ExprProc", 2, $3, $5); }
|
inferrable_params '|' ret_ty expr_nostruct { $$ = mk_node("ExprFnBlock", 3, $1, $3, $4); }
|
||||||
;
|
|
||||||
|
|
||||||
proc_expr_nostruct
|
|
||||||
: %prec LAMBDA
|
|
||||||
PROC '(' ')' expr_nostruct { $$ = mk_node("ExprProc", 2, mk_none(), $4); }
|
|
||||||
| %prec LAMBDA
|
| %prec LAMBDA
|
||||||
PROC '(' inferrable_params ')' expr_nostruct { $$ = mk_node("ExprProc", 2, $3, $5); }
|
inferrable_params OROR lambda_expr_nostruct_no_first_bar { $$ = mk_node("ExprFnBlock", 3, $1, mk_none(), $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
vec_expr
|
vec_expr
|
||||||
|
@ -1654,6 +1671,7 @@ struct_expr_fields
|
||||||
: field_inits
|
: field_inits
|
||||||
| field_inits ','
|
| field_inits ','
|
||||||
| maybe_field_inits default_field_init { $$ = ext_node($1, 1, $2); }
|
| maybe_field_inits default_field_init { $$ = ext_node($1, 1, $2); }
|
||||||
|
| %empty { $$ = mk_none(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
maybe_field_inits
|
maybe_field_inits
|
||||||
|
@ -1668,7 +1686,9 @@ field_inits
|
||||||
;
|
;
|
||||||
|
|
||||||
field_init
|
field_init
|
||||||
: ident ':' expr { $$ = mk_node("FieldInit", 2, $1, $3); }
|
: ident { $$ = mk_node("FieldInit", 1, $1); }
|
||||||
|
| ident ':' expr { $$ = mk_node("FieldInit", 2, $1, $3); }
|
||||||
|
| LIT_INTEGER ':' expr { $$ = mk_node("FieldInit", 2, mk_atom(yytext), $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
default_field_init
|
default_field_init
|
||||||
|
@ -1689,10 +1709,18 @@ block_expr
|
||||||
|
|
||||||
full_block_expr
|
full_block_expr
|
||||||
: block_expr
|
: block_expr
|
||||||
| full_block_expr '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
|
| block_expr_dot
|
||||||
| full_block_expr '.' path_generic_args_with_colons '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 3, $1, $3, $5); }
|
;
|
||||||
| full_block_expr '.' path_generic_args_with_colons '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 3, $1, $3, $5); }
|
|
||||||
| full_block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
block_expr_dot
|
||||||
|
: block_expr '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||||
|
| block_expr_dot '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||||
|
| block_expr '.' path_generic_args_with_colons '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 3, $1, $3, $5); }
|
||||||
|
| block_expr_dot '.' path_generic_args_with_colons '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 3, $1, $3, $5); }
|
||||||
|
| block_expr '.' path_generic_args_with_colons '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 3, $1, $3, $5); }
|
||||||
|
| block_expr_dot '.' path_generic_args_with_colons '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 3, $1, $3, $5); }
|
||||||
|
| block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||||
|
| block_expr_dot '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
expr_match
|
expr_match
|
||||||
|
@ -1714,12 +1742,13 @@ match_clause
|
||||||
;
|
;
|
||||||
|
|
||||||
nonblock_match_clause
|
nonblock_match_clause
|
||||||
: maybe_outer_attrs pats_or maybe_guard FAT_ARROW nonblock_expr { $$ = mk_node("Arm", 4, $1, $2, $3, $5); }
|
: maybe_outer_attrs pats_or maybe_guard FAT_ARROW nonblock_expr { $$ = mk_node("ArmNonblock", 4, $1, $2, $3, $5); }
|
||||||
| maybe_outer_attrs pats_or maybe_guard FAT_ARROW full_block_expr { $$ = mk_node("Arm", 4, $1, $2, $3, $5); }
|
| maybe_outer_attrs pats_or maybe_guard FAT_ARROW block_expr_dot { $$ = mk_node("ArmNonblock", 4, $1, $2, $3, $5); }
|
||||||
;
|
;
|
||||||
|
|
||||||
block_match_clause
|
block_match_clause
|
||||||
: maybe_outer_attrs pats_or maybe_guard FAT_ARROW block { $$ = mk_node("Arm", 4, $1, $2, $3, $5); }
|
: maybe_outer_attrs pats_or maybe_guard FAT_ARROW block { $$ = mk_node("ArmBlock", 4, $1, $2, $3, $5); }
|
||||||
|
| maybe_outer_attrs pats_or maybe_guard FAT_ARROW block_expr { $$ = mk_node("ArmBlock", 4, $1, $2, $3, $5); }
|
||||||
;
|
;
|
||||||
|
|
||||||
maybe_guard
|
maybe_guard
|
||||||
|
@ -1796,6 +1825,10 @@ maybe_ident
|
||||||
|
|
||||||
ident
|
ident
|
||||||
: IDENT { $$ = mk_node("ident", 1, mk_atom(yytext)); }
|
: IDENT { $$ = mk_node("ident", 1, mk_atom(yytext)); }
|
||||||
|
// Weak keywords that can be used as identifiers
|
||||||
|
| CATCH { $$ = mk_node("ident", 1, mk_atom(yytext)); }
|
||||||
|
| DEFAULT { $$ = mk_node("ident", 1, mk_atom(yytext)); }
|
||||||
|
| UNION { $$ = mk_node("ident", 1, mk_atom(yytext)); }
|
||||||
;
|
;
|
||||||
|
|
||||||
unpaired_token
|
unpaired_token
|
||||||
|
@ -1836,13 +1869,20 @@ unpaired_token
|
||||||
| LIFETIME { $$ = mk_atom(yytext); }
|
| LIFETIME { $$ = mk_atom(yytext); }
|
||||||
| SELF { $$ = mk_atom(yytext); }
|
| SELF { $$ = mk_atom(yytext); }
|
||||||
| STATIC { $$ = mk_atom(yytext); }
|
| STATIC { $$ = mk_atom(yytext); }
|
||||||
|
| ABSTRACT { $$ = mk_atom(yytext); }
|
||||||
|
| ALIGNOF { $$ = mk_atom(yytext); }
|
||||||
| AS { $$ = mk_atom(yytext); }
|
| AS { $$ = mk_atom(yytext); }
|
||||||
|
| BECOME { $$ = mk_atom(yytext); }
|
||||||
| BREAK { $$ = mk_atom(yytext); }
|
| BREAK { $$ = mk_atom(yytext); }
|
||||||
|
| CATCH { $$ = mk_atom(yytext); }
|
||||||
| CRATE { $$ = mk_atom(yytext); }
|
| CRATE { $$ = mk_atom(yytext); }
|
||||||
|
| DEFAULT { $$ = mk_atom(yytext); }
|
||||||
|
| DO { $$ = mk_atom(yytext); }
|
||||||
| ELSE { $$ = mk_atom(yytext); }
|
| ELSE { $$ = mk_atom(yytext); }
|
||||||
| ENUM { $$ = mk_atom(yytext); }
|
| ENUM { $$ = mk_atom(yytext); }
|
||||||
| EXTERN { $$ = mk_atom(yytext); }
|
| EXTERN { $$ = mk_atom(yytext); }
|
||||||
| FALSE { $$ = mk_atom(yytext); }
|
| FALSE { $$ = mk_atom(yytext); }
|
||||||
|
| FINAL { $$ = mk_atom(yytext); }
|
||||||
| FN { $$ = mk_atom(yytext); }
|
| FN { $$ = mk_atom(yytext); }
|
||||||
| FOR { $$ = mk_atom(yytext); }
|
| FOR { $$ = mk_atom(yytext); }
|
||||||
| IF { $$ = mk_atom(yytext); }
|
| IF { $$ = mk_atom(yytext); }
|
||||||
|
@ -1850,21 +1890,31 @@ unpaired_token
|
||||||
| IN { $$ = mk_atom(yytext); }
|
| IN { $$ = mk_atom(yytext); }
|
||||||
| LET { $$ = mk_atom(yytext); }
|
| LET { $$ = mk_atom(yytext); }
|
||||||
| LOOP { $$ = mk_atom(yytext); }
|
| LOOP { $$ = mk_atom(yytext); }
|
||||||
|
| MACRO { $$ = mk_atom(yytext); }
|
||||||
| MATCH { $$ = mk_atom(yytext); }
|
| MATCH { $$ = mk_atom(yytext); }
|
||||||
| MOD { $$ = mk_atom(yytext); }
|
| MOD { $$ = mk_atom(yytext); }
|
||||||
| MOVE { $$ = mk_atom(yytext); }
|
| MOVE { $$ = mk_atom(yytext); }
|
||||||
| MUT { $$ = mk_atom(yytext); }
|
| MUT { $$ = mk_atom(yytext); }
|
||||||
|
| OFFSETOF { $$ = mk_atom(yytext); }
|
||||||
|
| OVERRIDE { $$ = mk_atom(yytext); }
|
||||||
| PRIV { $$ = mk_atom(yytext); }
|
| PRIV { $$ = mk_atom(yytext); }
|
||||||
| PUB { $$ = mk_atom(yytext); }
|
| PUB { $$ = mk_atom(yytext); }
|
||||||
|
| PURE { $$ = mk_atom(yytext); }
|
||||||
| REF { $$ = mk_atom(yytext); }
|
| REF { $$ = mk_atom(yytext); }
|
||||||
| RETURN { $$ = mk_atom(yytext); }
|
| RETURN { $$ = mk_atom(yytext); }
|
||||||
| STRUCT { $$ = mk_atom(yytext); }
|
| STRUCT { $$ = mk_atom(yytext); }
|
||||||
|
| SIZEOF { $$ = mk_atom(yytext); }
|
||||||
|
| SUPER { $$ = mk_atom(yytext); }
|
||||||
| TRUE { $$ = mk_atom(yytext); }
|
| TRUE { $$ = mk_atom(yytext); }
|
||||||
| TRAIT { $$ = mk_atom(yytext); }
|
| TRAIT { $$ = mk_atom(yytext); }
|
||||||
| TYPE { $$ = mk_atom(yytext); }
|
| TYPE { $$ = mk_atom(yytext); }
|
||||||
|
| UNION { $$ = mk_atom(yytext); }
|
||||||
| UNSAFE { $$ = mk_atom(yytext); }
|
| UNSAFE { $$ = mk_atom(yytext); }
|
||||||
|
| UNSIZED { $$ = mk_atom(yytext); }
|
||||||
| USE { $$ = mk_atom(yytext); }
|
| USE { $$ = mk_atom(yytext); }
|
||||||
|
| VIRTUAL { $$ = mk_atom(yytext); }
|
||||||
| WHILE { $$ = mk_atom(yytext); }
|
| WHILE { $$ = mk_atom(yytext); }
|
||||||
|
| YIELD { $$ = mk_atom(yytext); }
|
||||||
| CONTINUE { $$ = mk_atom(yytext); }
|
| CONTINUE { $$ = mk_atom(yytext); }
|
||||||
| PROC { $$ = mk_atom(yytext); }
|
| PROC { $$ = mk_atom(yytext); }
|
||||||
| BOX { $$ = mk_atom(yytext); }
|
| BOX { $$ = mk_atom(yytext); }
|
||||||
|
|
|
@ -30,6 +30,7 @@ enum Token {
|
||||||
DOTDOT,
|
DOTDOT,
|
||||||
DOTDOTDOT,
|
DOTDOTDOT,
|
||||||
MOD_SEP,
|
MOD_SEP,
|
||||||
|
LARROW,
|
||||||
RARROW,
|
RARROW,
|
||||||
FAT_ARROW,
|
FAT_ARROW,
|
||||||
LIT_BYTE,
|
LIT_BYTE,
|
||||||
|
@ -47,13 +48,20 @@ enum Token {
|
||||||
// keywords
|
// keywords
|
||||||
SELF,
|
SELF,
|
||||||
STATIC,
|
STATIC,
|
||||||
|
ABSTRACT,
|
||||||
|
ALIGNOF,
|
||||||
AS,
|
AS,
|
||||||
|
BECOME,
|
||||||
BREAK,
|
BREAK,
|
||||||
|
CATCH,
|
||||||
CRATE,
|
CRATE,
|
||||||
|
DEFAULT,
|
||||||
|
DO,
|
||||||
ELSE,
|
ELSE,
|
||||||
ENUM,
|
ENUM,
|
||||||
EXTERN,
|
EXTERN,
|
||||||
FALSE,
|
FALSE,
|
||||||
|
FINAL,
|
||||||
FN,
|
FN,
|
||||||
FOR,
|
FOR,
|
||||||
IF,
|
IF,
|
||||||
|
@ -61,21 +69,31 @@ enum Token {
|
||||||
IN,
|
IN,
|
||||||
LET,
|
LET,
|
||||||
LOOP,
|
LOOP,
|
||||||
|
MACRO,
|
||||||
MATCH,
|
MATCH,
|
||||||
MOD,
|
MOD,
|
||||||
MOVE,
|
MOVE,
|
||||||
MUT,
|
MUT,
|
||||||
|
OFFSETOF,
|
||||||
|
OVERRIDE,
|
||||||
PRIV,
|
PRIV,
|
||||||
PUB,
|
PUB,
|
||||||
|
PURE,
|
||||||
REF,
|
REF,
|
||||||
RETURN,
|
RETURN,
|
||||||
|
SIZEOF,
|
||||||
STRUCT,
|
STRUCT,
|
||||||
|
SUPER,
|
||||||
|
UNION,
|
||||||
TRUE,
|
TRUE,
|
||||||
TRAIT,
|
TRAIT,
|
||||||
TYPE,
|
TYPE,
|
||||||
UNSAFE,
|
UNSAFE,
|
||||||
|
UNSIZED,
|
||||||
USE,
|
USE,
|
||||||
|
VIRTUAL,
|
||||||
WHILE,
|
WHILE,
|
||||||
|
YIELD,
|
||||||
CONTINUE,
|
CONTINUE,
|
||||||
PROC,
|
PROC,
|
||||||
BOX,
|
BOX,
|
||||||
|
|
|
@ -269,7 +269,38 @@ impl<T: ?Sized> Box<T> {
|
||||||
#[stable(feature = "box_raw", since = "1.4.0")]
|
#[stable(feature = "box_raw", since = "1.4.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_raw(raw: *mut T) -> Self {
|
pub unsafe fn from_raw(raw: *mut T) -> Self {
|
||||||
mem::transmute(raw)
|
Box::from_unique(Unique::new_unchecked(raw))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Constructs a `Box` from a `Unique<T>` pointer.
|
||||||
|
///
|
||||||
|
/// After calling this function, the memory is owned by a `Box` and `T` can
|
||||||
|
/// then be destroyed and released upon drop.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// A `Unique<T>` can be safely created via [`Unique::new`] and thus doesn't
|
||||||
|
/// necessarily own the data pointed to nor is the data guaranteed to live
|
||||||
|
/// as long as the pointer.
|
||||||
|
///
|
||||||
|
/// [`Unique::new`]: ../../core/ptr/struct.Unique.html#method.new
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(unique)]
|
||||||
|
///
|
||||||
|
/// fn main() {
|
||||||
|
/// let x = Box::new(5);
|
||||||
|
/// let ptr = Box::into_unique(x);
|
||||||
|
/// let x = unsafe { Box::from_unique(ptr) };
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
#[unstable(feature = "unique", reason = "needs an RFC to flesh out design",
|
||||||
|
issue = "27730")]
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn from_unique(u: Unique<T>) -> Self {
|
||||||
|
mem::transmute(u)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes the `Box`, returning the wrapped raw pointer.
|
/// Consumes the `Box`, returning the wrapped raw pointer.
|
||||||
|
@ -295,7 +326,7 @@ impl<T: ?Sized> Box<T> {
|
||||||
#[stable(feature = "box_raw", since = "1.4.0")]
|
#[stable(feature = "box_raw", since = "1.4.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_raw(b: Box<T>) -> *mut T {
|
pub fn into_raw(b: Box<T>) -> *mut T {
|
||||||
unsafe { mem::transmute(b) }
|
Box::into_unique(b).as_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes the `Box`, returning the wrapped pointer as `Unique<T>`.
|
/// Consumes the `Box`, returning the wrapped pointer as `Unique<T>`.
|
||||||
|
@ -303,13 +334,18 @@ impl<T: ?Sized> Box<T> {
|
||||||
/// After calling this function, the caller is responsible for the
|
/// After calling this function, the caller is responsible for the
|
||||||
/// memory previously managed by the `Box`. In particular, the
|
/// memory previously managed by the `Box`. In particular, the
|
||||||
/// caller should properly destroy `T` and release the memory. The
|
/// caller should properly destroy `T` and release the memory. The
|
||||||
/// proper way to do so is to convert the raw pointer back into a
|
/// proper way to do so is to either convert the `Unique<T>` pointer:
|
||||||
/// `Box` with the [`Box::from_raw`] function.
|
///
|
||||||
|
/// - Into a `Box` with the [`Box::from_unique`] function.
|
||||||
|
///
|
||||||
|
/// - Into a raw pointer and back into a `Box` with the [`Box::from_raw`]
|
||||||
|
/// function.
|
||||||
///
|
///
|
||||||
/// Note: this is an associated function, which means that you have
|
/// Note: this is an associated function, which means that you have
|
||||||
/// to call it as `Box::into_unique(b)` instead of `b.into_unique()`. This
|
/// to call it as `Box::into_unique(b)` instead of `b.into_unique()`. This
|
||||||
/// is so that there is no conflict with a method on the inner type.
|
/// is so that there is no conflict with a method on the inner type.
|
||||||
///
|
///
|
||||||
|
/// [`Box::from_unique`]: struct.Box.html#method.from_unique
|
||||||
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
|
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|
|
@ -836,7 +836,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||||
///
|
///
|
||||||
/// See the `discriminant` function in this module for more information.
|
/// See the `discriminant` function in this module for more information.
|
||||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||||
pub struct Discriminant<T>(u64, PhantomData<*const T>);
|
pub struct Discriminant<T>(u64, PhantomData<fn() -> T>);
|
||||||
|
|
||||||
// N.B. These trait implementations cannot be derived because we don't want any bounds on T.
|
// N.B. These trait implementations cannot be derived because we don't want any bounds on T.
|
||||||
|
|
||||||
|
|
|
@ -121,3 +121,19 @@ fn test_transmute() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn test_discriminant_send_sync() {
|
||||||
|
enum Regular {
|
||||||
|
A,
|
||||||
|
B(i32)
|
||||||
|
}
|
||||||
|
enum NotSendSync {
|
||||||
|
A(*const i32)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_send_sync<T: Send + Sync>() { }
|
||||||
|
|
||||||
|
is_send_sync::<Discriminant<Regular>>();
|
||||||
|
is_send_sync::<Discriminant<NotSendSync>>();
|
||||||
|
}
|
||||||
|
|
|
@ -488,7 +488,7 @@ impl Literal {
|
||||||
pub fn string(string: &str) -> Literal {
|
pub fn string(string: &str) -> Literal {
|
||||||
let mut escaped = String::new();
|
let mut escaped = String::new();
|
||||||
for ch in string.chars() {
|
for ch in string.chars() {
|
||||||
escaped.extend(ch.escape_unicode());
|
escaped.extend(ch.escape_debug());
|
||||||
}
|
}
|
||||||
Literal(token::Literal(token::Lit::Str_(Symbol::intern(&escaped)), None))
|
Literal(token::Literal(token::Lit::Str_(Symbol::intern(&escaped)), None))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1100,6 +1100,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
"generate a graphical HTML report of time spent in trans and LLVM"),
|
"generate a graphical HTML report of time spent in trans and LLVM"),
|
||||||
thinlto: bool = (false, parse_bool, [TRACKED],
|
thinlto: bool = (false, parse_bool, [TRACKED],
|
||||||
"enable ThinLTO when possible"),
|
"enable ThinLTO when possible"),
|
||||||
|
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||||
|
"control whether #[inline] functions are in all cgus"),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_lib_output() -> CrateType {
|
pub fn default_lib_output() -> CrateType {
|
||||||
|
@ -1711,7 +1713,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
||||||
|
|
||||||
let codegen_units = codegen_units.unwrap_or_else(|| {
|
let codegen_units = codegen_units.unwrap_or_else(|| {
|
||||||
match opt_level {
|
match opt_level {
|
||||||
// If we're compiling at `-O0` then default to 32 codegen units.
|
// If we're compiling at `-O0` then default to 16 codegen units.
|
||||||
// The number here shouldn't matter too too much as debug mode
|
// The number here shouldn't matter too too much as debug mode
|
||||||
// builds don't rely on performance at all, meaning that lost
|
// builds don't rely on performance at all, meaning that lost
|
||||||
// opportunities for inlining through multiple codegen units is
|
// opportunities for inlining through multiple codegen units is
|
||||||
|
@ -1729,7 +1731,21 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
||||||
// unit takes *too* long to build we'll be guaranteed that all
|
// unit takes *too* long to build we'll be guaranteed that all
|
||||||
// cpus will finish pretty closely to one another and we should
|
// cpus will finish pretty closely to one another and we should
|
||||||
// make relatively optimal use of system resources
|
// make relatively optimal use of system resources
|
||||||
OptLevel::No => 32,
|
//
|
||||||
|
// Another note worth mentioning here, however, is that this number
|
||||||
|
// isn't *too* high. When codegen units are increased that means we
|
||||||
|
// currently have to codegen `#[inline]` functions into each codegen
|
||||||
|
// unit, which means the more codegen units we're using the more we
|
||||||
|
// may be generating. In other words, increasing codegen units may
|
||||||
|
// increase the overall work the compiler does. If we don't have
|
||||||
|
// enough cores to make up for this loss then increasing the number
|
||||||
|
// of codegen units could become an overall loss!
|
||||||
|
//
|
||||||
|
// As a result we choose a hopefully conservative value 16, which
|
||||||
|
// should be more than the number of cpus of most hardware compiling
|
||||||
|
// Rust but also not too much for 2-4 core machines to have too much
|
||||||
|
// loss of compile time.
|
||||||
|
OptLevel::No => 16,
|
||||||
|
|
||||||
// All other optimization levels default use one codegen unit,
|
// All other optimization levels default use one codegen unit,
|
||||||
// the historical default in Rust for a Long Time.
|
// the historical default in Rust for a Long Time.
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
use LinkerFlavor;
|
|
||||||
use super::{LinkArgs, Target, TargetOptions, TargetResult};
|
|
||||||
|
|
||||||
pub fn target() -> TargetResult {
|
|
||||||
let mut pre_link_args = LinkArgs::new();
|
|
||||||
pre_link_args.insert(LinkerFlavor::Gcc,
|
|
||||||
vec!["--pnacl-exceptions=sjlj".to_string(),
|
|
||||||
"--target=le32-unknown-nacl".to_string(),
|
|
||||||
"-Wl,--start-group".to_string()]);
|
|
||||||
let mut post_link_args = LinkArgs::new();
|
|
||||||
post_link_args.insert(LinkerFlavor::Gcc,
|
|
||||||
vec!["-Wl,--end-group".to_string()]);
|
|
||||||
|
|
||||||
let opts = TargetOptions {
|
|
||||||
linker: "pnacl-clang".to_string(),
|
|
||||||
ar: "pnacl-ar".to_string(),
|
|
||||||
|
|
||||||
pre_link_args,
|
|
||||||
post_link_args,
|
|
||||||
dynamic_linking: false,
|
|
||||||
executables: true,
|
|
||||||
exe_suffix: ".pexe".to_string(),
|
|
||||||
linker_is_gnu: true,
|
|
||||||
allow_asm: false,
|
|
||||||
max_atomic_width: Some(32),
|
|
||||||
.. Default::default()
|
|
||||||
};
|
|
||||||
Ok(Target {
|
|
||||||
llvm_target: "le32-unknown-nacl".to_string(),
|
|
||||||
target_endian: "little".to_string(),
|
|
||||||
target_pointer_width: "32".to_string(),
|
|
||||||
target_c_int_width: "32".to_string(),
|
|
||||||
target_os: "nacl".to_string(),
|
|
||||||
target_env: "newlib".to_string(),
|
|
||||||
target_vendor: "unknown".to_string(),
|
|
||||||
data_layout: "e-i64:64:64-p:32:32:32-v128:32:32".to_string(),
|
|
||||||
arch: "le32".to_string(),
|
|
||||||
linker_flavor: LinkerFlavor::Gcc,
|
|
||||||
options: opts,
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -215,7 +215,6 @@ supported_targets! {
|
||||||
("i686-pc-windows-msvc", i686_pc_windows_msvc),
|
("i686-pc-windows-msvc", i686_pc_windows_msvc),
|
||||||
("i586-pc-windows-msvc", i586_pc_windows_msvc),
|
("i586-pc-windows-msvc", i586_pc_windows_msvc),
|
||||||
|
|
||||||
("le32-unknown-nacl", le32_unknown_nacl),
|
|
||||||
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
|
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
|
||||||
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
|
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
|
||||||
("wasm32-experimental-emscripten", wasm32_experimental_emscripten),
|
("wasm32-experimental-emscripten", wasm32_experimental_emscripten),
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
//! be indexed by the direction (see the type `Direction`).
|
//! be indexed by the direction (see the type `Direction`).
|
||||||
|
|
||||||
use bitvec::BitVector;
|
use bitvec::BitVector;
|
||||||
use std::fmt::{Formatter, Error, Debug};
|
use std::fmt::Debug;
|
||||||
use std::usize;
|
use std::usize;
|
||||||
use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ pub struct Node<N> {
|
||||||
pub data: N,
|
pub data: N,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Edge<E> {
|
pub struct Edge<E> {
|
||||||
next_edge: [EdgeIndex; 2], // see module comment
|
next_edge: [EdgeIndex; 2], // see module comment
|
||||||
source: NodeIndex,
|
source: NodeIndex,
|
||||||
|
@ -69,18 +70,6 @@ impl<N> SnapshotVecDelegate for Edge<N> {
|
||||||
fn reverse(_: &mut Vec<Edge<N>>, _: ()) {}
|
fn reverse(_: &mut Vec<Edge<N>>, _: ()) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Debug> Debug for Edge<E> {
|
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
|
||||||
write!(f,
|
|
||||||
"Edge {{ next_edge: [{:?}, {:?}], source: {:?}, target: {:?}, data: {:?} }}",
|
|
||||||
self.next_edge[0],
|
|
||||||
self.next_edge[1],
|
|
||||||
self.source,
|
|
||||||
self.target,
|
|
||||||
self.data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct NodeIndex(pub usize);
|
pub struct NodeIndex(pub usize);
|
||||||
|
|
||||||
|
|
|
@ -1238,7 +1238,7 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
|
||||||
errors::Level::Note);
|
errors::Level::Note);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(io::stderr(), "{}", str::from_utf8(&data.lock().unwrap()).unwrap()).unwrap();
|
eprintln!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_on_err();
|
exit_on_err();
|
||||||
|
|
|
@ -88,7 +88,7 @@ fn main() {
|
||||||
let is_crossed = target != host;
|
let is_crossed = target != host;
|
||||||
|
|
||||||
let mut optional_components =
|
let mut optional_components =
|
||||||
vec!["x86", "arm", "aarch64", "mips", "powerpc", "pnacl",
|
vec!["x86", "arm", "aarch64", "mips", "powerpc",
|
||||||
"systemz", "jsbackend", "webassembly", "msp430", "sparc", "nvptx"];
|
"systemz", "jsbackend", "webassembly", "msp430", "sparc", "nvptx"];
|
||||||
|
|
||||||
let mut version_cmd = Command::new(&llvm_config);
|
let mut version_cmd = Command::new(&llvm_config);
|
||||||
|
|
|
@ -346,10 +346,6 @@ pub fn initialize_available_targets() {
|
||||||
LLVMInitializePowerPCTargetMC,
|
LLVMInitializePowerPCTargetMC,
|
||||||
LLVMInitializePowerPCAsmPrinter,
|
LLVMInitializePowerPCAsmPrinter,
|
||||||
LLVMInitializePowerPCAsmParser);
|
LLVMInitializePowerPCAsmParser);
|
||||||
init_target!(llvm_component = "pnacl",
|
|
||||||
LLVMInitializePNaClTargetInfo,
|
|
||||||
LLVMInitializePNaClTarget,
|
|
||||||
LLVMInitializePNaClTargetMC);
|
|
||||||
init_target!(llvm_component = "systemz",
|
init_target!(llvm_component = "systemz",
|
||||||
LLVMInitializeSystemZTargetInfo,
|
LLVMInitializeSystemZTargetInfo,
|
||||||
LLVMInitializeSystemZTarget,
|
LLVMInitializeSystemZTarget,
|
||||||
|
|
|
@ -751,9 +751,7 @@ impl<'a, 'tcx> FnType<'tcx> {
|
||||||
Some(ty.boxed_ty())
|
Some(ty.boxed_ty())
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyRef(b, mt) => {
|
ty::TyRef(_, mt) => {
|
||||||
use rustc::ty::{BrAnon, ReLateBound};
|
|
||||||
|
|
||||||
// `&mut` pointer parameters never alias other parameters, or mutable global data
|
// `&mut` pointer parameters never alias other parameters, or mutable global data
|
||||||
//
|
//
|
||||||
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as
|
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as
|
||||||
|
@ -779,13 +777,6 @@ impl<'a, 'tcx> FnType<'tcx> {
|
||||||
arg.attrs.set(ArgAttribute::ReadOnly);
|
arg.attrs.set(ArgAttribute::ReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a reference in an argument has no named lifetime, it's
|
|
||||||
// impossible for that reference to escape this function
|
|
||||||
// (returned or stored beyond the call by a closure).
|
|
||||||
if let ReLateBound(_, BrAnon(_)) = *b {
|
|
||||||
arg.attrs.set(ArgAttribute::NoCapture);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(mt.ty)
|
Some(mt.ty)
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None
|
||||||
|
|
|
@ -98,8 +98,10 @@
|
||||||
//! DefPaths which are much more robust in the face of changes to the code base.
|
//! DefPaths which are much more robust in the face of changes to the code base.
|
||||||
|
|
||||||
use monomorphize::Instance;
|
use monomorphize::Instance;
|
||||||
|
use trans_item::{TransItemExt, InstantiationMode};
|
||||||
|
|
||||||
use rustc::middle::weak_lang_items;
|
use rustc::middle::weak_lang_items;
|
||||||
|
use rustc::middle::trans::TransItem;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::hir::map as hir_map;
|
use rustc::hir::map as hir_map;
|
||||||
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||||
|
@ -150,7 +152,10 @@ pub fn provide(providers: &mut Providers) {
|
||||||
fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
// the DefId of the item this name is for
|
// the DefId of the item this name is for
|
||||||
def_id: Option<DefId>,
|
def_id: DefId,
|
||||||
|
|
||||||
|
// instance this name will be for
|
||||||
|
instance: Instance<'tcx>,
|
||||||
|
|
||||||
// type of the item, without any generic
|
// type of the item, without any generic
|
||||||
// parameters substituted; this is
|
// parameters substituted; this is
|
||||||
|
@ -160,7 +165,7 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
// values for generic type parameters,
|
// values for generic type parameters,
|
||||||
// if any.
|
// if any.
|
||||||
substs: Option<&'tcx Substs<'tcx>>)
|
substs: &'tcx Substs<'tcx>)
|
||||||
-> u64 {
|
-> u64 {
|
||||||
debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
|
debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
|
||||||
|
|
||||||
|
@ -170,7 +175,7 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// the main symbol name is not necessarily unique; hash in the
|
// the main symbol name is not necessarily unique; hash in the
|
||||||
// compiler's internal def-path, guaranteeing each symbol has a
|
// compiler's internal def-path, guaranteeing each symbol has a
|
||||||
// truly unique path
|
// truly unique path
|
||||||
hasher.hash(def_id.map(|def_id| tcx.def_path_hash(def_id)));
|
hasher.hash(tcx.def_path_hash(def_id));
|
||||||
|
|
||||||
// Include the main item-type. Note that, in this case, the
|
// Include the main item-type. Note that, in this case, the
|
||||||
// assertions about `needs_subst` may not hold, but this item-type
|
// assertions about `needs_subst` may not hold, but this item-type
|
||||||
|
@ -186,20 +191,37 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// also include any type parameters (for generic items)
|
// also include any type parameters (for generic items)
|
||||||
if let Some(substs) = substs {
|
|
||||||
assert!(!substs.has_erasable_regions());
|
assert!(!substs.has_erasable_regions());
|
||||||
assert!(!substs.needs_subst());
|
assert!(!substs.needs_subst());
|
||||||
substs.visit_with(&mut hasher);
|
substs.visit_with(&mut hasher);
|
||||||
|
|
||||||
|
let mut avoid_cross_crate_conflicts = false;
|
||||||
|
|
||||||
// If this is an instance of a generic function, we also hash in
|
// If this is an instance of a generic function, we also hash in
|
||||||
// the ID of the instantiating crate. This avoids symbol conflicts
|
// the ID of the instantiating crate. This avoids symbol conflicts
|
||||||
// in case the same instances is emitted in two crates of the same
|
// in case the same instances is emitted in two crates of the same
|
||||||
// project.
|
// project.
|
||||||
if substs.types().next().is_some() {
|
if substs.types().next().is_some() {
|
||||||
|
avoid_cross_crate_conflicts = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're dealing with an instance of a function that's inlined from
|
||||||
|
// another crate but we're marking it as globally shared to our
|
||||||
|
// compliation (aka we're not making an internal copy in each of our
|
||||||
|
// codegen units) then this symbol may become an exported (but hidden
|
||||||
|
// visibility) symbol. This means that multiple crates may do the same
|
||||||
|
// and we want to be sure to avoid any symbol conflicts here.
|
||||||
|
match TransItem::Fn(instance).instantiation_mode(tcx) {
|
||||||
|
InstantiationMode::GloballyShared { may_conflict: true } => {
|
||||||
|
avoid_cross_crate_conflicts = true;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if avoid_cross_crate_conflicts {
|
||||||
hasher.hash(tcx.crate_name.as_str());
|
hasher.hash(tcx.crate_name.as_str());
|
||||||
hasher.hash(tcx.sess.local_crate_disambiguator().as_str());
|
hasher.hash(tcx.sess.local_crate_disambiguator().as_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 64 bits should be enough to avoid collisions.
|
// 64 bits should be enough to avoid collisions.
|
||||||
|
@ -309,7 +331,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
|
||||||
// and should not matter anyhow.
|
// and should not matter anyhow.
|
||||||
let instance_ty = tcx.erase_regions(&instance_ty);
|
let instance_ty = tcx.erase_regions(&instance_ty);
|
||||||
|
|
||||||
let hash = get_symbol_hash(tcx, Some(def_id), instance_ty, Some(substs));
|
let hash = get_symbol_hash(tcx, def_id, instance, instance_ty, substs);
|
||||||
|
|
||||||
SymbolPathBuffer::from_interned(tcx.def_symbol_name(def_id)).finish(hash)
|
SymbolPathBuffer::from_interned(tcx.def_symbol_name(def_id)).finish(hash)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1247,7 +1247,7 @@ fn start_executing_work(tcx: TyCtxt,
|
||||||
modules_config: Arc<ModuleConfig>,
|
modules_config: Arc<ModuleConfig>,
|
||||||
metadata_config: Arc<ModuleConfig>,
|
metadata_config: Arc<ModuleConfig>,
|
||||||
allocator_config: Arc<ModuleConfig>)
|
allocator_config: Arc<ModuleConfig>)
|
||||||
-> thread::JoinHandle<CompiledModules> {
|
-> thread::JoinHandle<Result<CompiledModules, ()>> {
|
||||||
let coordinator_send = tcx.tx_to_llvm_workers.clone();
|
let coordinator_send = tcx.tx_to_llvm_workers.clone();
|
||||||
let mut exported_symbols = FxHashMap();
|
let mut exported_symbols = FxHashMap();
|
||||||
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
|
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
|
||||||
|
@ -1695,7 +1695,7 @@ fn start_executing_work(tcx: TyCtxt,
|
||||||
Message::Done { result: Err(()), worker_id: _ } => {
|
Message::Done { result: Err(()), worker_id: _ } => {
|
||||||
shared_emitter.fatal("aborting due to worker thread failure");
|
shared_emitter.fatal("aborting due to worker thread failure");
|
||||||
// Exit the coordinator thread
|
// Exit the coordinator thread
|
||||||
panic!("aborting due to worker thread failure")
|
return Err(())
|
||||||
}
|
}
|
||||||
Message::TranslateItem => {
|
Message::TranslateItem => {
|
||||||
bug!("the coordinator should not receive translation requests")
|
bug!("the coordinator should not receive translation requests")
|
||||||
|
@ -1721,11 +1721,11 @@ fn start_executing_work(tcx: TyCtxt,
|
||||||
let compiled_metadata_module = compiled_metadata_module
|
let compiled_metadata_module = compiled_metadata_module
|
||||||
.expect("Metadata module not compiled?");
|
.expect("Metadata module not compiled?");
|
||||||
|
|
||||||
CompiledModules {
|
Ok(CompiledModules {
|
||||||
modules: compiled_modules,
|
modules: compiled_modules,
|
||||||
metadata_module: compiled_metadata_module,
|
metadata_module: compiled_metadata_module,
|
||||||
allocator_module: compiled_allocator_module,
|
allocator_module: compiled_allocator_module,
|
||||||
}
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// A heuristic that determines if we have enough LLVM WorkItems in the
|
// A heuristic that determines if we have enough LLVM WorkItems in the
|
||||||
|
@ -2018,7 +2018,7 @@ pub struct OngoingCrateTranslation {
|
||||||
coordinator_send: Sender<Box<Any + Send>>,
|
coordinator_send: Sender<Box<Any + Send>>,
|
||||||
trans_worker_receive: Receiver<Message>,
|
trans_worker_receive: Receiver<Message>,
|
||||||
shared_emitter_main: SharedEmitterMain,
|
shared_emitter_main: SharedEmitterMain,
|
||||||
future: thread::JoinHandle<CompiledModules>,
|
future: thread::JoinHandle<Result<CompiledModules, ()>>,
|
||||||
output_filenames: Arc<OutputFilenames>,
|
output_filenames: Arc<OutputFilenames>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,7 +2026,11 @@ impl OngoingCrateTranslation {
|
||||||
pub fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation {
|
pub fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation {
|
||||||
self.shared_emitter_main.check(sess, true);
|
self.shared_emitter_main.check(sess, true);
|
||||||
let compiled_modules = match self.future.join() {
|
let compiled_modules = match self.future.join() {
|
||||||
Ok(compiled_modules) => compiled_modules,
|
Ok(Ok(compiled_modules)) => compiled_modules,
|
||||||
|
Ok(Err(())) => {
|
||||||
|
sess.abort_if_errors();
|
||||||
|
panic!("expected abort due to worker thread errors")
|
||||||
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
sess.fatal("Error during translation/LLVM phase.");
|
sess.fatal("Error during translation/LLVM phase.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1231,9 +1231,6 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
});
|
});
|
||||||
|
|
||||||
assert!(tcx.sess.opts.codegen_units == codegen_units.len() ||
|
|
||||||
tcx.sess.opts.debugging_opts.incremental.is_some());
|
|
||||||
|
|
||||||
let translation_items: DefIdSet = items.iter().filter_map(|trans_item| {
|
let translation_items: DefIdSet = items.iter().filter_map(|trans_item| {
|
||||||
match *trans_item {
|
match *trans_item {
|
||||||
TransItem::Fn(ref instance) => Some(instance.def_id()),
|
TransItem::Fn(ref instance) => Some(instance.def_id()),
|
||||||
|
|
|
@ -279,9 +279,11 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let mut internalization_candidates = FxHashSet();
|
let mut internalization_candidates = FxHashSet();
|
||||||
|
|
||||||
for trans_item in trans_items {
|
for trans_item in trans_items {
|
||||||
let is_root = trans_item.instantiation_mode(tcx) == InstantiationMode::GloballyShared;
|
match trans_item.instantiation_mode(tcx) {
|
||||||
|
InstantiationMode::GloballyShared { .. } => {}
|
||||||
|
InstantiationMode::LocalCopy => continue,
|
||||||
|
}
|
||||||
|
|
||||||
if is_root {
|
|
||||||
let characteristic_def_id = characteristic_def_id_of_trans_item(tcx, trans_item);
|
let characteristic_def_id = characteristic_def_id_of_trans_item(tcx, trans_item);
|
||||||
let is_volatile = is_incremental_build &&
|
let is_volatile = is_incremental_build &&
|
||||||
trans_item.is_generic_fn();
|
trans_item.is_generic_fn();
|
||||||
|
@ -309,11 +311,9 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
if tcx.is_exported_symbol(def_id) {
|
if tcx.is_exported_symbol(def_id) {
|
||||||
Visibility::Default
|
Visibility::Default
|
||||||
} else {
|
} else {
|
||||||
internalization_candidates.insert(trans_item);
|
|
||||||
Visibility::Hidden
|
Visibility::Hidden
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
internalization_candidates.insert(trans_item);
|
|
||||||
Visibility::Hidden
|
Visibility::Hidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,9 +323,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
InstanceDef::ClosureOnceShim { .. } |
|
InstanceDef::ClosureOnceShim { .. } |
|
||||||
InstanceDef::DropGlue(..) |
|
InstanceDef::DropGlue(..) |
|
||||||
InstanceDef::CloneShim(..) => {
|
InstanceDef::CloneShim(..) => {
|
||||||
bug!("partitioning: Encountered unexpected
|
Visibility::Hidden
|
||||||
root translation item: {:?}",
|
|
||||||
trans_item)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(Linkage::External, visibility)
|
(Linkage::External, visibility)
|
||||||
|
@ -336,7 +334,6 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let visibility = if tcx.is_exported_symbol(def_id) {
|
let visibility = if tcx.is_exported_symbol(def_id) {
|
||||||
Visibility::Default
|
Visibility::Default
|
||||||
} else {
|
} else {
|
||||||
internalization_candidates.insert(trans_item);
|
|
||||||
Visibility::Hidden
|
Visibility::Hidden
|
||||||
};
|
};
|
||||||
(Linkage::External, visibility)
|
(Linkage::External, visibility)
|
||||||
|
@ -344,11 +341,13 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if visibility == Visibility::Hidden {
|
||||||
|
internalization_candidates.insert(trans_item);
|
||||||
|
}
|
||||||
|
|
||||||
codegen_unit.items_mut().insert(trans_item, (linkage, visibility));
|
codegen_unit.items_mut().insert(trans_item, (linkage, visibility));
|
||||||
roots.insert(trans_item);
|
roots.insert(trans_item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// always ensure we have at least one CGU; otherwise, if we have a
|
// always ensure we have at least one CGU; otherwise, if we have a
|
||||||
// crate with just types (for example), we could wind up with no CGU
|
// crate with just types (for example), we could wind up with no CGU
|
||||||
|
@ -390,15 +389,6 @@ fn merge_codegen_units<'tcx>(initial_partitioning: &mut PreInliningPartitioning<
|
||||||
for (index, cgu) in codegen_units.iter_mut().enumerate() {
|
for (index, cgu) in codegen_units.iter_mut().enumerate() {
|
||||||
cgu.set_name(numbered_codegen_unit_name(crate_name, index));
|
cgu.set_name(numbered_codegen_unit_name(crate_name, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the initial partitioning contained less than target_cgu_count to begin
|
|
||||||
// with, we won't have enough codegen units here, so add a empty units until
|
|
||||||
// we reach the target count
|
|
||||||
while codegen_units.len() < target_cgu_count {
|
|
||||||
let index = codegen_units.len();
|
|
||||||
let name = numbered_codegen_unit_name(crate_name, index);
|
|
||||||
codegen_units.push(CodegenUnit::new(name));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn place_inlined_translation_items<'tcx>(initial_partitioning: PreInliningPartitioning<'tcx>,
|
fn place_inlined_translation_items<'tcx>(initial_partitioning: PreInliningPartitioning<'tcx>,
|
||||||
|
|
|
@ -26,6 +26,7 @@ use monomorphize::Instance;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::middle::trans::{Linkage, Visibility};
|
use rustc::middle::trans::{Linkage, Visibility};
|
||||||
|
use rustc::session::config::OptLevel;
|
||||||
use rustc::traits;
|
use rustc::traits;
|
||||||
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||||
use rustc::ty::subst::{Subst, Substs};
|
use rustc::ty::subst::{Subst, Substs};
|
||||||
|
@ -44,7 +45,20 @@ pub use rustc::middle::trans::TransItem;
|
||||||
pub enum InstantiationMode {
|
pub enum InstantiationMode {
|
||||||
/// There will be exactly one instance of the given TransItem. It will have
|
/// There will be exactly one instance of the given TransItem. It will have
|
||||||
/// external linkage so that it can be linked to from other codegen units.
|
/// external linkage so that it can be linked to from other codegen units.
|
||||||
GloballyShared,
|
GloballyShared {
|
||||||
|
/// In some compilation scenarios we may decide to take functions that
|
||||||
|
/// are typically `LocalCopy` and instead move them to `GloballyShared`
|
||||||
|
/// to avoid translating them a bunch of times. In this situation,
|
||||||
|
/// however, our local copy may conflict with other crates also
|
||||||
|
/// inlining the same function.
|
||||||
|
///
|
||||||
|
/// This flag indicates that this situation is occuring, and informs
|
||||||
|
/// symbol name calculation that some extra mangling is needed to
|
||||||
|
/// avoid conflicts. Note that this may eventually go away entirely if
|
||||||
|
/// ThinLTO enables us to *always* have a globally shared instance of a
|
||||||
|
/// function within one crate's compilation.
|
||||||
|
may_conflict: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// Each codegen unit containing a reference to the given TransItem will
|
/// Each codegen unit containing a reference to the given TransItem will
|
||||||
/// have its own private copy of the function (with internal linkage).
|
/// have its own private copy of the function (with internal linkage).
|
||||||
|
@ -154,18 +168,31 @@ pub trait TransItemExt<'a, 'tcx>: fmt::Debug {
|
||||||
fn instantiation_mode(&self,
|
fn instantiation_mode(&self,
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||||
-> InstantiationMode {
|
-> InstantiationMode {
|
||||||
|
let inline_in_all_cgus =
|
||||||
|
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| {
|
||||||
|
tcx.sess.opts.optimize != OptLevel::No
|
||||||
|
});
|
||||||
|
|
||||||
match *self.as_trans_item() {
|
match *self.as_trans_item() {
|
||||||
TransItem::Fn(ref instance) => {
|
TransItem::Fn(ref instance) => {
|
||||||
if self.explicit_linkage(tcx).is_none() &&
|
if self.explicit_linkage(tcx).is_none() &&
|
||||||
common::requests_inline(tcx, instance)
|
common::requests_inline(tcx, instance)
|
||||||
{
|
{
|
||||||
|
if inline_in_all_cgus {
|
||||||
InstantiationMode::LocalCopy
|
InstantiationMode::LocalCopy
|
||||||
} else {
|
} else {
|
||||||
InstantiationMode::GloballyShared
|
InstantiationMode::GloballyShared { may_conflict: true }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InstantiationMode::GloballyShared { may_conflict: false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TransItem::Static(..) => InstantiationMode::GloballyShared,
|
TransItem::Static(..) => {
|
||||||
TransItem::GlobalAsm(..) => InstantiationMode::GloballyShared,
|
InstantiationMode::GloballyShared { may_conflict: false }
|
||||||
|
}
|
||||||
|
TransItem::GlobalAsm(..) => {
|
||||||
|
InstantiationMode::GloballyShared { may_conflict: false }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1464,7 +1464,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
||||||
/// declaration like `self: SomeType` into either `self`,
|
/// declaration like `self: SomeType` into either `self`,
|
||||||
/// `&self`, `&mut self`, or `Box<self>`. We do this here
|
/// `&self`, `&mut self`, or `Box<self>`. We do this here
|
||||||
/// by some simple pattern matching. A more precise check
|
/// by some simple pattern matching. A more precise check
|
||||||
/// is done later in `check_method_self_type()`.
|
/// is done later in `check_method_receiver()`.
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
///
|
///
|
||||||
|
@ -1475,7 +1475,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
||||||
/// fn method2(self: &T); // ExplicitSelf::ByValue
|
/// fn method2(self: &T); // ExplicitSelf::ByValue
|
||||||
/// fn method3(self: Box<&T>); // ExplicitSelf::ByBox
|
/// fn method3(self: Box<&T>); // ExplicitSelf::ByBox
|
||||||
///
|
///
|
||||||
/// // Invalid cases will be caught later by `check_method_self_type`:
|
/// // Invalid cases will be caught later by `check_method_receiver`:
|
||||||
/// fn method_err1(self: &mut T); // ExplicitSelf::ByReference
|
/// fn method_err1(self: &mut T); // ExplicitSelf::ByReference
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -337,7 +337,6 @@ impl<'a> fmt::Display for Html<'a> {
|
||||||
"l4re" => "L4Re",
|
"l4re" => "L4Re",
|
||||||
"linux" => "Linux",
|
"linux" => "Linux",
|
||||||
"macos" => "macOS",
|
"macos" => "macOS",
|
||||||
"nacl" => "NaCl",
|
|
||||||
"netbsd" => "NetBSD",
|
"netbsd" => "NetBSD",
|
||||||
"openbsd" => "OpenBSD",
|
"openbsd" => "OpenBSD",
|
||||||
"redox" => "Redox",
|
"redox" => "Redox",
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::str;
|
use std::str;
|
||||||
use html::markdown::{Markdown, RenderType};
|
use html::markdown::{Markdown, RenderType};
|
||||||
|
@ -70,17 +69,13 @@ pub fn load_string<P: AsRef<Path>>(file_path: P) -> Result<String, LoadStringErr
|
||||||
let result = File::open(file_path)
|
let result = File::open(file_path)
|
||||||
.and_then(|mut f| f.read_to_end(&mut contents));
|
.and_then(|mut f| f.read_to_end(&mut contents));
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
let _ = writeln!(&mut io::stderr(),
|
eprintln!("error reading `{}`: {}", file_path.display(), e);
|
||||||
"error reading `{}`: {}",
|
|
||||||
file_path.display(), e);
|
|
||||||
return Err(LoadStringError::ReadFail);
|
return Err(LoadStringError::ReadFail);
|
||||||
}
|
}
|
||||||
match str::from_utf8(&contents) {
|
match str::from_utf8(&contents) {
|
||||||
Ok(s) => Ok(s.to_string()),
|
Ok(s) => Ok(s.to_string()),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let _ = writeln!(&mut io::stderr(),
|
eprintln!("error reading `{}`: not UTF-8", file_path.display());
|
||||||
"error reading `{}`: not UTF-8",
|
|
||||||
file_path.display());
|
|
||||||
Err(LoadStringError::BadUtf8)
|
Err(LoadStringError::BadUtf8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io;
|
|
||||||
use std::path::{PathBuf, Path};
|
use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
use getopts;
|
use getopts;
|
||||||
|
@ -75,9 +74,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
|
||||||
|
|
||||||
let mut out = match File::create(&output) {
|
let mut out = match File::create(&output) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _ = writeln!(&mut io::stderr(),
|
eprintln!("rustdoc: {}: {}", output.display(), e);
|
||||||
"rustdoc: {}: {}",
|
|
||||||
output.display(), e);
|
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
Ok(f) => f
|
Ok(f) => f
|
||||||
|
@ -85,10 +82,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
|
||||||
|
|
||||||
let (metadata, text) = extract_leading_metadata(&input_str);
|
let (metadata, text) = extract_leading_metadata(&input_str);
|
||||||
if metadata.is_empty() {
|
if metadata.is_empty() {
|
||||||
let _ = writeln!(
|
eprintln!("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`");
|
||||||
&mut io::stderr(),
|
|
||||||
"rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`"
|
|
||||||
);
|
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
let title = metadata[0];
|
let title = metadata[0];
|
||||||
|
@ -138,9 +132,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
|
||||||
|
|
||||||
match err {
|
match err {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _ = writeln!(&mut io::stderr(),
|
eprintln!("rustdoc: cannot write to `{}`: {}", output.display(), e);
|
||||||
"rustdoc: cannot write to `{}`: {}",
|
|
||||||
output.display(), e);
|
|
||||||
6
|
6
|
||||||
}
|
}
|
||||||
Ok(_) => 0
|
Ok(_) => 0
|
||||||
|
|
|
@ -495,8 +495,7 @@ impl Collector {
|
||||||
found = entry.remove_item(&test).is_some();
|
found = entry.remove_item(&test).is_some();
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
let _ = writeln!(&mut io::stderr(),
|
eprintln!("WARNING: {} Code block is not currently run as a test, but will \
|
||||||
"WARNING: {} Code block is not currently run as a test, but will \
|
|
||||||
in future versions of rustdoc. Please ensure this code block is \
|
in future versions of rustdoc. Please ensure this code block is \
|
||||||
a runnable test, or use the `ignore` directive.",
|
a runnable test, or use the `ignore` directive.",
|
||||||
name);
|
name);
|
||||||
|
|
|
@ -38,7 +38,6 @@ pub mod linux;
|
||||||
#[cfg(all(not(dox), target_os = "haiku"))] pub mod haiku;
|
#[cfg(all(not(dox), target_os = "haiku"))] pub mod haiku;
|
||||||
#[cfg(all(not(dox), target_os = "ios"))] pub mod ios;
|
#[cfg(all(not(dox), target_os = "ios"))] pub mod ios;
|
||||||
#[cfg(all(not(dox), target_os = "macos"))] pub mod macos;
|
#[cfg(all(not(dox), target_os = "macos"))] pub mod macos;
|
||||||
#[cfg(all(not(dox), target_os = "nacl"))] pub mod nacl;
|
|
||||||
#[cfg(all(not(dox), target_os = "netbsd"))] pub mod netbsd;
|
#[cfg(all(not(dox), target_os = "netbsd"))] pub mod netbsd;
|
||||||
#[cfg(all(not(dox), target_os = "openbsd"))] pub mod openbsd;
|
#[cfg(all(not(dox), target_os = "openbsd"))] pub mod openbsd;
|
||||||
#[cfg(all(not(dox), target_os = "solaris"))] pub mod solaris;
|
#[cfg(all(not(dox), target_os = "solaris"))] pub mod solaris;
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
#![stable(feature = "metadata_ext", since = "1.1.0")]
|
|
||||||
|
|
||||||
use libc;
|
|
||||||
|
|
||||||
use fs::Metadata;
|
|
||||||
use sys_common::AsInner;
|
|
||||||
|
|
||||||
#[allow(deprecated)]
|
|
||||||
use os::nacl::raw;
|
|
||||||
|
|
||||||
/// OS-specific extension methods for `fs::Metadata`
|
|
||||||
#[stable(feature = "metadata_ext", since = "1.1.0")]
|
|
||||||
pub trait MetadataExt {
|
|
||||||
/// Gain a reference to the underlying `stat` structure which contains
|
|
||||||
/// the raw information returned by the OS.
|
|
||||||
///
|
|
||||||
/// The contents of the returned `stat` are **not** consistent across
|
|
||||||
/// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
|
|
||||||
/// cross-Unix abstractions contained within the raw stat.
|
|
||||||
#[stable(feature = "metadata_ext", since = "1.1.0")]
|
|
||||||
#[rustc_deprecated(since = "1.8.0",
|
|
||||||
reason = "deprecated in favor of the accessor \
|
|
||||||
methods of this trait")]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
fn as_raw_stat(&self) -> &raw::stat;
|
|
||||||
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_dev(&self) -> u64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_ino(&self) -> u64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_mode(&self) -> u32;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_nlink(&self) -> u64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_uid(&self) -> u32;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_gid(&self) -> u32;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_rdev(&self) -> u64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_size(&self) -> u64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_atime(&self) -> i64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_atime_nsec(&self) -> i64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_mtime(&self) -> i64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_mtime_nsec(&self) -> i64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_ctime(&self) -> i64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_ctime_nsec(&self) -> i64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_blksize(&self) -> u64;
|
|
||||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
|
||||||
fn st_blocks(&self) -> u64;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "metadata_ext", since = "1.1.0")]
|
|
||||||
impl MetadataExt for Metadata {
|
|
||||||
#[allow(deprecated)]
|
|
||||||
fn as_raw_stat(&self) -> &raw::stat {
|
|
||||||
unsafe {
|
|
||||||
&*(self.as_inner().as_inner() as *const libc::stat64
|
|
||||||
as *const raw::stat)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn st_dev(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_dev as u64
|
|
||||||
}
|
|
||||||
fn st_ino(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_ino as u64
|
|
||||||
}
|
|
||||||
fn st_mode(&self) -> u32 {
|
|
||||||
self.as_inner().as_inner().st_mode as u32
|
|
||||||
}
|
|
||||||
fn st_nlink(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_nlink as u64
|
|
||||||
}
|
|
||||||
fn st_uid(&self) -> u32 {
|
|
||||||
self.as_inner().as_inner().st_uid as u32
|
|
||||||
}
|
|
||||||
fn st_gid(&self) -> u32 {
|
|
||||||
self.as_inner().as_inner().st_gid as u32
|
|
||||||
}
|
|
||||||
fn st_rdev(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_rdev as u64
|
|
||||||
}
|
|
||||||
fn st_size(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_size as u64
|
|
||||||
}
|
|
||||||
fn st_atime(&self) -> i64 {
|
|
||||||
self.as_inner().as_inner().st_atime as i64
|
|
||||||
}
|
|
||||||
fn st_atime_nsec(&self) -> i64 {
|
|
||||||
self.as_inner().as_inner().st_atime_nsec as i64
|
|
||||||
}
|
|
||||||
fn st_mtime(&self) -> i64 {
|
|
||||||
self.as_inner().as_inner().st_mtime as i64
|
|
||||||
}
|
|
||||||
fn st_mtime_nsec(&self) -> i64 {
|
|
||||||
self.as_inner().as_inner().st_mtime_nsec as i64
|
|
||||||
}
|
|
||||||
fn st_ctime(&self) -> i64 {
|
|
||||||
self.as_inner().as_inner().st_ctime as i64
|
|
||||||
}
|
|
||||||
fn st_ctime_nsec(&self) -> i64 {
|
|
||||||
self.as_inner().as_inner().st_ctime_nsec as i64
|
|
||||||
}
|
|
||||||
fn st_blksize(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_blksize as u64
|
|
||||||
}
|
|
||||||
fn st_blocks(&self) -> u64 {
|
|
||||||
self.as_inner().as_inner().st_blocks as u64
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
//! Nacl-specific raw type definitions
|
|
||||||
|
|
||||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
|
||||||
#![rustc_deprecated(since = "1.8.0",
|
|
||||||
reason = "these type aliases are no longer supported by \
|
|
||||||
the standard library, the `libc` crate on \
|
|
||||||
crates.io should be used instead for the correct \
|
|
||||||
definitions")]
|
|
||||||
#![allow(deprecated)]
|
|
||||||
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
|
|
||||||
|
|
||||||
#[stable(feature = "pthread_t", since = "1.8.0")]
|
|
||||||
pub type pthread_t = usize;
|
|
||||||
|
|
||||||
#[repr(C)]
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
|
||||||
pub struct stat {
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_dev: dev_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ino: ino_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mode: mode_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_nlink: nlink_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_uid: uid_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_gid: gid_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_rdev: dev_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_size: off_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_blksize: blksize_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_blocks: blkcnt_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime: time_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime_nsec: i64,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime: time_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime_nsec: i64,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime: time_t,
|
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime_nsec: i64,
|
|
||||||
}
|
|
|
@ -742,21 +742,128 @@ impl fmt::Debug for Output {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Describes what to do with a standard I/O stream for a child process.
|
/// Describes what to do with a standard I/O stream for a child process when
|
||||||
|
/// passed to the [`stdin`], [`stdout`], and [`stderr`] methods of [`Command`].
|
||||||
|
///
|
||||||
|
/// [`stdin`]: struct.Command.html#method.stdin
|
||||||
|
/// [`stdout`]: struct.Command.html#method.stdout
|
||||||
|
/// [`stderr`]: struct.Command.html#method.stderr
|
||||||
|
/// [`Command`]: struct.Command.html
|
||||||
#[stable(feature = "process", since = "1.0.0")]
|
#[stable(feature = "process", since = "1.0.0")]
|
||||||
pub struct Stdio(imp::Stdio);
|
pub struct Stdio(imp::Stdio);
|
||||||
|
|
||||||
impl Stdio {
|
impl Stdio {
|
||||||
/// A new pipe should be arranged to connect the parent and child processes.
|
/// A new pipe should be arranged to connect the parent and child processes.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// With stdout:
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// use std::process::{Command, Stdio};
|
||||||
|
///
|
||||||
|
/// let output = Command::new("echo")
|
||||||
|
/// .arg("Hello, world!")
|
||||||
|
/// .stdout(Stdio::piped())
|
||||||
|
/// .output()
|
||||||
|
/// .expect("Failed to execute command");
|
||||||
|
///
|
||||||
|
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "Hello, world!\n");
|
||||||
|
/// // Nothing echoed to console
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// With stdin:
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// use std::io::Write;
|
||||||
|
/// use std::process::{Command, Stdio};
|
||||||
|
///
|
||||||
|
/// let mut child = Command::new("rev")
|
||||||
|
/// .stdin(Stdio::piped())
|
||||||
|
/// .stdout(Stdio::piped())
|
||||||
|
/// .spawn()
|
||||||
|
/// .expect("Failed to spawn child process");
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let mut stdin = child.stdin.as_mut().expect("Failed to open stdin");
|
||||||
|
/// stdin.write_all("Hello, world!".as_bytes()).expect("Failed to write to stdin");
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let output = child.wait_with_output().expect("Failed to read stdout");
|
||||||
|
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH\n");
|
||||||
|
/// ```
|
||||||
#[stable(feature = "process", since = "1.0.0")]
|
#[stable(feature = "process", since = "1.0.0")]
|
||||||
pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) }
|
pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) }
|
||||||
|
|
||||||
/// The child inherits from the corresponding parent descriptor.
|
/// The child inherits from the corresponding parent descriptor.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// With stdout:
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// use std::process::{Command, Stdio};
|
||||||
|
///
|
||||||
|
/// let output = Command::new("echo")
|
||||||
|
/// .arg("Hello, world!")
|
||||||
|
/// .stdout(Stdio::inherit())
|
||||||
|
/// .output()
|
||||||
|
/// .expect("Failed to execute command");
|
||||||
|
///
|
||||||
|
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "");
|
||||||
|
/// // "Hello, world!" echoed to console
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// With stdin:
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// use std::process::{Command, Stdio};
|
||||||
|
///
|
||||||
|
/// let output = Command::new("rev")
|
||||||
|
/// .stdin(Stdio::inherit())
|
||||||
|
/// .stdout(Stdio::piped())
|
||||||
|
/// .output()
|
||||||
|
/// .expect("Failed to execute command");
|
||||||
|
///
|
||||||
|
/// println!("You piped in the reverse of: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
/// ```
|
||||||
#[stable(feature = "process", since = "1.0.0")]
|
#[stable(feature = "process", since = "1.0.0")]
|
||||||
pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) }
|
pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) }
|
||||||
|
|
||||||
/// This stream will be ignored. This is the equivalent of attaching the
|
/// This stream will be ignored. This is the equivalent of attaching the
|
||||||
/// stream to `/dev/null`
|
/// stream to `/dev/null`
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// With stdout:
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// use std::process::{Command, Stdio};
|
||||||
|
///
|
||||||
|
/// let output = Command::new("echo")
|
||||||
|
/// .arg("Hello, world!")
|
||||||
|
/// .stdout(Stdio::null())
|
||||||
|
/// .output()
|
||||||
|
/// .expect("Failed to execute command");
|
||||||
|
///
|
||||||
|
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "");
|
||||||
|
/// // Nothing echoed to console
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// With stdin:
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// use std::process::{Command, Stdio};
|
||||||
|
///
|
||||||
|
/// let output = Command::new("rev")
|
||||||
|
/// .stdin(Stdio::null())
|
||||||
|
/// .stdout(Stdio::piped())
|
||||||
|
/// .output()
|
||||||
|
/// .expect("Failed to execute command");
|
||||||
|
///
|
||||||
|
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "");
|
||||||
|
/// // Ignores any piped-in input
|
||||||
|
/// ```
|
||||||
#[stable(feature = "process", since = "1.0.0")]
|
#[stable(feature = "process", since = "1.0.0")]
|
||||||
pub fn null() -> Stdio { Stdio(imp::Stdio::Null) }
|
pub fn null() -> Stdio { Stdio(imp::Stdio::Null) }
|
||||||
}
|
}
|
||||||
|
@ -1083,8 +1190,6 @@ impl Child {
|
||||||
/// function and compute the exit code from its return value:
|
/// function and compute the exit code from its return value:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::io::{self, Write};
|
|
||||||
///
|
|
||||||
/// fn run_app() -> Result<(), ()> {
|
/// fn run_app() -> Result<(), ()> {
|
||||||
/// // Application logic here
|
/// // Application logic here
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
|
@ -1094,7 +1199,7 @@ impl Child {
|
||||||
/// ::std::process::exit(match run_app() {
|
/// ::std::process::exit(match run_app() {
|
||||||
/// Ok(_) => 0,
|
/// Ok(_) => 0,
|
||||||
/// Err(err) => {
|
/// Err(err) => {
|
||||||
/// writeln!(io::stderr(), "error: {:?}", err).unwrap();
|
/// eprintln!("error: {:?}", err);
|
||||||
/// 1
|
/// 1
|
||||||
/// }
|
/// }
|
||||||
/// });
|
/// });
|
||||||
|
|
|
@ -919,7 +919,7 @@ impl<T> Drop for Sender<T> {
|
||||||
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
||||||
impl<T> fmt::Debug for Sender<T> {
|
impl<T> fmt::Debug for Sender<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "Sender {{ .. }}")
|
f.debug_struct("Sender").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,7 +1049,7 @@ impl<T> Drop for SyncSender<T> {
|
||||||
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
||||||
impl<T> fmt::Debug for SyncSender<T> {
|
impl<T> fmt::Debug for SyncSender<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "SyncSender {{ .. }}")
|
f.debug_struct("SyncSender").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,7 +1551,7 @@ impl<T> Drop for Receiver<T> {
|
||||||
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
||||||
impl<T> fmt::Debug for Receiver<T> {
|
impl<T> fmt::Debug for Receiver<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "Receiver {{ .. }}")
|
f.debug_struct("Receiver").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3009,22 +3009,4 @@ mod sync_tests {
|
||||||
repro()
|
repro()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn fmt_debug_sender() {
|
|
||||||
let (tx, _) = channel::<i32>();
|
|
||||||
assert_eq!(format!("{:?}", tx), "Sender { .. }");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn fmt_debug_recv() {
|
|
||||||
let (_, rx) = channel::<i32>();
|
|
||||||
assert_eq!(format!("{:?}", rx), "Receiver { .. }");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn fmt_debug_sync_sender() {
|
|
||||||
let (tx, _) = sync_channel::<i32>(1);
|
|
||||||
assert_eq!(format!("{:?}", tx), "SyncSender { .. }");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,13 +354,13 @@ impl Iterator for Packets {
|
||||||
|
|
||||||
impl fmt::Debug for Select {
|
impl fmt::Debug for Select {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "Select {{ .. }}")
|
f.debug_struct("Select").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> {
|
impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "Handle {{ .. }}")
|
f.debug_struct("Handle").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,18 +774,4 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn fmt_debug_select() {
|
|
||||||
let sel = Select::new();
|
|
||||||
assert_eq!(format!("{:?}", sel), "Select { .. }");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn fmt_debug_handle() {
|
|
||||||
let (_, rx) = channel::<i32>();
|
|
||||||
let sel = Select::new();
|
|
||||||
let handle = sel.handle(&rx);
|
|
||||||
assert_eq!(format!("{:?}", handle), "Handle { .. }");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,11 +394,18 @@ impl<T: ?Sized + Default> Default for Mutex<T> {
|
||||||
impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
|
impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.try_lock() {
|
match self.try_lock() {
|
||||||
Ok(guard) => write!(f, "Mutex {{ data: {:?} }}", &*guard),
|
Ok(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(),
|
||||||
Err(TryLockError::Poisoned(err)) => {
|
Err(TryLockError::Poisoned(err)) => {
|
||||||
write!(f, "Mutex {{ data: Poisoned({:?}) }}", &**err.get_ref())
|
f.debug_struct("Mutex").field("data", &&**err.get_ref()).finish()
|
||||||
},
|
},
|
||||||
Err(TryLockError::WouldBlock) => write!(f, "Mutex {{ <locked> }}")
|
Err(TryLockError::WouldBlock) => {
|
||||||
|
struct LockedPlaceholder;
|
||||||
|
impl fmt::Debug for LockedPlaceholder {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
|
||||||
|
}
|
||||||
|
|
||||||
|
f.debug_struct("Mutex").field("data", &LockedPlaceholder).finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,11 +428,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> {
|
||||||
impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
|
impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.try_read() {
|
match self.try_read() {
|
||||||
Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", &*guard),
|
Ok(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(),
|
||||||
Err(TryLockError::Poisoned(err)) => {
|
Err(TryLockError::Poisoned(err)) => {
|
||||||
write!(f, "RwLock {{ data: Poisoned({:?}) }}", &**err.get_ref())
|
f.debug_struct("RwLock").field("data", &&**err.get_ref()).finish()
|
||||||
},
|
},
|
||||||
Err(TryLockError::WouldBlock) => write!(f, "RwLock {{ <locked> }}")
|
Err(TryLockError::WouldBlock) => {
|
||||||
|
struct LockedPlaceholder;
|
||||||
|
impl fmt::Debug for LockedPlaceholder {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
|
||||||
|
}
|
||||||
|
|
||||||
|
f.debug_struct("RwLock").field("data", &LockedPlaceholder).finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,27 +118,6 @@ pub mod os {
|
||||||
pub const EXE_EXTENSION: &'static str = "";
|
pub const EXE_EXTENSION: &'static str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "nacl", not(target_arch = "le32")))]
|
|
||||||
pub mod os {
|
|
||||||
pub const FAMILY: &'static str = "unix";
|
|
||||||
pub const OS: &'static str = "nacl";
|
|
||||||
pub const DLL_PREFIX: &'static str = "lib";
|
|
||||||
pub const DLL_SUFFIX: &'static str = ".so";
|
|
||||||
pub const DLL_EXTENSION: &'static str = "so";
|
|
||||||
pub const EXE_SUFFIX: &'static str = ".nexe";
|
|
||||||
pub const EXE_EXTENSION: &'static str = "nexe";
|
|
||||||
}
|
|
||||||
#[cfg(all(target_os = "nacl", target_arch = "le32"))]
|
|
||||||
pub mod os {
|
|
||||||
pub const FAMILY: &'static str = "unix";
|
|
||||||
pub const OS: &'static str = "pnacl";
|
|
||||||
pub const DLL_PREFIX: &'static str = "lib";
|
|
||||||
pub const DLL_SUFFIX: &'static str = ".pso";
|
|
||||||
pub const DLL_EXTENSION: &'static str = "pso";
|
|
||||||
pub const EXE_SUFFIX: &'static str = ".pexe";
|
|
||||||
pub const EXE_EXTENSION: &'static str = "pexe";
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "haiku")]
|
#[cfg(target_os = "haiku")]
|
||||||
pub mod os {
|
pub mod os {
|
||||||
pub const FAMILY: &'static str = "unix";
|
pub const FAMILY: &'static str = "unix";
|
||||||
|
|
|
@ -22,7 +22,6 @@ use libc;
|
||||||
#[cfg(all(not(dox), target_os = "haiku"))] pub use os::haiku as platform;
|
#[cfg(all(not(dox), target_os = "haiku"))] pub use os::haiku as platform;
|
||||||
#[cfg(all(not(dox), target_os = "ios"))] pub use os::ios as platform;
|
#[cfg(all(not(dox), target_os = "ios"))] pub use os::ios as platform;
|
||||||
#[cfg(all(not(dox), target_os = "macos"))] pub use os::macos as platform;
|
#[cfg(all(not(dox), target_os = "macos"))] pub use os::macos as platform;
|
||||||
#[cfg(all(not(dox), target_os = "nacl"))] pub use os::nacl as platform;
|
|
||||||
#[cfg(all(not(dox), target_os = "netbsd"))] pub use os::netbsd as platform;
|
#[cfg(all(not(dox), target_os = "netbsd"))] pub use os::netbsd as platform;
|
||||||
#[cfg(all(not(dox), target_os = "openbsd"))] pub use os::openbsd as platform;
|
#[cfg(all(not(dox), target_os = "openbsd"))] pub use os::openbsd as platform;
|
||||||
#[cfg(all(not(dox), target_os = "solaris"))] pub use os::solaris as platform;
|
#[cfg(all(not(dox), target_os = "solaris"))] pub use os::solaris as platform;
|
||||||
|
@ -77,11 +76,11 @@ pub fn init() {
|
||||||
reset_sigpipe();
|
reset_sigpipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "nacl", target_os = "emscripten", target_os="fuchsia")))]
|
#[cfg(not(any(target_os = "emscripten", target_os="fuchsia")))]
|
||||||
unsafe fn reset_sigpipe() {
|
unsafe fn reset_sigpipe() {
|
||||||
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
|
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "nacl", target_os = "emscripten", target_os="fuchsia"))]
|
#[cfg(any(target_os = "emscripten", target_os="fuchsia"))]
|
||||||
unsafe fn reset_sigpipe() {}
|
unsafe fn reset_sigpipe() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,12 +483,10 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||||
|
|
||||||
#[cfg(any(target_os = "android",
|
#[cfg(any(target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
target_os = "nacl",
|
|
||||||
target_os = "emscripten"))]
|
target_os = "emscripten"))]
|
||||||
unsafe fn fallback() -> Option<OsString> { None }
|
unsafe fn fallback() -> Option<OsString> { None }
|
||||||
#[cfg(not(any(target_os = "android",
|
#[cfg(not(any(target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
target_os = "nacl",
|
|
||||||
target_os = "emscripten")))]
|
target_os = "emscripten")))]
|
||||||
unsafe fn fallback() -> Option<OsString> {
|
unsafe fn fallback() -> Option<OsString> {
|
||||||
let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {
|
let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {
|
||||||
|
|
|
@ -464,7 +464,6 @@ mod tests {
|
||||||
// test from being flaky we ignore it on macOS.
|
// test from being flaky we ignore it on macOS.
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "macos", ignore)]
|
#[cfg_attr(target_os = "macos", ignore)]
|
||||||
#[cfg_attr(target_os = "nacl", ignore)] // no signals on NaCl.
|
|
||||||
// When run under our current QEMU emulation test suite this test fails,
|
// When run under our current QEMU emulation test suite this test fails,
|
||||||
// although the reason isn't very clear as to why. For now this test is
|
// although the reason isn't very clear as to why. For now this test is
|
||||||
// ignored there.
|
// ignored there.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use io;
|
use io;
|
||||||
use libc;
|
use libc::{self, size_t};
|
||||||
use mem;
|
use mem;
|
||||||
use ptr;
|
use ptr;
|
||||||
|
|
||||||
|
@ -148,8 +148,8 @@ impl Process {
|
||||||
use sys::process::zircon::*;
|
use sys::process::zircon::*;
|
||||||
|
|
||||||
let mut proc_info: zx_info_process_t = Default::default();
|
let mut proc_info: zx_info_process_t = Default::default();
|
||||||
let mut actual: zx_size_t = 0;
|
let mut actual: size_t = 0;
|
||||||
let mut avail: zx_size_t = 0;
|
let mut avail: size_t = 0;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
|
zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
|
||||||
|
@ -171,8 +171,8 @@ impl Process {
|
||||||
use sys::process::zircon::*;
|
use sys::process::zircon::*;
|
||||||
|
|
||||||
let mut proc_info: zx_info_process_t = Default::default();
|
let mut proc_info: zx_info_process_t = Default::default();
|
||||||
let mut actual: zx_size_t = 0;
|
let mut actual: size_t = 0;
|
||||||
let mut avail: zx_size_t = 0;
|
let mut avail: size_t = 0;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
|
let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
|
||||||
|
|
|
@ -184,8 +184,8 @@ impl Command {
|
||||||
*sys::os::environ() = envp.as_ptr();
|
*sys::os::environ() = envp.as_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NaCl has no signal support.
|
// emscripten has no signal support.
|
||||||
#[cfg(not(any(target_os = "nacl", target_os = "emscripten")))]
|
#[cfg(not(any(target_os = "emscripten")))]
|
||||||
{
|
{
|
||||||
use mem;
|
use mem;
|
||||||
// Reset signal handling so the child process starts in a
|
// Reset signal handling so the child process starts in a
|
||||||
|
|
|
@ -15,15 +15,13 @@ use io;
|
||||||
use os::raw::c_char;
|
use os::raw::c_char;
|
||||||
use u64;
|
use u64;
|
||||||
|
|
||||||
use libc::{c_int, c_void};
|
use libc::{c_int, c_void, size_t};
|
||||||
|
|
||||||
pub type zx_handle_t = i32;
|
pub type zx_handle_t = u32;
|
||||||
pub type zx_vaddr_t = usize;
|
pub type zx_vaddr_t = usize;
|
||||||
pub type zx_rights_t = u32;
|
pub type zx_rights_t = u32;
|
||||||
pub type zx_status_t = i32;
|
pub type zx_status_t = i32;
|
||||||
|
|
||||||
pub type zx_size_t = usize;
|
|
||||||
|
|
||||||
pub const ZX_HANDLE_INVALID: zx_handle_t = 0;
|
pub const ZX_HANDLE_INVALID: zx_handle_t = 0;
|
||||||
|
|
||||||
pub type zx_time_t = u64;
|
pub type zx_time_t = u64;
|
||||||
|
@ -115,36 +113,37 @@ extern {
|
||||||
pending: *mut zx_signals_t) -> zx_status_t;
|
pending: *mut zx_signals_t) -> zx_status_t;
|
||||||
|
|
||||||
pub fn zx_object_get_info(handle: zx_handle_t, topic: u32, buffer: *mut c_void,
|
pub fn zx_object_get_info(handle: zx_handle_t, topic: u32, buffer: *mut c_void,
|
||||||
buffer_size: zx_size_t, actual_size: *mut zx_size_t,
|
buffer_size: size_t, actual_size: *mut size_t,
|
||||||
avail: *mut zx_size_t) -> zx_status_t;
|
avail: *mut size_t) -> zx_status_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// From `enum special_handles` in system/ulib/launchpad/launchpad.c
|
// From `enum special_handles` in system/ulib/launchpad/launchpad.c
|
||||||
// HND_LOADER_SVC = 0
|
// HND_LOADER_SVC = 0
|
||||||
// HND_EXEC_VMO = 1
|
// HND_EXEC_VMO = 1
|
||||||
pub const HND_SPECIAL_COUNT: usize = 2;
|
// HND_SEGMENTS_VMAR = 2
|
||||||
|
const HND_SPECIAL_COUNT: c_int = 3;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct launchpad_t {
|
pub struct launchpad_t {
|
||||||
argc: u32,
|
argc: u32,
|
||||||
envc: u32,
|
envc: u32,
|
||||||
args: *const c_char,
|
args: *const c_char,
|
||||||
args_len: usize,
|
args_len: size_t,
|
||||||
env: *const c_char,
|
env: *const c_char,
|
||||||
env_len: usize,
|
env_len: size_t,
|
||||||
|
|
||||||
handles: *mut zx_handle_t,
|
handles: *mut zx_handle_t,
|
||||||
handles_info: *mut u32,
|
handles_info: *mut u32,
|
||||||
handle_count: usize,
|
handle_count: size_t,
|
||||||
handle_alloc: usize,
|
handle_alloc: size_t,
|
||||||
|
|
||||||
entry: zx_vaddr_t,
|
entry: zx_vaddr_t,
|
||||||
base: zx_vaddr_t,
|
base: zx_vaddr_t,
|
||||||
vdso_base: zx_vaddr_t,
|
vdso_base: zx_vaddr_t,
|
||||||
|
|
||||||
stack_size: usize,
|
stack_size: size_t,
|
||||||
|
|
||||||
special_handles: [zx_handle_t; HND_SPECIAL_COUNT],
|
special_handles: [zx_handle_t; HND_SPECIAL_COUNT as usize],
|
||||||
loader_message: bool,
|
loader_message: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![cfg_attr(target_os = "nacl", allow(dead_code))]
|
|
||||||
|
|
||||||
/// Common code for printing the backtrace in the same way across the different
|
/// Common code for printing the backtrace in the same way across the different
|
||||||
/// supported platforms.
|
/// supported platforms.
|
||||||
|
|
||||||
|
|
|
@ -116,11 +116,18 @@ impl<T> Drop for ReentrantMutex<T> {
|
||||||
impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
|
impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.try_lock() {
|
match self.try_lock() {
|
||||||
Ok(guard) => write!(f, "ReentrantMutex {{ data: {:?} }}", &*guard),
|
Ok(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(),
|
||||||
Err(TryLockError::Poisoned(err)) => {
|
Err(TryLockError::Poisoned(err)) => {
|
||||||
write!(f, "ReentrantMutex {{ data: Poisoned({:?}) }}", &**err.get_ref())
|
f.debug_struct("ReentrantMutex").field("data", &**err.get_ref()).finish()
|
||||||
},
|
},
|
||||||
Err(TryLockError::WouldBlock) => write!(f, "ReentrantMutex {{ <locked> }}")
|
Err(TryLockError::WouldBlock) => {
|
||||||
|
struct LockedPlaceholder;
|
||||||
|
impl fmt::Debug for LockedPlaceholder {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
|
||||||
|
}
|
||||||
|
|
||||||
|
f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,15 +485,17 @@ impl Builder {
|
||||||
/// let (tx, rx) = channel();
|
/// let (tx, rx) = channel();
|
||||||
///
|
///
|
||||||
/// let sender = thread::spawn(move || {
|
/// let sender = thread::spawn(move || {
|
||||||
/// let _ = tx.send("Hello, thread".to_owned());
|
/// tx.send("Hello, thread".to_owned())
|
||||||
|
/// .expect("Unable to send on channel");
|
||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// let receiver = thread::spawn(move || {
|
/// let receiver = thread::spawn(move || {
|
||||||
/// println!("{}", rx.recv().unwrap());
|
/// let value = rx.recv().expect("Unable to receive from channel");
|
||||||
|
/// println!("{}", value);
|
||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// let _ = sender.join();
|
/// sender.join().expect("The sender thread has panicked");
|
||||||
/// let _ = receiver.join();
|
/// receiver.join().expect("The receiver thread has panicked");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// A thread can also return a value through its [`JoinHandle`], you can use
|
/// A thread can also return a value through its [`JoinHandle`], you can use
|
||||||
|
@ -1192,7 +1194,7 @@ impl<T> JoinInner<T> {
|
||||||
/// });
|
/// });
|
||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// let _ = original_thread.join();
|
/// original_thread.join().expect("The thread being joined has panicked");
|
||||||
/// println!("Original thread is joined.");
|
/// println!("Original thread is joined.");
|
||||||
///
|
///
|
||||||
/// // We make sure that the new thread has time to run, before the main
|
/// // We make sure that the new thread has time to run, before the main
|
||||||
|
|
|
@ -2890,17 +2890,30 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
match self.parse_path(PathStyle::Expr) {
|
match self.parse_path(PathStyle::Expr) {
|
||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
|
let (op_noun, op_verb) = match self.token {
|
||||||
|
token::Lt => ("comparison", "comparing"),
|
||||||
|
token::BinOp(token::Shl) => ("shift", "shifting"),
|
||||||
|
_ => {
|
||||||
|
// We can end up here even without `<` being the next token, for
|
||||||
|
// example because `parse_ty_no_plus` returns `Err` on keywords,
|
||||||
|
// but `parse_path` returns `Ok` on them due to error recovery.
|
||||||
|
// Return original error and parser state.
|
||||||
|
mem::replace(self, parser_snapshot_after_type);
|
||||||
|
return Err(type_err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Successfully parsed the type path leaving a `<` yet to parse.
|
// Successfully parsed the type path leaving a `<` yet to parse.
|
||||||
type_err.cancel();
|
type_err.cancel();
|
||||||
|
|
||||||
// Report non-fatal diagnostics, keep `x as usize` as an expression
|
// Report non-fatal diagnostics, keep `x as usize` as an expression
|
||||||
// in AST and continue parsing.
|
// in AST and continue parsing.
|
||||||
let msg = format!("`<` is interpreted as a start of generic \
|
let msg = format!("`<` is interpreted as a start of generic \
|
||||||
arguments for `{}`, not a comparison", path);
|
arguments for `{}`, not a {}", path, op_noun);
|
||||||
let mut err = self.sess.span_diagnostic.struct_span_err(self.span, &msg);
|
let mut err = self.sess.span_diagnostic.struct_span_err(self.span, &msg);
|
||||||
err.span_label(self.look_ahead_span(1).to(parser_snapshot_after_type.span),
|
err.span_label(self.look_ahead_span(1).to(parser_snapshot_after_type.span),
|
||||||
"interpreted as generic arguments");
|
"interpreted as generic arguments");
|
||||||
err.span_label(self.span, "not interpreted as comparison");
|
err.span_label(self.span, format!("not interpreted as {}", op_noun));
|
||||||
|
|
||||||
let expr = mk_expr(self, P(Ty {
|
let expr = mk_expr(self, P(Ty {
|
||||||
span: path.span,
|
span: path.span,
|
||||||
|
@ -2911,7 +2924,7 @@ impl<'a> Parser<'a> {
|
||||||
let expr_str = self.sess.codemap().span_to_snippet(expr.span)
|
let expr_str = self.sess.codemap().span_to_snippet(expr.span)
|
||||||
.unwrap_or(pprust::expr_to_string(&expr));
|
.unwrap_or(pprust::expr_to_string(&expr));
|
||||||
err.span_suggestion(expr.span,
|
err.span_suggestion(expr.span,
|
||||||
"try comparing the casted value",
|
&format!("try {} the casted value", op_verb),
|
||||||
format!("({})", expr_str));
|
format!("({})", expr_str));
|
||||||
err.emit();
|
err.emit();
|
||||||
|
|
||||||
|
|
|
@ -339,8 +339,11 @@ impl serialize::UseSpecializedDecodable for Span {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
|
fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "Span {{ lo: {:?}, hi: {:?}, ctxt: {:?} }}",
|
f.debug_struct("Span")
|
||||||
span.lo(), span.hi(), span.ctxt())
|
.field("lo", &span.lo())
|
||||||
|
.field("hi", &span.hi())
|
||||||
|
.field("ctxt", &span.ctxt())
|
||||||
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Span {
|
impl fmt::Debug for Span {
|
||||||
|
|
|
@ -1554,16 +1554,14 @@ impl MetricMap {
|
||||||
/// elimination.
|
/// elimination.
|
||||||
///
|
///
|
||||||
/// This function is a no-op, and does not even read from `dummy`.
|
/// This function is a no-op, and does not even read from `dummy`.
|
||||||
#[cfg(not(any(all(target_os = "nacl", target_arch = "le32"),
|
#[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))]
|
||||||
target_arch = "asmjs", target_arch = "wasm32")))]
|
|
||||||
pub fn black_box<T>(dummy: T) -> T {
|
pub fn black_box<T>(dummy: T) -> T {
|
||||||
// we need to "use" the argument in some way LLVM can't
|
// we need to "use" the argument in some way LLVM can't
|
||||||
// introspect.
|
// introspect.
|
||||||
unsafe { asm!("" : : "r"(&dummy)) }
|
unsafe { asm!("" : : "r"(&dummy)) }
|
||||||
dummy
|
dummy
|
||||||
}
|
}
|
||||||
#[cfg(any(all(target_os = "nacl", target_arch = "le32"),
|
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))]
|
||||||
target_arch = "asmjs", target_arch = "wasm32"))]
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn black_box<T>(dummy: T) -> T {
|
pub fn black_box<T>(dummy: T) -> T {
|
||||||
dummy
|
dummy
|
||||||
|
|
|
@ -57,7 +57,7 @@ static AtomicOrdering fromRust(LLVMAtomicOrdering Ordering) {
|
||||||
llvm_unreachable("Invalid LLVMAtomicOrdering value!");
|
llvm_unreachable("Invalid LLVMAtomicOrdering value!");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *LastError;
|
static LLVM_THREAD_LOCAL char *LastError;
|
||||||
|
|
||||||
extern "C" LLVMMemoryBufferRef
|
extern "C" LLVMMemoryBufferRef
|
||||||
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
|
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic0[Internal]
|
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic0[Internal]
|
||||||
struct StructWithDtor(u32);
|
struct StructWithDtor(u32);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// compile-flags:-Zprint-trans-items=eager
|
// compile-flags:-Zprint-trans-items=eager
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
#![feature(coerce_unsized)]
|
#![feature(coerce_unsized)]
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// We specify -Z incremental here because we want to test the partitioning for
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
// incremental compilation
|
// incremental compilation
|
||||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/extern-drop-glue
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/extern-drop-glue
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type="lib"]
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// We specify -Z incremental here because we want to test the partitioning for
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
// incremental compilation
|
// incremental compilation
|
||||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/inlining-from-extern-crate
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/inlining-from-extern-crate
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![crate_type="lib"]
|
#![crate_type="lib"]
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// We specify -Z incremental here because we want to test the partitioning for
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
// incremental compilation
|
// incremental compilation
|
||||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-drop-glue
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-drop-glue
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type="lib"]
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// ignore-tidy-linelength
|
||||||
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
|
// incremental compilation
|
||||||
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-inlining-but-not-all
|
||||||
|
// compile-flags:-Zinline-in-all-cgus=no
|
||||||
|
|
||||||
|
#![allow(dead_code)]
|
||||||
|
#![crate_type="lib"]
|
||||||
|
|
||||||
|
mod inline {
|
||||||
|
|
||||||
|
//~ TRANS_ITEM fn local_inlining_but_not_all::inline[0]::inlined_function[0] @@ local_inlining_but_not_all-inline[External]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn inlined_function()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod user1 {
|
||||||
|
use super::inline;
|
||||||
|
|
||||||
|
//~ TRANS_ITEM fn local_inlining_but_not_all::user1[0]::foo[0] @@ local_inlining_but_not_all-user1[Internal]
|
||||||
|
fn foo() {
|
||||||
|
inline::inlined_function();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod user2 {
|
||||||
|
use super::inline;
|
||||||
|
|
||||||
|
//~ TRANS_ITEM fn local_inlining_but_not_all::user2[0]::bar[0] @@ local_inlining_but_not_all-user2[Internal]
|
||||||
|
fn bar() {
|
||||||
|
inline::inlined_function();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod non_user {
|
||||||
|
|
||||||
|
//~ TRANS_ITEM fn local_inlining_but_not_all::non_user[0]::baz[0] @@ local_inlining_but_not_all-non_user[Internal]
|
||||||
|
fn baz() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@
|
||||||
// We specify -Z incremental here because we want to test the partitioning for
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
// incremental compilation
|
// incremental compilation
|
||||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-inlining
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-inlining
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type="lib"]
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// We specify -Z incremental here because we want to test the partitioning for
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
// incremental compilation
|
// incremental compilation
|
||||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-transitive-inlining
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-transitive-inlining
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type="lib"]
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// We specify -Z incremental here because we want to test the partitioning for
|
// We specify -Z incremental here because we want to test the partitioning for
|
||||||
// incremental compilation
|
// incremental compilation
|
||||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/vtable-through-const
|
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/vtable-through-const
|
||||||
|
// compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
// This test case makes sure, that references made through constants are
|
// This test case makes sure, that references made through constants are
|
||||||
// recorded properly in the InliningMap.
|
// recorded properly in the InliningMap.
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn add(x: f32, y: f32) -> f32 {
|
pub fn add(x: f32, y: f32) -> f32 {
|
||||||
// CHECK: fadd float
|
// CHECK: fadd float
|
||||||
// CHECK-NOT fast
|
// CHECK-NOT: fast
|
||||||
x + y
|
x + y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags: -Zincremental=tmp/cfail-tests/incr_comp_with_macro_export
|
// revisions: cfail1 cfail2 cfail3
|
||||||
// must-compile-successfully
|
// must-compile-successfully
|
||||||
|
|
||||||
|
|
||||||
// This test case makes sure that we can compile with incremental compilation
|
// This test case makes sure that we can compile with incremental compilation
|
||||||
// enabled when there are macros exported from this crate. (See #37756)
|
// enabled when there are macros exported from this crate. (See #37756)
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
// error-pattern:panic 1
|
// error-pattern:panic 1
|
||||||
// error-pattern:drop 2
|
// error-pattern:drop 2
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
struct Droppable(u32);
|
struct Droppable(u32);
|
||||||
impl Drop for Droppable {
|
impl Drop for Droppable {
|
||||||
|
@ -18,7 +17,7 @@ impl Drop for Droppable {
|
||||||
if self.0 == 1 {
|
if self.0 == 1 {
|
||||||
panic!("panic 1");
|
panic!("panic 1");
|
||||||
} else {
|
} else {
|
||||||
write!(io::stderr(), "drop {}", self.0);
|
eprint!("drop {}", self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
// error-pattern:drop 1
|
// error-pattern:drop 1
|
||||||
// error-pattern:drop 2
|
// error-pattern:drop 2
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
|
|
||||||
/// Structure which will not allow to be dropped twice.
|
/// Structure which will not allow to be dropped twice.
|
||||||
|
@ -17,10 +16,10 @@ struct Droppable<'a>(&'a mut bool, u32);
|
||||||
impl<'a> Drop for Droppable<'a> {
|
impl<'a> Drop for Droppable<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if *self.0 {
|
if *self.0 {
|
||||||
writeln!(io::stderr(), "{} dropped twice", self.1);
|
eprintln!("{} dropped twice", self.1);
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
}
|
}
|
||||||
writeln!(io::stderr(), "drop {}", self.1);
|
eprintln!("drop {}", self.1);
|
||||||
*self.0 = true;
|
*self.0 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// error-pattern:drop 1
|
// error-pattern:drop 1
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
|
|
||||||
/// Structure which will not allow to be dropped twice.
|
/// Structure which will not allow to be dropped twice.
|
||||||
|
@ -17,10 +16,10 @@ struct Droppable<'a>(&'a mut bool, u32);
|
||||||
impl<'a> Drop for Droppable<'a> {
|
impl<'a> Drop for Droppable<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if *self.0 {
|
if *self.0 {
|
||||||
writeln!(io::stderr(), "{} dropped twice", self.1);
|
eprintln!("{} dropped twice", self.1);
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
}
|
}
|
||||||
writeln!(io::stderr(), "drop {}", self.1);
|
eprintln!("drop {}", self.1);
|
||||||
*self.0 = true;
|
*self.0 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// error-pattern:drop 3
|
// error-pattern:drop 3
|
||||||
// error-pattern:drop 2
|
// error-pattern:drop 2
|
||||||
// error-pattern:drop 1
|
// error-pattern:drop 1
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
|
|
||||||
/// Structure which will not allow to be dropped twice.
|
/// Structure which will not allow to be dropped twice.
|
||||||
|
@ -20,10 +19,10 @@ struct Droppable<'a>(&'a mut bool, u32);
|
||||||
impl<'a> Drop for Droppable<'a> {
|
impl<'a> Drop for Droppable<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if *self.0 {
|
if *self.0 {
|
||||||
writeln!(io::stderr(), "{} dropped twice", self.1);
|
eprintln!("{} dropped twice", self.1);
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
}
|
}
|
||||||
writeln!(io::stderr(), "drop {}", self.1);
|
eprintln!("drop {}", self.1);
|
||||||
*self.0 = true;
|
*self.0 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,15 @@
|
||||||
// error-pattern:0 dropped
|
// error-pattern:0 dropped
|
||||||
// error-pattern:exit
|
// error-pattern:exit
|
||||||
|
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
struct Droppable(u8);
|
struct Droppable(u8);
|
||||||
impl Drop for Droppable {
|
impl Drop for Droppable {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
write!(io::stderr(), "{} dropped\n", self.0);
|
eprintln!("{} dropped", self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn converging_fn() {
|
fn converging_fn() {
|
||||||
write!(io::stderr(), "converging_fn called\n");
|
eprintln!("converging_fn called");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mir(d: Droppable) {
|
fn mir(d: Droppable) {
|
||||||
|
|
|
@ -12,18 +12,16 @@
|
||||||
// error-pattern:dropped
|
// error-pattern:dropped
|
||||||
// error-pattern:exit
|
// error-pattern:exit
|
||||||
|
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
struct Droppable;
|
struct Droppable;
|
||||||
impl Drop for Droppable {
|
impl Drop for Droppable {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
write!(io::stderr(), "dropped\n");
|
eprintln!("dropped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return value of this function is copied into the return slot
|
// return value of this function is copied into the return slot
|
||||||
fn complex() -> u64 {
|
fn complex() -> u64 {
|
||||||
write!(io::stderr(), "complex called\n");
|
eprintln!("complex called");
|
||||||
42
|
42
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,10 @@
|
||||||
// error-pattern:diverging_fn called
|
// error-pattern:diverging_fn called
|
||||||
// error-pattern:0 dropped
|
// error-pattern:0 dropped
|
||||||
|
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
struct Droppable(u8);
|
struct Droppable(u8);
|
||||||
impl Drop for Droppable {
|
impl Drop for Droppable {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
write!(io::stderr(), "{} dropped", self.0);
|
eprintln!("{} dropped", self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,10 @@
|
||||||
#![feature(panic_handler)]
|
#![feature(panic_handler)]
|
||||||
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
panic::set_hook(Box::new(|i| {
|
panic::set_hook(Box::new(|i| {
|
||||||
write!(io::stderr(), "greetings from the panic handler");
|
eprint!("greetings from the panic handler");
|
||||||
}));
|
}));
|
||||||
panic!("foobar");
|
panic!("foobar");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,10 @@
|
||||||
#![feature(panic_handler)]
|
#![feature(panic_handler)]
|
||||||
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
panic::set_hook(Box::new(|i| {
|
panic::set_hook(Box::new(|i| {
|
||||||
write!(io::stderr(), "greetings from the panic handler");
|
eprint!("greetings from the panic handler");
|
||||||
}));
|
}));
|
||||||
panic::take_hook();
|
panic::take_hook();
|
||||||
panic!("foobar");
|
panic!("foobar");
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) cci_lib.rs
|
$(RUSTC) cci_lib.rs
|
||||||
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
|
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \
|
||||||
|
-Z inline-in-all-cgus
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ]
|
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ]
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
# in only one compilation unit.
|
# in only one compilation unit.
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
|
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \
|
||||||
|
-Z inline-in-all-cgus
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ]
|
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ]
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ]
|
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ]
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ]
|
[ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ]
|
||||||
|
|
|
@ -5,5 +5,5 @@ all:
|
||||||
$(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | grep -q "Error loading target specification"
|
$(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | grep -q "Error loading target specification"
|
||||||
$(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | grep 'Field llvm-target'
|
$(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | grep 'Field llvm-target'
|
||||||
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
|
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
|
||||||
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=x86_64-unknown-linux-gnu --crate-type=lib --emit=asm
|
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
|
||||||
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
|
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"pre-link-args": ["-m64"],
|
"pre-link-args": ["-m64"],
|
||||||
"data-layout": "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128",
|
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
||||||
"linker-flavor": "gcc",
|
"linker-flavor": "gcc",
|
||||||
"llvm-target": "x86_64-unknown-linux-gnu",
|
"llvm-target": "x86_64-unknown-linux-gnu",
|
||||||
"target-endian": "little",
|
"target-endian": "little",
|
|
@ -19,8 +19,6 @@
|
||||||
// ignore-pretty issue #37195
|
// ignore-pretty issue #37195
|
||||||
// ignore-emscripten spawning processes is not supported
|
// ignore-emscripten spawning processes is not supported
|
||||||
|
|
||||||
use std::io;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
#[path = "backtrace-debuginfo-aux.rs"] mod aux;
|
#[path = "backtrace-debuginfo-aux.rs"] mod aux;
|
||||||
|
@ -163,7 +161,7 @@ fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
if args.len() >= 2 {
|
if args.len() >= 2 {
|
||||||
let case = args[1].parse().unwrap();
|
let case = args[1].parse().unwrap();
|
||||||
writeln!(&mut io::stderr(), "test case {}", case).unwrap();
|
eprintln!("test case {}", case);
|
||||||
outer(case, pos!());
|
outer(case, pos!());
|
||||||
println!("done.");
|
println!("done.");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -35,5 +35,7 @@ fn main() {
|
||||||
<
|
<
|
||||||
5);
|
5);
|
||||||
|
|
||||||
|
println!("{}", a as usize << long_name);
|
||||||
|
|
||||||
println!("{}", a: &mut 4);
|
println!("{}", a: &mut 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,18 @@ help: try comparing the casted value
|
||||||
33 |
|
33 |
|
||||||
...
|
...
|
||||||
|
|
||||||
error: expected type, found `4`
|
error: `<` is interpreted as a start of generic arguments for `usize`, not a shift
|
||||||
--> $DIR/issue-22644.rs:38:28
|
--> $DIR/issue-22644.rs:38:31
|
||||||
|
|
|
|
||||||
38 | println!("{}", a: &mut 4);
|
38 | println!("{}", a as usize << long_name);
|
||||||
|
| ---------- ^^ --------- interpreted as generic arguments
|
||||||
|
| | |
|
||||||
|
| | not interpreted as shift
|
||||||
|
| help: try shifting the casted value: `(a as usize)`
|
||||||
|
|
||||||
|
error: expected type, found `4`
|
||||||
|
--> $DIR/issue-22644.rs:40:28
|
||||||
|
|
|
||||||
|
40 | println!("{}", a: &mut 4);
|
||||||
| ^ expecting a type here because of type ascription
|
| ^ expecting a type here because of type ascription
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
|
@ -8,9 +8,12 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
//! Nacl-specific definitions
|
macro_rules! foo {
|
||||||
|
($rest: tt) => {
|
||||||
|
bar(baz: $rest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
fn main() {
|
||||||
|
foo!(true);
|
||||||
pub mod raw;
|
}
|
||||||
pub mod fs;
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
error: expected identifier, found keyword `true`
|
||||||
|
--> $DIR/issue-44406.rs:18:10
|
||||||
|
|
|
||||||
|
18 | foo!(true);
|
||||||
|
| ^^^^
|
||||||
|
|
||||||
|
error: expected type, found keyword `true`
|
||||||
|
--> $DIR/issue-44406.rs:18:10
|
||||||
|
|
|
||||||
|
13 | bar(baz: $rest)
|
||||||
|
| - help: did you mean to use `;` here?
|
||||||
|
...
|
||||||
|
18 | foo!(true);
|
||||||
|
| ^^^^ expecting a type here because of type ascription
|
||||||
|
|
||||||
|
error: expected one of `!`, `&&`, `&`, `(`, `*`, `.`, `;`, `<`, `?`, `[`, `_`, `extern`, `fn`, `for`, `impl`, `unsafe`, `}`, an operator, or lifetime, found `true`
|
||||||
|
--> $DIR/issue-44406.rs:18:10
|
||||||
|
|
|
||||||
|
13 | bar(baz: $rest)
|
||||||
|
| - expected one of 19 possible tokens here
|
||||||
|
...
|
||||||
|
18 | foo!(true);
|
||||||
|
| ^^^^ unexpected token
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
|
@ -567,6 +567,19 @@ impl Config {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find_rust_src_root(&self) -> Option<PathBuf> {
|
||||||
|
let mut path = self.src_base.clone();
|
||||||
|
let path_postfix = Path::new("src/etc/lldb_batchmode.py");
|
||||||
|
|
||||||
|
while path.pop() {
|
||||||
|
if path.join(&path_postfix).is_file() {
|
||||||
|
return Some(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lldb_version_to_int(version_string: &str) -> isize {
|
pub fn lldb_version_to_int(version_string: &str) -> isize {
|
||||||
|
|
|
@ -489,15 +489,28 @@ fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> bool {
|
fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> bool {
|
||||||
|
let rust_src_dir = config.find_rust_src_root().expect(
|
||||||
|
"Could not find Rust source root",
|
||||||
|
);
|
||||||
let stamp = mtime(&stamp(config, testpaths));
|
let stamp = mtime(&stamp(config, testpaths));
|
||||||
let mut inputs = vec![
|
let mut inputs = vec![mtime(&testpaths.file), mtime(&config.rustc_path)];
|
||||||
mtime(&testpaths.file),
|
|
||||||
mtime(&config.rustc_path),
|
|
||||||
];
|
|
||||||
for aux in props.aux.iter() {
|
for aux in props.aux.iter() {
|
||||||
inputs.push(mtime(&testpaths.file.parent().unwrap()
|
inputs.push(mtime(
|
||||||
.join("auxiliary")
|
&testpaths.file.parent().unwrap().join("auxiliary").join(
|
||||||
.join(aux)));
|
aux,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// Relevant pretty printer files
|
||||||
|
let pretty_printer_files = [
|
||||||
|
"src/etc/debugger_pretty_printers_common.py",
|
||||||
|
"src/etc/gdb_load_rust_pretty_printers.py",
|
||||||
|
"src/etc/gdb_rust_pretty_printing.py",
|
||||||
|
"src/etc/lldb_batchmode.py",
|
||||||
|
"src/etc/lldb_rust_formatters.py",
|
||||||
|
];
|
||||||
|
for pretty_printer_file in &pretty_printer_files {
|
||||||
|
inputs.push(mtime(&rust_src_dir.join(pretty_printer_file)));
|
||||||
}
|
}
|
||||||
for lib in config.run_lib_path.read_dir().unwrap() {
|
for lib in config.run_lib_path.read_dir().unwrap() {
|
||||||
let lib = lib.unwrap();
|
let lib = lib.unwrap();
|
||||||
|
|
|
@ -572,8 +572,9 @@ actual:\n\
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let rust_src_root = self.find_rust_src_root()
|
let rust_src_root = self.config.find_rust_src_root().expect(
|
||||||
.expect("Could not find Rust source root");
|
"Could not find Rust source root",
|
||||||
|
);
|
||||||
let rust_pp_module_rel_path = Path::new("./src/etc");
|
let rust_pp_module_rel_path = Path::new("./src/etc");
|
||||||
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path)
|
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path)
|
||||||
.to_str()
|
.to_str()
|
||||||
|
@ -664,19 +665,6 @@ actual:\n\
|
||||||
self.check_debugger_output(&debugger_run_result, &check_lines);
|
self.check_debugger_output(&debugger_run_result, &check_lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_rust_src_root(&self) -> Option<PathBuf> {
|
|
||||||
let mut path = self.config.src_base.clone();
|
|
||||||
let path_postfix = Path::new("src/etc/lldb_batchmode.py");
|
|
||||||
|
|
||||||
while path.pop() {
|
|
||||||
if path.join(&path_postfix).is_file() {
|
|
||||||
return Some(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_debuginfo_lldb_test(&self) {
|
fn run_debuginfo_lldb_test(&self) {
|
||||||
assert!(self.revision.is_none(), "revisions not relevant here");
|
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||||
|
|
||||||
|
@ -735,7 +723,9 @@ actual:\n\
|
||||||
script_str.push_str("version\n");
|
script_str.push_str("version\n");
|
||||||
|
|
||||||
// Switch LLDB into "Rust mode"
|
// Switch LLDB into "Rust mode"
|
||||||
let rust_src_root = self.find_rust_src_root().expect("Could not find Rust source root");
|
let rust_src_root = self.config.find_rust_src_root().expect(
|
||||||
|
"Could not find Rust source root",
|
||||||
|
);
|
||||||
let rust_pp_module_rel_path = Path::new("./src/etc/lldb_rust_formatters.py");
|
let rust_pp_module_rel_path = Path::new("./src/etc/lldb_rust_formatters.py");
|
||||||
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path)
|
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path)
|
||||||
.to_str()
|
.to_str()
|
||||||
|
@ -1717,11 +1707,13 @@ actual:\n\
|
||||||
if self.props.check_test_line_numbers_match {
|
if self.props.check_test_line_numbers_match {
|
||||||
self.check_rustdoc_test_option(proc_res);
|
self.check_rustdoc_test_option(proc_res);
|
||||||
} else {
|
} else {
|
||||||
let root = self.find_rust_src_root().unwrap();
|
let root = self.config.find_rust_src_root().unwrap();
|
||||||
let res = self.cmd2procres(Command::new(&self.config.docck_python)
|
let res = self.cmd2procres(
|
||||||
|
Command::new(&self.config.docck_python)
|
||||||
.arg(root.join("src/etc/htmldocck.py"))
|
.arg(root.join("src/etc/htmldocck.py"))
|
||||||
.arg(out_dir)
|
.arg(out_dir)
|
||||||
.arg(&self.testpaths.file));
|
.arg(&self.testpaths.file),
|
||||||
|
);
|
||||||
if !res.status.success() {
|
if !res.status.success() {
|
||||||
self.fatal_proc_rec("htmldocck failed!", &res);
|
self.fatal_proc_rec("htmldocck failed!", &res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,9 @@ macro_rules! t {
|
||||||
|
|
||||||
macro_rules! tidy_error {
|
macro_rules! tidy_error {
|
||||||
($bad:expr, $fmt:expr, $($arg:tt)*) => ({
|
($bad:expr, $fmt:expr, $($arg:tt)*) => ({
|
||||||
use std::io::Write;
|
|
||||||
*$bad = true;
|
*$bad = true;
|
||||||
write!(::std::io::stderr(), "tidy error: ").expect("could not write to stderr");
|
eprint!("tidy error: ");
|
||||||
writeln!(::std::io::stderr(), $fmt, $($arg)*).expect("could not write to stderr");
|
eprintln!($fmt, $($arg)*);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ use tidy::*;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let path = env::args_os().skip(1).next().expect("need an argument");
|
let path = env::args_os().skip(1).next().expect("need an argument");
|
||||||
|
@ -44,7 +43,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if bad {
|
if bad {
|
||||||
writeln!(io::stderr(), "some tidy checks failed").expect("could not write to stderr");
|
eprintln!("some tidy checks failed");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue