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
|
||||
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.
|
||||
|
||||
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
|
||||
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:
|
||||
|
||||
```
|
||||
|
|
|
@ -31,8 +31,6 @@ extern crate bootstrap;
|
|||
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::str::FromStr;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Command, ExitStatus};
|
||||
|
@ -270,7 +268,7 @@ fn main() {
|
|||
}
|
||||
|
||||
if verbose > 1 {
|
||||
writeln!(&mut io::stderr(), "rustc command: {:?}", cmd).unwrap();
|
||||
eprintln!("rustc command: {:?}", cmd);
|
||||
}
|
||||
|
||||
// Actually run the compiler!
|
||||
|
|
|
@ -499,7 +499,7 @@ class RustBuild(object):
|
|||
|
||||
If the key does not exists, the result is None:
|
||||
|
||||
>>> rb.get_toml("key3") == None
|
||||
>>> rb.get_toml("key3") is None
|
||||
True
|
||||
"""
|
||||
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
|
||||
# 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
|
||||
# we've got configure.
|
||||
def to_toml(value):
|
||||
|
@ -372,7 +372,7 @@ def to_toml(value):
|
|||
elif isinstance(value, str):
|
||||
return "'" + value + "'"
|
||||
else:
|
||||
raise 'no toml'
|
||||
raise RuntimeError('no toml')
|
||||
|
||||
|
||||
def configure_section(lines, config):
|
||||
|
@ -392,9 +392,9 @@ def configure_section(lines, config):
|
|||
for section_key in config:
|
||||
section_config = config[section_key]
|
||||
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:
|
||||
configure_section(targets[target], section_config[target])
|
||||
else:
|
||||
|
|
|
@ -31,7 +31,7 @@ download_sysimage() {
|
|||
# Keep printing yes to accept the licenses
|
||||
while true; do echo yes; sleep 10; done | \
|
||||
/android/sdk/tools/android update sdk -a --no-ui \
|
||||
--filter "$filter"
|
||||
--filter "$filter" --no-https
|
||||
}
|
||||
|
||||
create_avd() {
|
||||
|
|
|
@ -81,7 +81,7 @@ def execute_command(command_interpreter, command):
|
|||
|
||||
if res.Succeeded():
|
||||
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
|
||||
# them with the breakpoint
|
||||
|
|
|
@ -85,16 +85,23 @@ ident [a-zA-Z\x80-\xff_][a-zA-Z0-9\x80-\xff_]*
|
|||
<blockcomment>(.|\n) { }
|
||||
|
||||
_ { return UNDERSCORE; }
|
||||
abstract { return ABSTRACT; }
|
||||
alignof { return ALIGNOF; }
|
||||
as { return AS; }
|
||||
become { return BECOME; }
|
||||
box { return BOX; }
|
||||
break { return BREAK; }
|
||||
catch { return CATCH; }
|
||||
const { return CONST; }
|
||||
continue { return CONTINUE; }
|
||||
crate { return CRATE; }
|
||||
default { return DEFAULT; }
|
||||
do { return DO; }
|
||||
else { return ELSE; }
|
||||
enum { return ENUM; }
|
||||
extern { return EXTERN; }
|
||||
false { return FALSE; }
|
||||
final { return FINAL; }
|
||||
fn { return FN; }
|
||||
for { return FOR; }
|
||||
if { return IF; }
|
||||
|
@ -102,26 +109,36 @@ impl { return IMPL; }
|
|||
in { return IN; }
|
||||
let { return LET; }
|
||||
loop { return LOOP; }
|
||||
macro { return MACRO; }
|
||||
match { return MATCH; }
|
||||
mod { return MOD; }
|
||||
move { return MOVE; }
|
||||
mut { return MUT; }
|
||||
offsetof { return OFFSETOF; }
|
||||
override { return OVERRIDE; }
|
||||
priv { return PRIV; }
|
||||
proc { return PROC; }
|
||||
pure { return PURE; }
|
||||
pub { return PUB; }
|
||||
ref { return REF; }
|
||||
return { return RETURN; }
|
||||
self { return SELF; }
|
||||
sizeof { return SIZEOF; }
|
||||
static { return STATIC; }
|
||||
struct { return STRUCT; }
|
||||
super { return SUPER; }
|
||||
trait { return TRAIT; }
|
||||
true { return TRUE; }
|
||||
type { return TYPE; }
|
||||
typeof { return TYPEOF; }
|
||||
union { return UNION; }
|
||||
unsafe { return UNSAFE; }
|
||||
unsized { return UNSIZED; }
|
||||
use { return USE; }
|
||||
virtual { return VIRTUAL; }
|
||||
where { return WHERE; }
|
||||
while { return WHILE; }
|
||||
yield { return YIELD; }
|
||||
|
||||
{ident} { return IDENT; }
|
||||
|
||||
|
@ -189,25 +206,25 @@ while { return WHILE; }
|
|||
\>\>= { return SHREQ; }
|
||||
\> { return '>'; }
|
||||
|
||||
\x27 { BEGIN(ltorchar); yymore(); }
|
||||
<ltorchar>static { BEGIN(INITIAL); return STATIC_LIFETIME; }
|
||||
<ltorchar>{ident} { BEGIN(INITIAL); return LIFETIME; }
|
||||
<ltorchar>\\[nrt\\\x27\x220]\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>.\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||
<ltorchar>[\x80-\xff]{2,4}\x27 { BEGIN(suffix); return LIT_CHAR; }
|
||||
<ltorchar><<EOF>> { BEGIN(INITIAL); return -1; }
|
||||
\x27 { BEGIN(ltorchar); yymore(); }
|
||||
<ltorchar>static { BEGIN(INITIAL); return STATIC_LIFETIME; }
|
||||
<ltorchar>{ident} { BEGIN(INITIAL); return LIFETIME; }
|
||||
<ltorchar>\\[nrt\\\x27\x220]\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]_*){1,6}\}\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><<EOF>> { BEGIN(INITIAL); return -1; }
|
||||
|
||||
b\x22 { BEGIN(bytestr); yymore(); }
|
||||
<bytestr>\x22 { BEGIN(suffix); return LIT_BYTE_STR; }
|
||||
|
||||
<bytestr><<EOF>> { return -1; }
|
||||
<bytestr>\\[n\nrt\\\x27\x220] { yymore(); }
|
||||
<bytestr>\\x[0-9a-fA-F]{2} { yymore(); }
|
||||
<bytestr>\\u\{[0-9a-fA-F]?{6}\} { yymore(); }
|
||||
<bytestr>\\[^n\nrt\\\x27\x220] { return -1; }
|
||||
<bytestr>(.|\n) { yymore(); }
|
||||
<bytestr><<EOF>> { return -1; }
|
||||
<bytestr>\\[n\nrt\\\x27\x220] { yymore(); }
|
||||
<bytestr>\\x[0-9a-fA-F]{2} { yymore(); }
|
||||
<bytestr>\\u\{([0-9a-fA-F]_*){1,6}\} { yymore(); }
|
||||
<bytestr>\\[^n\nrt\\\x27\x220] { return -1; }
|
||||
<bytestr>(.|\n) { yymore(); }
|
||||
|
||||
br\x22 { BEGIN(rawbytestr_nohash); yymore(); }
|
||||
<rawbytestr_nohash>\x22 { BEGIN(suffix); return LIT_BYTE_STR_RAW; }
|
||||
|
@ -252,13 +269,13 @@ br/# {
|
|||
}
|
||||
<rawbytestr><<EOF>> { return -1; }
|
||||
|
||||
b\x27 { BEGIN(byte); yymore(); }
|
||||
<byte>\\[nrt\\\x27\x220]\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]{8}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||
<byte>.\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||
<byte><<EOF>> { BEGIN(INITIAL); return -1; }
|
||||
b\x27 { BEGIN(byte); yymore(); }
|
||||
<byte>\\[nrt\\\x27\x220]\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]_*){8}\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||
<byte>.\x27 { BEGIN(INITIAL); return LIT_BYTE; }
|
||||
<byte><<EOF>> { BEGIN(INITIAL); return -1; }
|
||||
|
||||
r\x22 { BEGIN(rawstr); yymore(); }
|
||||
<rawstr>\x22 { BEGIN(suffix); return LIT_STR_RAW; }
|
||||
|
@ -310,12 +327,12 @@ r/# {
|
|||
\x22 { BEGIN(str); yymore(); }
|
||||
<str>\x22 { BEGIN(suffix); return LIT_STR; }
|
||||
|
||||
<str><<EOF>> { return -1; }
|
||||
<str>\\[n\nr\rt\\\x27\x220] { yymore(); }
|
||||
<str>\\x[0-9a-fA-F]{2} { yymore(); }
|
||||
<str>\\u\{[0-9a-fA-F]?{6}\} { yymore(); }
|
||||
<str>\\[^n\nrt\\\x27\x220] { return -1; }
|
||||
<str>(.|\n) { yymore(); }
|
||||
<str><<EOF>> { return -1; }
|
||||
<str>\\[n\nr\rt\\\x27\x220] { yymore(); }
|
||||
<str>\\x[0-9a-fA-F]{2} { yymore(); }
|
||||
<str>\\u\{([0-9a-fA-F]_*){1,6}\} { yymore(); }
|
||||
<str>\\[^n\nrt\\\x27\x220] { return -1; }
|
||||
<str>(.|\n) { yymore(); }
|
||||
|
||||
\<- { return LARROW; }
|
||||
-\> { return RARROW; }
|
||||
|
|
|
@ -62,13 +62,19 @@ extern char *yytext;
|
|||
// keywords
|
||||
%token SELF
|
||||
%token STATIC
|
||||
%token ABSTRACT
|
||||
%token ALIGNOF
|
||||
%token AS
|
||||
%token BECOME
|
||||
%token BREAK
|
||||
%token CATCH
|
||||
%token CRATE
|
||||
%token DO
|
||||
%token ELSE
|
||||
%token ENUM
|
||||
%token EXTERN
|
||||
%token FALSE
|
||||
%token FINAL
|
||||
%token FN
|
||||
%token FOR
|
||||
%token IF
|
||||
|
@ -76,19 +82,29 @@ extern char *yytext;
|
|||
%token IN
|
||||
%token LET
|
||||
%token LOOP
|
||||
%token MACRO
|
||||
%token MATCH
|
||||
%token MOD
|
||||
%token MOVE
|
||||
%token MUT
|
||||
%token OFFSETOF
|
||||
%token OVERRIDE
|
||||
%token PRIV
|
||||
%token PUB
|
||||
%token PURE
|
||||
%token REF
|
||||
%token RETURN
|
||||
%token SIZEOF
|
||||
%token STRUCT
|
||||
%token SUPER
|
||||
%token UNION
|
||||
%token UNSIZED
|
||||
%token TRUE
|
||||
%token TRAIT
|
||||
%token TYPE
|
||||
%token UNSAFE
|
||||
%token VIRTUAL
|
||||
%token YIELD
|
||||
%token DEFAULT
|
||||
%token USE
|
||||
%token WHILE
|
||||
|
@ -141,6 +157,10 @@ extern char *yytext;
|
|||
// 'foo:bar . <' is shifted (in a trait reference occurring in a
|
||||
// bounds list), parsing as foo:(bar<baz>) rather than (foo:bar)<baz>.
|
||||
%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 +
|
||||
// and < in trailing type contexts. These come up when you have a type
|
||||
|
@ -161,13 +181,13 @@ extern char *yytext;
|
|||
%precedence FOR
|
||||
|
||||
// Binops & unops, and their precedences
|
||||
%precedence '?'
|
||||
%precedence BOX
|
||||
%precedence BOXPLACE
|
||||
%nonassoc DOTDOT
|
||||
|
||||
// RETURN needs to be lower-precedence than tokens that start
|
||||
// prefix_exprs
|
||||
%precedence RETURN
|
||||
%precedence RETURN YIELD
|
||||
|
||||
%right '=' SHLEQ SHREQ MINUSEQ ANDEQ OREQ PLUSEQ STAREQ SLASHEQ CARETEQ PERCENTEQ
|
||||
%right LARROW
|
||||
|
@ -321,6 +341,8 @@ view_path
|
|||
| 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); }
|
||||
| path_no_types_allowed MOD_SEP '*' { $$ = mk_node("ViewPathGlob", 1, $1); }
|
||||
| MOD_SEP '*' { $$ = mk_atom("ViewPathGlob"); }
|
||||
| '*' { $$ = mk_atom("ViewPathGlob"); }
|
||||
| '{' '}' { $$ = mk_atom("ViewPathListEmpty"); }
|
||||
| '{' 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_struct
|
||||
| item_enum
|
||||
| item_union
|
||||
| item_trait
|
||||
| item_impl
|
||||
;
|
||||
|
@ -387,6 +410,7 @@ struct_decl_field
|
|||
struct_tuple_fields
|
||||
: struct_tuple_field { $$ = mk_node("StructFields", 1, $1); }
|
||||
| struct_tuple_fields ',' struct_tuple_field { $$ = ext_node($1, 1, $3); }
|
||||
| %empty { $$ = mk_none(); }
|
||||
;
|
||||
|
||||
struct_tuple_field
|
||||
|
@ -417,6 +441,11 @@ enum_args
|
|||
| %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
|
||||
: MOD ident ';' { $$ = mk_node("ItemMod", 1, $2); }
|
||||
| MOD ident '{' maybe_mod_items '}' { $$ = mk_node("ItemMod", 2, $2, $4); }
|
||||
|
@ -475,7 +504,7 @@ visibility
|
|||
|
||||
idents_or_self
|
||||
: 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); }
|
||||
;
|
||||
|
||||
|
@ -515,6 +544,7 @@ trait_item
|
|||
: trait_const
|
||||
| trait_type
|
||||
| trait_method
|
||||
| maybe_outer_attrs item_macro { $$ = mk_node("TraitMacroItem", 2, $1, $2); }
|
||||
;
|
||||
|
||||
trait_const
|
||||
|
@ -547,36 +577,48 @@ trait_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);
|
||||
}
|
||||
| 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);
|
||||
}
|
||||
;
|
||||
|
||||
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);
|
||||
}
|
||||
| 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);
|
||||
}
|
||||
;
|
||||
|
||||
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);
|
||||
}
|
||||
| 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:
|
||||
|
@ -638,12 +680,17 @@ impl_item
|
|||
| impl_type
|
||||
;
|
||||
|
||||
maybe_default
|
||||
: DEFAULT { $$ = mk_atom("Default"); }
|
||||
| %empty { $$ = mk_none(); }
|
||||
;
|
||||
|
||||
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
|
||||
: 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
|
||||
|
@ -651,6 +698,10 @@ item_fn
|
|||
{
|
||||
$$ = 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
|
||||
|
@ -658,6 +709,10 @@ item_unsafe_fn
|
|||
{
|
||||
$$ = 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
|
||||
{
|
||||
$$ = 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); }
|
||||
;
|
||||
|
||||
maybe_unboxed_closure_kind
|
||||
: %empty
|
||||
| ':'
|
||||
| '&' maybe_mut ':'
|
||||
;
|
||||
|
||||
maybe_comma_params
|
||||
: ',' { $$ = mk_none(); }
|
||||
| ',' params { $$ = $2; }
|
||||
|
@ -784,7 +833,8 @@ ret_ty
|
|||
;
|
||||
|
||||
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 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); }
|
||||
| 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); }
|
||||
;
|
||||
|
||||
|
@ -882,7 +934,7 @@ generic_args
|
|||
;
|
||||
|
||||
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
|
||||
|
@ -910,12 +962,11 @@ pat
|
|||
| ANDAND pat { $$ = mk_node("PatRegion", 1, mk_node("PatRegion", 1, $2)); }
|
||||
| '(' ')' { $$ = mk_atom("PatUnit"); }
|
||||
| '(' pat_tup ')' { $$ = mk_node("PatTup", 1, $2); }
|
||||
| '(' pat_tup ',' ')' { $$ = mk_node("PatTup", 1, $2); }
|
||||
| '[' pat_vec ']' { $$ = mk_node("PatVec", 1, $2); }
|
||||
| lit_or_path
|
||||
| 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 '(' 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 '!' maybe_ident delimited_token_trees { $$ = mk_node("PatMac", 3, $1, $3, $4); }
|
||||
| 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); }
|
||||
| ident ':' pat { $$ = mk_node("PatField", 2, $1, $3); }
|
||||
| binding_mode ident ':' pat { $$ = mk_node("PatField", 3, $1, $2, $4); }
|
||||
| LIT_INTEGER ':' pat { $$ = mk_node("PatField", 2, mk_atom(yytext), $3); }
|
||||
;
|
||||
|
||||
pat_fields
|
||||
|
@ -965,11 +1017,26 @@ pat_struct
|
|||
| pat_fields ',' { $$ = mk_node("PatStruct", 2, $1, mk_atom("false")); }
|
||||
| pat_fields ',' DOTDOT { $$ = mk_node("PatStruct", 2, $1, mk_atom("true")); }
|
||||
| DOTDOT { $$ = mk_node("PatStruct", 1, mk_atom("true")); }
|
||||
| %empty { $$ = mk_node("PatStruct", 1, mk_none()); }
|
||||
;
|
||||
|
||||
pat_tup
|
||||
: pat { $$ = mk_node("pat_tup", 1, $1); }
|
||||
| pat_tup ',' pat { $$ = ext_node($1, 1, $3); }
|
||||
: pat_tup_elts { $$ = mk_node("PatTup", 2, $1, mk_none()); }
|
||||
| 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
|
||||
|
@ -1007,24 +1074,25 @@ ty
|
|||
;
|
||||
|
||||
ty_prim
|
||||
: %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 SELF MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("self", 1, mk_atom("true")), $3); }
|
||||
| BOX ty { $$ = mk_node("TyBox", 1, $2); }
|
||||
| '*' maybe_mut_or_const ty { $$ = mk_node("TyPtr", 2, $2, $3); }
|
||||
| '&' ty { $$ = mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2); }
|
||||
| '&' MUT ty { $$ = mk_node("TyRptr", 2, mk_atom("MutMutable"), $3); }
|
||||
| ANDAND ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2)); }
|
||||
| ANDAND MUT ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 2, mk_atom("MutMutable"), $3)); }
|
||||
| '&' lifetime maybe_mut ty { $$ = mk_node("TyRptr", 3, $2, $3, $4); }
|
||||
| ANDAND lifetime maybe_mut ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 3, $2, $3, $4)); }
|
||||
| '[' ty ']' { $$ = mk_node("TyVec", 1, $2); }
|
||||
| '[' ty ',' DOTDOT expr ']' { $$ = mk_node("TyFixedLengthVec", 2, $2, $5); }
|
||||
| '[' ty ';' expr ']' { $$ = mk_node("TyFixedLengthVec", 2, $2, $4); }
|
||||
| TYPEOF '(' expr ')' { $$ = mk_node("TyTypeof", 1, $3); }
|
||||
| UNDERSCORE { $$ = mk_atom("TyInfer"); }
|
||||
: %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 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); }
|
||||
| '*' maybe_mut_or_const ty { $$ = mk_node("TyPtr", 2, $2, $3); }
|
||||
| '&' ty { $$ = mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2); }
|
||||
| '&' MUT ty { $$ = mk_node("TyRptr", 2, mk_atom("MutMutable"), $3); }
|
||||
| ANDAND ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2)); }
|
||||
| ANDAND MUT ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 2, mk_atom("MutMutable"), $3)); }
|
||||
| '&' lifetime maybe_mut ty { $$ = mk_node("TyRptr", 3, $2, $3, $4); }
|
||||
| ANDAND lifetime maybe_mut ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 3, $2, $3, $4)); }
|
||||
| '[' ty ']' { $$ = mk_node("TyVec", 1, $2); }
|
||||
| '[' ty ',' DOTDOT expr ']' { $$ = mk_node("TyFixedLengthVec", 2, $2, $5); }
|
||||
| '[' ty ';' expr ']' { $$ = mk_node("TyFixedLengthVec", 2, $2, $4); }
|
||||
| TYPEOF '(' expr ')' { $$ = mk_node("TyTypeof", 1, $3); }
|
||||
| UNDERSCORE { $$ = mk_atom("TyInfer"); }
|
||||
| ty_bare_fn
|
||||
| ty_proc
|
||||
| for_in_type
|
||||
;
|
||||
|
||||
|
@ -1046,17 +1114,12 @@ ty_closure
|
|||
| 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 '<' maybe_lifetimes '>' for_in_type_suffix { $$ = mk_node("ForInType", 2, $3, $5); }
|
||||
;
|
||||
|
||||
for_in_type_suffix
|
||||
: ty_proc
|
||||
| ty_bare_fn
|
||||
: ty_bare_fn
|
||||
| trait_ref
|
||||
| ty_closure
|
||||
;
|
||||
|
@ -1100,13 +1163,23 @@ ty_sums
|
|||
;
|
||||
|
||||
ty_sum
|
||||
: ty { $$ = mk_node("TySum", 1, $1); }
|
||||
| ty '+' ty_param_bounds { $$ = mk_node("TySum", 2, $1, $3); }
|
||||
: ty_sum_elt { $$ = mk_node("TySum", 1, $1); }
|
||||
| ty_sum '+' ty_sum_elt { $$ = ext_node($1, 1, $3); }
|
||||
;
|
||||
|
||||
ty_sum_elt
|
||||
: ty
|
||||
| lifetime
|
||||
;
|
||||
|
||||
ty_prim_sum
|
||||
: ty_prim { $$ = mk_node("TySum", 1, $1); }
|
||||
| ty_prim '+' ty_param_bounds { $$ = mk_node("TySum", 2, $1, $3); }
|
||||
: ty_prim_sum_elt { $$ = mk_node("TySum", 1, $1); }
|
||||
| ty_prim_sum '+' ty_prim_sum_elt { $$ = ext_node($1, 1, $3); }
|
||||
;
|
||||
|
||||
ty_prim_sum_elt
|
||||
: ty_prim
|
||||
| lifetime
|
||||
;
|
||||
|
||||
maybe_ty_param_bounds
|
||||
|
@ -1127,6 +1200,7 @@ boundseq
|
|||
polybound
|
||||
: FOR '<' maybe_lifetimes '>' bound { $$ = mk_node("PolyBound", 2, $3, $5); }
|
||||
| bound
|
||||
| '?' FOR '<' maybe_lifetimes '>' bound { $$ = mk_node("PolyBound", 2, $4, $6); }
|
||||
| '?' bound { $$ = $2; }
|
||||
;
|
||||
|
||||
|
@ -1244,11 +1318,6 @@ maybe_stmts
|
|||
// block, nonblock-prefix, and nonblock-nonprefix.
|
||||
//
|
||||
// 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
|
||||
: stmt { $$ = mk_node("stmts", 1, $1); }
|
||||
|
@ -1256,14 +1325,15 @@ stmts
|
|||
;
|
||||
|
||||
stmt
|
||||
: let
|
||||
: maybe_outer_attrs let { $$ = $2; }
|
||||
| stmt_item
|
||||
| PUB stmt_item { $$ = $2; }
|
||||
| outer_attrs stmt_item { $$ = $2; }
|
||||
| outer_attrs PUB stmt_item { $$ = $3; }
|
||||
| full_block_expr
|
||||
| block
|
||||
| nonblock_expr ';'
|
||||
| maybe_outer_attrs block { $$ = $2; }
|
||||
| nonblock_expr ';'
|
||||
| outer_attrs nonblock_expr ';' { $$ = $2; }
|
||||
| ';' { $$ = mk_none(); }
|
||||
;
|
||||
|
||||
|
@ -1296,7 +1366,9 @@ path_expr
|
|||
// expressions.
|
||||
path_generic_args_with_colons
|
||||
: 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 SUPER { $$ = ext_node($1, 1, mk_atom("Super")); }
|
||||
| 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"))); }
|
||||
| macro_expr { $$ = mk_node("ExprMac", 1, $1); }
|
||||
| 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 '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||
| nonblock_expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
||||
|
@ -1325,6 +1398,8 @@ nonblock_expr
|
|||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
||||
| 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 '=' expr { $$ = mk_node("ExprAssign", 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 { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
||||
| nonblock_expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
||||
| BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||
| %prec BOXPLACE BOX '(' maybe_expr ')' nonblock_expr { $$ = mk_node("ExprBox", 2, $3, $5); }
|
||||
| nonblock_expr ':' ty { $$ = mk_node("ExprTypeAscr", 2, $1, $3); }
|
||||
| BOX expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||
| expr_qualified_path
|
||||
| nonblock_prefix_expr
|
||||
;
|
||||
|
@ -1373,6 +1448,7 @@ expr
|
|||
| 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); }
|
||||
| expr '?' { $$ = mk_node("ExprTry", 1, $1); }
|
||||
| expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||
| expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||
| expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
||||
|
@ -1385,6 +1461,8 @@ expr
|
|||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
||||
| 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 '=' expr { $$ = mk_node("ExprAssign", 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 { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
||||
| 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", 2, $3, $5); }
|
||||
| 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 ':' ty { $$ = mk_node("ExprTypeAscr", 2, $1, $3); }
|
||||
| BOX expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||
| expr_qualified_path
|
||||
| block_expr
|
||||
| block
|
||||
|
@ -1495,6 +1512,7 @@ expr_nostruct
|
|||
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); }
|
||||
| expr_nostruct '?' { $$ = mk_node("ExprTry", 1, $1); }
|
||||
| expr_nostruct '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||
| expr_nostruct '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
|
||||
| expr_nostruct '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
|
||||
|
@ -1507,6 +1525,8 @@ expr_nostruct
|
|||
| RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
|
||||
| BREAK { $$ = mk_node("ExprBreak", 0); }
|
||||
| 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 '=' expr_nostruct { $$ = mk_node("ExprAssign", 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 { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
|
||||
| expr_nostruct AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
|
||||
| BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||
| %prec BOXPLACE BOX '(' maybe_expr ')' expr_nostruct { $$ = mk_node("ExprBox", 1, $3, $5); }
|
||||
| expr_nostruct ':' ty { $$ = mk_node("ExprTypeAscr", 2, $1, $3); }
|
||||
| BOX expr { $$ = mk_node("ExprBox", 1, $2); }
|
||||
| expr_qualified_path
|
||||
| block_expr
|
||||
| block
|
||||
|
@ -1558,7 +1578,6 @@ nonblock_prefix_expr_nostruct
|
|||
| ANDAND maybe_mut expr_nostruct { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
|
||||
| lambda_expr_nostruct
|
||||
| MOVE lambda_expr_nostruct { $$ = $2; }
|
||||
| proc_expr_nostruct
|
||||
;
|
||||
|
||||
nonblock_prefix_expr
|
||||
|
@ -1569,7 +1588,6 @@ nonblock_prefix_expr
|
|||
| ANDAND maybe_mut expr { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
|
||||
| lambda_expr
|
||||
| MOVE lambda_expr { $$ = $2; }
|
||||
| proc_expr
|
||||
;
|
||||
|
||||
expr_qualified_path
|
||||
|
@ -1606,43 +1624,42 @@ maybe_as_trait_ref
|
|||
|
||||
lambda_expr
|
||||
: %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
|
||||
'|' 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
|
||||
'|' 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
|
||||
'|' '&' 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
|
||||
'|' ':' 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
|
||||
: %prec LAMBDA
|
||||
OROR expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $2); }
|
||||
OROR expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $2); }
|
||||
| %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
|
||||
'|' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $2, $4); }
|
||||
'|' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $2, $4); }
|
||||
| %prec LAMBDA
|
||||
'|' '&' maybe_mut ':' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $5, $7); }
|
||||
| %prec LAMBDA
|
||||
'|' ':' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $3, $5); }
|
||||
|
||||
'|' inferrable_params OROR lambda_expr_nostruct_no_first_bar { $$ = mk_node("ExprFnBlock", 3, $2, mk_none(), $4); }
|
||||
;
|
||||
|
||||
proc_expr
|
||||
lambda_expr_nostruct_no_first_bar
|
||||
: %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
|
||||
PROC '(' inferrable_params ')' expr { $$ = mk_node("ExprProc", 2, $3, $5); }
|
||||
;
|
||||
|
||||
proc_expr_nostruct
|
||||
: %prec LAMBDA
|
||||
PROC '(' ')' expr_nostruct { $$ = mk_node("ExprProc", 2, mk_none(), $4); }
|
||||
inferrable_params '|' ret_ty expr_nostruct { $$ = mk_node("ExprFnBlock", 3, $1, $3, $4); }
|
||||
| %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
|
||||
|
@ -1654,6 +1671,7 @@ struct_expr_fields
|
|||
: field_inits
|
||||
| field_inits ','
|
||||
| maybe_field_inits default_field_init { $$ = ext_node($1, 1, $2); }
|
||||
| %empty { $$ = mk_none(); }
|
||||
;
|
||||
|
||||
maybe_field_inits
|
||||
|
@ -1668,7 +1686,9 @@ field_inits
|
|||
;
|
||||
|
||||
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
|
||||
|
@ -1689,10 +1709,18 @@ block_expr
|
|||
|
||||
full_block_expr
|
||||
: block_expr
|
||||
| full_block_expr '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
|
||||
| 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_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
|
||||
|
@ -1714,12 +1742,13 @@ 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 full_block_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 block_expr_dot { $$ = mk_node("ArmNonblock", 4, $1, $2, $3, $5); }
|
||||
;
|
||||
|
||||
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
|
||||
|
@ -1796,6 +1825,10 @@ maybe_ident
|
|||
|
||||
ident
|
||||
: 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
|
||||
|
@ -1836,13 +1869,20 @@ unpaired_token
|
|||
| LIFETIME { $$ = mk_atom(yytext); }
|
||||
| SELF { $$ = mk_atom(yytext); }
|
||||
| STATIC { $$ = mk_atom(yytext); }
|
||||
| ABSTRACT { $$ = mk_atom(yytext); }
|
||||
| ALIGNOF { $$ = mk_atom(yytext); }
|
||||
| AS { $$ = mk_atom(yytext); }
|
||||
| BECOME { $$ = mk_atom(yytext); }
|
||||
| BREAK { $$ = mk_atom(yytext); }
|
||||
| CATCH { $$ = mk_atom(yytext); }
|
||||
| CRATE { $$ = mk_atom(yytext); }
|
||||
| DEFAULT { $$ = mk_atom(yytext); }
|
||||
| DO { $$ = mk_atom(yytext); }
|
||||
| ELSE { $$ = mk_atom(yytext); }
|
||||
| ENUM { $$ = mk_atom(yytext); }
|
||||
| EXTERN { $$ = mk_atom(yytext); }
|
||||
| FALSE { $$ = mk_atom(yytext); }
|
||||
| FINAL { $$ = mk_atom(yytext); }
|
||||
| FN { $$ = mk_atom(yytext); }
|
||||
| FOR { $$ = mk_atom(yytext); }
|
||||
| IF { $$ = mk_atom(yytext); }
|
||||
|
@ -1850,21 +1890,31 @@ unpaired_token
|
|||
| IN { $$ = mk_atom(yytext); }
|
||||
| LET { $$ = mk_atom(yytext); }
|
||||
| LOOP { $$ = mk_atom(yytext); }
|
||||
| MACRO { $$ = mk_atom(yytext); }
|
||||
| MATCH { $$ = mk_atom(yytext); }
|
||||
| MOD { $$ = mk_atom(yytext); }
|
||||
| MOVE { $$ = mk_atom(yytext); }
|
||||
| MUT { $$ = mk_atom(yytext); }
|
||||
| OFFSETOF { $$ = mk_atom(yytext); }
|
||||
| OVERRIDE { $$ = mk_atom(yytext); }
|
||||
| PRIV { $$ = mk_atom(yytext); }
|
||||
| PUB { $$ = mk_atom(yytext); }
|
||||
| PURE { $$ = mk_atom(yytext); }
|
||||
| REF { $$ = mk_atom(yytext); }
|
||||
| RETURN { $$ = mk_atom(yytext); }
|
||||
| STRUCT { $$ = mk_atom(yytext); }
|
||||
| SIZEOF { $$ = mk_atom(yytext); }
|
||||
| SUPER { $$ = mk_atom(yytext); }
|
||||
| TRUE { $$ = mk_atom(yytext); }
|
||||
| TRAIT { $$ = mk_atom(yytext); }
|
||||
| TYPE { $$ = mk_atom(yytext); }
|
||||
| UNION { $$ = mk_atom(yytext); }
|
||||
| UNSAFE { $$ = mk_atom(yytext); }
|
||||
| UNSIZED { $$ = mk_atom(yytext); }
|
||||
| USE { $$ = mk_atom(yytext); }
|
||||
| VIRTUAL { $$ = mk_atom(yytext); }
|
||||
| WHILE { $$ = mk_atom(yytext); }
|
||||
| YIELD { $$ = mk_atom(yytext); }
|
||||
| CONTINUE { $$ = mk_atom(yytext); }
|
||||
| PROC { $$ = mk_atom(yytext); }
|
||||
| BOX { $$ = mk_atom(yytext); }
|
||||
|
|
|
@ -30,6 +30,7 @@ enum Token {
|
|||
DOTDOT,
|
||||
DOTDOTDOT,
|
||||
MOD_SEP,
|
||||
LARROW,
|
||||
RARROW,
|
||||
FAT_ARROW,
|
||||
LIT_BYTE,
|
||||
|
@ -47,13 +48,20 @@ enum Token {
|
|||
// keywords
|
||||
SELF,
|
||||
STATIC,
|
||||
ABSTRACT,
|
||||
ALIGNOF,
|
||||
AS,
|
||||
BECOME,
|
||||
BREAK,
|
||||
CATCH,
|
||||
CRATE,
|
||||
DEFAULT,
|
||||
DO,
|
||||
ELSE,
|
||||
ENUM,
|
||||
EXTERN,
|
||||
FALSE,
|
||||
FINAL,
|
||||
FN,
|
||||
FOR,
|
||||
IF,
|
||||
|
@ -61,21 +69,31 @@ enum Token {
|
|||
IN,
|
||||
LET,
|
||||
LOOP,
|
||||
MACRO,
|
||||
MATCH,
|
||||
MOD,
|
||||
MOVE,
|
||||
MUT,
|
||||
OFFSETOF,
|
||||
OVERRIDE,
|
||||
PRIV,
|
||||
PUB,
|
||||
PURE,
|
||||
REF,
|
||||
RETURN,
|
||||
SIZEOF,
|
||||
STRUCT,
|
||||
SUPER,
|
||||
UNION,
|
||||
TRUE,
|
||||
TRAIT,
|
||||
TYPE,
|
||||
UNSAFE,
|
||||
UNSIZED,
|
||||
USE,
|
||||
VIRTUAL,
|
||||
WHILE,
|
||||
YIELD,
|
||||
CONTINUE,
|
||||
PROC,
|
||||
BOX,
|
||||
|
|
|
@ -269,7 +269,38 @@ impl<T: ?Sized> Box<T> {
|
|||
#[stable(feature = "box_raw", since = "1.4.0")]
|
||||
#[inline]
|
||||
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.
|
||||
|
@ -295,7 +326,7 @@ impl<T: ?Sized> Box<T> {
|
|||
#[stable(feature = "box_raw", since = "1.4.0")]
|
||||
#[inline]
|
||||
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>`.
|
||||
|
@ -303,13 +334,18 @@ impl<T: ?Sized> Box<T> {
|
|||
/// After calling this function, the caller is responsible for the
|
||||
/// memory previously managed by the `Box`. In particular, 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
|
||||
/// `Box` with the [`Box::from_raw`] function.
|
||||
/// proper way to do so is to either convert the `Unique<T>` pointer:
|
||||
///
|
||||
/// - 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
|
||||
/// 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.
|
||||
///
|
||||
/// [`Box::from_unique`]: struct.Box.html#method.from_unique
|
||||
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
|
||||
///
|
||||
/// # 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.
|
||||
#[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.
|
||||
|
||||
|
|
|
@ -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 {
|
||||
let mut escaped = String::new();
|
||||
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))
|
||||
}
|
||||
|
|
|
@ -1100,6 +1100,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
"generate a graphical HTML report of time spent in trans and LLVM"),
|
||||
thinlto: bool = (false, parse_bool, [TRACKED],
|
||||
"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 {
|
||||
|
@ -1711,7 +1713,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
|||
|
||||
let codegen_units = codegen_units.unwrap_or_else(|| {
|
||||
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
|
||||
// builds don't rely on performance at all, meaning that lost
|
||||
// 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
|
||||
// cpus will finish pretty closely to one another and we should
|
||||
// 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,
|
||||
// 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),
|
||||
("i586-pc-windows-msvc", i586_pc_windows_msvc),
|
||||
|
||||
("le32-unknown-nacl", le32_unknown_nacl),
|
||||
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
|
||||
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
|
||||
("wasm32-experimental-emscripten", wasm32_experimental_emscripten),
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
//! be indexed by the direction (see the type `Direction`).
|
||||
|
||||
use bitvec::BitVector;
|
||||
use std::fmt::{Formatter, Error, Debug};
|
||||
use std::fmt::Debug;
|
||||
use std::usize;
|
||||
use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
||||
|
||||
|
@ -48,6 +48,7 @@ pub struct Node<N> {
|
|||
pub data: N,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Edge<E> {
|
||||
next_edge: [EdgeIndex; 2], // see module comment
|
||||
source: NodeIndex,
|
||||
|
@ -69,18 +70,6 @@ impl<N> SnapshotVecDelegate for 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)]
|
||||
pub struct NodeIndex(pub usize);
|
||||
|
||||
|
|
|
@ -1238,7 +1238,7 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
|
|||
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();
|
||||
|
|
|
@ -88,7 +88,7 @@ fn main() {
|
|||
let is_crossed = target != host;
|
||||
|
||||
let mut optional_components =
|
||||
vec!["x86", "arm", "aarch64", "mips", "powerpc", "pnacl",
|
||||
vec!["x86", "arm", "aarch64", "mips", "powerpc",
|
||||
"systemz", "jsbackend", "webassembly", "msp430", "sparc", "nvptx"];
|
||||
|
||||
let mut version_cmd = Command::new(&llvm_config);
|
||||
|
|
|
@ -346,10 +346,6 @@ pub fn initialize_available_targets() {
|
|||
LLVMInitializePowerPCTargetMC,
|
||||
LLVMInitializePowerPCAsmPrinter,
|
||||
LLVMInitializePowerPCAsmParser);
|
||||
init_target!(llvm_component = "pnacl",
|
||||
LLVMInitializePNaClTargetInfo,
|
||||
LLVMInitializePNaClTarget,
|
||||
LLVMInitializePNaClTargetMC);
|
||||
init_target!(llvm_component = "systemz",
|
||||
LLVMInitializeSystemZTargetInfo,
|
||||
LLVMInitializeSystemZTarget,
|
||||
|
|
|
@ -751,9 +751,7 @@ impl<'a, 'tcx> FnType<'tcx> {
|
|||
Some(ty.boxed_ty())
|
||||
}
|
||||
|
||||
ty::TyRef(b, mt) => {
|
||||
use rustc::ty::{BrAnon, ReLateBound};
|
||||
|
||||
ty::TyRef(_, mt) => {
|
||||
// `&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
|
||||
|
@ -779,13 +777,6 @@ impl<'a, 'tcx> FnType<'tcx> {
|
|||
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)
|
||||
}
|
||||
_ => None
|
||||
|
|
|
@ -98,8 +98,10 @@
|
|||
//! DefPaths which are much more robust in the face of changes to the code base.
|
||||
|
||||
use monomorphize::Instance;
|
||||
use trans_item::{TransItemExt, InstantiationMode};
|
||||
|
||||
use rustc::middle::weak_lang_items;
|
||||
use rustc::middle::trans::TransItem;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::map as hir_map;
|
||||
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>,
|
||||
|
||||
// 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
|
||||
// parameters substituted; this is
|
||||
|
@ -160,7 +165,7 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
// values for generic type parameters,
|
||||
// if any.
|
||||
substs: Option<&'tcx Substs<'tcx>>)
|
||||
substs: &'tcx Substs<'tcx>)
|
||||
-> u64 {
|
||||
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
|
||||
// compiler's internal def-path, guaranteeing each symbol has a
|
||||
// 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
|
||||
// assertions about `needs_subst` may not hold, but this item-type
|
||||
|
@ -186,19 +191,36 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
|
||||
// also include any type parameters (for generic items)
|
||||
if let Some(substs) = substs {
|
||||
assert!(!substs.has_erasable_regions());
|
||||
assert!(!substs.needs_subst());
|
||||
substs.visit_with(&mut hasher);
|
||||
assert!(!substs.has_erasable_regions());
|
||||
assert!(!substs.needs_subst());
|
||||
substs.visit_with(&mut hasher);
|
||||
|
||||
// If this is an instance of a generic function, we also hash in
|
||||
// the ID of the instantiating crate. This avoids symbol conflicts
|
||||
// in case the same instances is emitted in two crates of the same
|
||||
// project.
|
||||
if substs.types().next().is_some() {
|
||||
hasher.hash(tcx.crate_name.as_str());
|
||||
hasher.hash(tcx.sess.local_crate_disambiguator().as_str());
|
||||
let mut avoid_cross_crate_conflicts = false;
|
||||
|
||||
// If this is an instance of a generic function, we also hash in
|
||||
// the ID of the instantiating crate. This avoids symbol conflicts
|
||||
// in case the same instances is emitted in two crates of the same
|
||||
// project.
|
||||
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.sess.local_crate_disambiguator().as_str());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -309,7 +331,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
|
|||
// and should not matter anyhow.
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -1247,7 +1247,7 @@ fn start_executing_work(tcx: TyCtxt,
|
|||
modules_config: Arc<ModuleConfig>,
|
||||
metadata_config: Arc<ModuleConfig>,
|
||||
allocator_config: Arc<ModuleConfig>)
|
||||
-> thread::JoinHandle<CompiledModules> {
|
||||
-> thread::JoinHandle<Result<CompiledModules, ()>> {
|
||||
let coordinator_send = tcx.tx_to_llvm_workers.clone();
|
||||
let mut exported_symbols = FxHashMap();
|
||||
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: _ } => {
|
||||
shared_emitter.fatal("aborting due to worker thread failure");
|
||||
// Exit the coordinator thread
|
||||
panic!("aborting due to worker thread failure")
|
||||
return Err(())
|
||||
}
|
||||
Message::TranslateItem => {
|
||||
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
|
||||
.expect("Metadata module not compiled?");
|
||||
|
||||
CompiledModules {
|
||||
Ok(CompiledModules {
|
||||
modules: compiled_modules,
|
||||
metadata_module: compiled_metadata_module,
|
||||
allocator_module: compiled_allocator_module,
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// 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>>,
|
||||
trans_worker_receive: Receiver<Message>,
|
||||
shared_emitter_main: SharedEmitterMain,
|
||||
future: thread::JoinHandle<CompiledModules>,
|
||||
future: thread::JoinHandle<Result<CompiledModules, ()>>,
|
||||
output_filenames: Arc<OutputFilenames>,
|
||||
}
|
||||
|
||||
|
@ -2026,7 +2026,11 @@ impl OngoingCrateTranslation {
|
|||
pub fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation {
|
||||
self.shared_emitter_main.check(sess, true);
|
||||
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(_) => {
|
||||
sess.fatal("Error during translation/LLVM phase.");
|
||||
}
|
||||
|
|
|
@ -1231,9 +1231,6 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
|
|||
.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| {
|
||||
match *trans_item {
|
||||
TransItem::Fn(ref instance) => Some(instance.def_id()),
|
||||
|
|
|
@ -401,9 +401,9 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
|
||||
fn record_accesses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
caller: TransItem<'tcx>,
|
||||
callees: &[TransItem<'tcx>],
|
||||
inlining_map: &mut InliningMap<'tcx>) {
|
||||
caller: TransItem<'tcx>,
|
||||
callees: &[TransItem<'tcx>],
|
||||
inlining_map: &mut InliningMap<'tcx>) {
|
||||
let is_inlining_candidate = |trans_item: &TransItem<'tcx>| {
|
||||
trans_item.instantiation_mode(tcx) == InstantiationMode::LocalCopy
|
||||
};
|
||||
|
|
|
@ -279,75 +279,74 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
let mut internalization_candidates = FxHashSet();
|
||||
|
||||
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 is_volatile = is_incremental_build &&
|
||||
trans_item.is_generic_fn();
|
||||
let characteristic_def_id = characteristic_def_id_of_trans_item(tcx, trans_item);
|
||||
let is_volatile = is_incremental_build &&
|
||||
trans_item.is_generic_fn();
|
||||
|
||||
let codegen_unit_name = match characteristic_def_id {
|
||||
Some(def_id) => compute_codegen_unit_name(tcx, def_id, is_volatile),
|
||||
None => Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str(),
|
||||
};
|
||||
let codegen_unit_name = match characteristic_def_id {
|
||||
Some(def_id) => compute_codegen_unit_name(tcx, def_id, is_volatile),
|
||||
None => Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str(),
|
||||
};
|
||||
|
||||
let make_codegen_unit = || {
|
||||
CodegenUnit::new(codegen_unit_name.clone())
|
||||
};
|
||||
let make_codegen_unit = || {
|
||||
CodegenUnit::new(codegen_unit_name.clone())
|
||||
};
|
||||
|
||||
let codegen_unit = codegen_units.entry(codegen_unit_name.clone())
|
||||
.or_insert_with(make_codegen_unit);
|
||||
let codegen_unit = codegen_units.entry(codegen_unit_name.clone())
|
||||
.or_insert_with(make_codegen_unit);
|
||||
|
||||
let (linkage, visibility) = match trans_item.explicit_linkage(tcx) {
|
||||
Some(explicit_linkage) => (explicit_linkage, Visibility::Default),
|
||||
None => {
|
||||
match trans_item {
|
||||
TransItem::Fn(ref instance) => {
|
||||
let visibility = match instance.def {
|
||||
InstanceDef::Item(def_id) => {
|
||||
if def_id.is_local() {
|
||||
if tcx.is_exported_symbol(def_id) {
|
||||
Visibility::Default
|
||||
} else {
|
||||
internalization_candidates.insert(trans_item);
|
||||
Visibility::Hidden
|
||||
}
|
||||
let (linkage, visibility) = match trans_item.explicit_linkage(tcx) {
|
||||
Some(explicit_linkage) => (explicit_linkage, Visibility::Default),
|
||||
None => {
|
||||
match trans_item {
|
||||
TransItem::Fn(ref instance) => {
|
||||
let visibility = match instance.def {
|
||||
InstanceDef::Item(def_id) => {
|
||||
if def_id.is_local() {
|
||||
if tcx.is_exported_symbol(def_id) {
|
||||
Visibility::Default
|
||||
} else {
|
||||
internalization_candidates.insert(trans_item);
|
||||
Visibility::Hidden
|
||||
}
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
}
|
||||
InstanceDef::FnPtrShim(..) |
|
||||
InstanceDef::Virtual(..) |
|
||||
InstanceDef::Intrinsic(..) |
|
||||
InstanceDef::ClosureOnceShim { .. } |
|
||||
InstanceDef::DropGlue(..) |
|
||||
InstanceDef::CloneShim(..) => {
|
||||
bug!("partitioning: Encountered unexpected
|
||||
root translation item: {:?}",
|
||||
trans_item)
|
||||
}
|
||||
};
|
||||
(Linkage::External, visibility)
|
||||
}
|
||||
TransItem::Static(node_id) |
|
||||
TransItem::GlobalAsm(node_id) => {
|
||||
let def_id = tcx.hir.local_def_id(node_id);
|
||||
let visibility = if tcx.is_exported_symbol(def_id) {
|
||||
Visibility::Default
|
||||
} else {
|
||||
internalization_candidates.insert(trans_item);
|
||||
}
|
||||
InstanceDef::FnPtrShim(..) |
|
||||
InstanceDef::Virtual(..) |
|
||||
InstanceDef::Intrinsic(..) |
|
||||
InstanceDef::ClosureOnceShim { .. } |
|
||||
InstanceDef::DropGlue(..) |
|
||||
InstanceDef::CloneShim(..) => {
|
||||
Visibility::Hidden
|
||||
};
|
||||
(Linkage::External, visibility)
|
||||
}
|
||||
}
|
||||
};
|
||||
(Linkage::External, visibility)
|
||||
}
|
||||
TransItem::Static(node_id) |
|
||||
TransItem::GlobalAsm(node_id) => {
|
||||
let def_id = tcx.hir.local_def_id(node_id);
|
||||
let visibility = if tcx.is_exported_symbol(def_id) {
|
||||
Visibility::Default
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
};
|
||||
(Linkage::External, visibility)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
codegen_unit.items_mut().insert(trans_item, (linkage, visibility));
|
||||
roots.insert(trans_item);
|
||||
}
|
||||
};
|
||||
if visibility == Visibility::Hidden {
|
||||
internalization_candidates.insert(trans_item);
|
||||
}
|
||||
|
||||
codegen_unit.items_mut().insert(trans_item, (linkage, visibility));
|
||||
roots.insert(trans_item);
|
||||
}
|
||||
|
||||
// always ensure we have at least one CGU; otherwise, if we have a
|
||||
|
@ -390,15 +389,6 @@ fn merge_codegen_units<'tcx>(initial_partitioning: &mut PreInliningPartitioning<
|
|||
for (index, cgu) in codegen_units.iter_mut().enumerate() {
|
||||
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>,
|
||||
|
|
|
@ -26,6 +26,7 @@ use monomorphize::Instance;
|
|||
use rustc::hir;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::trans::{Linkage, Visibility};
|
||||
use rustc::session::config::OptLevel;
|
||||
use rustc::traits;
|
||||
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc::ty::subst::{Subst, Substs};
|
||||
|
@ -44,7 +45,20 @@ pub use rustc::middle::trans::TransItem;
|
|||
pub enum InstantiationMode {
|
||||
/// 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.
|
||||
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
|
||||
/// 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,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> 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() {
|
||||
TransItem::Fn(ref instance) => {
|
||||
if self.explicit_linkage(tcx).is_none() &&
|
||||
common::requests_inline(tcx, instance)
|
||||
{
|
||||
InstantiationMode::LocalCopy
|
||||
if inline_in_all_cgus {
|
||||
InstantiationMode::LocalCopy
|
||||
} else {
|
||||
InstantiationMode::GloballyShared { may_conflict: true }
|
||||
}
|
||||
} else {
|
||||
InstantiationMode::GloballyShared
|
||||
InstantiationMode::GloballyShared { may_conflict: false }
|
||||
}
|
||||
}
|
||||
TransItem::Static(..) => InstantiationMode::GloballyShared,
|
||||
TransItem::GlobalAsm(..) => InstantiationMode::GloballyShared,
|
||||
TransItem::Static(..) => {
|
||||
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`,
|
||||
/// `&self`, `&mut self`, or `Box<self>`. We do this here
|
||||
/// 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:
|
||||
///
|
||||
|
@ -1475,7 +1475,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
|||
/// fn method2(self: &T); // ExplicitSelf::ByValue
|
||||
/// 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
|
||||
/// }
|
||||
/// ```
|
||||
|
|
|
@ -337,7 +337,6 @@ impl<'a> fmt::Display for Html<'a> {
|
|||
"l4re" => "L4Re",
|
||||
"linux" => "Linux",
|
||||
"macos" => "macOS",
|
||||
"nacl" => "NaCl",
|
||||
"netbsd" => "NetBSD",
|
||||
"openbsd" => "OpenBSD",
|
||||
"redox" => "Redox",
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
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)
|
||||
.and_then(|mut f| f.read_to_end(&mut contents));
|
||||
if let Err(e) = result {
|
||||
let _ = writeln!(&mut io::stderr(),
|
||||
"error reading `{}`: {}",
|
||||
file_path.display(), e);
|
||||
eprintln!("error reading `{}`: {}", file_path.display(), e);
|
||||
return Err(LoadStringError::ReadFail);
|
||||
}
|
||||
match str::from_utf8(&contents) {
|
||||
Ok(s) => Ok(s.to_string()),
|
||||
Err(_) => {
|
||||
let _ = writeln!(&mut io::stderr(),
|
||||
"error reading `{}`: not UTF-8",
|
||||
file_path.display());
|
||||
eprintln!("error reading `{}`: not UTF-8", file_path.display());
|
||||
Err(LoadStringError::BadUtf8)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
use std::default::Default;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::io;
|
||||
use std::path::{PathBuf, Path};
|
||||
|
||||
use getopts;
|
||||
|
@ -75,9 +74,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
|
|||
|
||||
let mut out = match File::create(&output) {
|
||||
Err(e) => {
|
||||
let _ = writeln!(&mut io::stderr(),
|
||||
"rustdoc: {}: {}",
|
||||
output.display(), e);
|
||||
eprintln!("rustdoc: {}: {}", output.display(), e);
|
||||
return 4;
|
||||
}
|
||||
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);
|
||||
if metadata.is_empty() {
|
||||
let _ = writeln!(
|
||||
&mut io::stderr(),
|
||||
"rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`"
|
||||
);
|
||||
eprintln!("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`");
|
||||
return 5;
|
||||
}
|
||||
let title = metadata[0];
|
||||
|
@ -138,9 +132,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
|
|||
|
||||
match err {
|
||||
Err(e) => {
|
||||
let _ = writeln!(&mut io::stderr(),
|
||||
"rustdoc: cannot write to `{}`: {}",
|
||||
output.display(), e);
|
||||
eprintln!("rustdoc: cannot write to `{}`: {}", output.display(), e);
|
||||
6
|
||||
}
|
||||
Ok(_) => 0
|
||||
|
|
|
@ -495,11 +495,10 @@ impl Collector {
|
|||
found = entry.remove_item(&test).is_some();
|
||||
}
|
||||
if !found {
|
||||
let _ = writeln!(&mut io::stderr(),
|
||||
"WARNING: {} Code block is not currently run as a test, but will \
|
||||
in future versions of rustdoc. Please ensure this code block is \
|
||||
a runnable test, or use the `ignore` directive.",
|
||||
name);
|
||||
eprintln!("WARNING: {} Code block is not currently run as a test, but will \
|
||||
in future versions of rustdoc. Please ensure this code block is \
|
||||
a runnable test, or use the `ignore` directive.",
|
||||
name);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ pub mod linux;
|
|||
#[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 = "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 = "openbsd"))] pub mod openbsd;
|
||||
#[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")]
|
||||
pub struct Stdio(imp::Stdio);
|
||||
|
||||
impl Stdio {
|
||||
/// 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")]
|
||||
pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) }
|
||||
|
||||
/// 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")]
|
||||
pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) }
|
||||
|
||||
/// This stream will be ignored. This is the equivalent of attaching the
|
||||
/// 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")]
|
||||
pub fn null() -> Stdio { Stdio(imp::Stdio::Null) }
|
||||
}
|
||||
|
@ -1083,8 +1190,6 @@ impl Child {
|
|||
/// function and compute the exit code from its return value:
|
||||
///
|
||||
/// ```
|
||||
/// use std::io::{self, Write};
|
||||
///
|
||||
/// fn run_app() -> Result<(), ()> {
|
||||
/// // Application logic here
|
||||
/// Ok(())
|
||||
|
@ -1094,7 +1199,7 @@ impl Child {
|
|||
/// ::std::process::exit(match run_app() {
|
||||
/// Ok(_) => 0,
|
||||
/// Err(err) => {
|
||||
/// writeln!(io::stderr(), "error: {:?}", err).unwrap();
|
||||
/// eprintln!("error: {:?}", err);
|
||||
/// 1
|
||||
/// }
|
||||
/// });
|
||||
|
|
|
@ -919,7 +919,7 @@ impl<T> Drop for Sender<T> {
|
|||
#[stable(feature = "mpsc_debug", since = "1.8.0")]
|
||||
impl<T> fmt::Debug for Sender<T> {
|
||||
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")]
|
||||
impl<T> fmt::Debug for SyncSender<T> {
|
||||
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")]
|
||||
impl<T> fmt::Debug for Receiver<T> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
#[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 {
|
||||
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> {
|
||||
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> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
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)) => {
|
||||
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> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
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)) => {
|
||||
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 = "";
|
||||
}
|
||||
|
||||
#[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")]
|
||||
pub mod os {
|
||||
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 = "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 = "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 = "openbsd"))] pub use os::openbsd as platform;
|
||||
#[cfg(all(not(dox), target_os = "solaris"))] pub use os::solaris as platform;
|
||||
|
@ -77,11 +76,11 @@ pub fn init() {
|
|||
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() {
|
||||
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() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -483,12 +483,10 @@ pub fn home_dir() -> Option<PathBuf> {
|
|||
|
||||
#[cfg(any(target_os = "android",
|
||||
target_os = "ios",
|
||||
target_os = "nacl",
|
||||
target_os = "emscripten"))]
|
||||
unsafe fn fallback() -> Option<OsString> { None }
|
||||
#[cfg(not(any(target_os = "android",
|
||||
target_os = "ios",
|
||||
target_os = "nacl",
|
||||
target_os = "emscripten")))]
|
||||
unsafe fn fallback() -> Option<OsString> {
|
||||
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]
|
||||
#[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,
|
||||
// although the reason isn't very clear as to why. For now this test is
|
||||
// ignored there.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use io;
|
||||
use libc;
|
||||
use libc::{self, size_t};
|
||||
use mem;
|
||||
use ptr;
|
||||
|
||||
|
@ -148,8 +148,8 @@ impl Process {
|
|||
use sys::process::zircon::*;
|
||||
|
||||
let mut proc_info: zx_info_process_t = Default::default();
|
||||
let mut actual: zx_size_t = 0;
|
||||
let mut avail: zx_size_t = 0;
|
||||
let mut actual: size_t = 0;
|
||||
let mut avail: size_t = 0;
|
||||
|
||||
unsafe {
|
||||
zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
|
||||
|
@ -171,8 +171,8 @@ impl Process {
|
|||
use sys::process::zircon::*;
|
||||
|
||||
let mut proc_info: zx_info_process_t = Default::default();
|
||||
let mut actual: zx_size_t = 0;
|
||||
let mut avail: zx_size_t = 0;
|
||||
let mut actual: size_t = 0;
|
||||
let mut avail: size_t = 0;
|
||||
|
||||
unsafe {
|
||||
let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
|
||||
|
|
|
@ -184,8 +184,8 @@ impl Command {
|
|||
*sys::os::environ() = envp.as_ptr();
|
||||
}
|
||||
|
||||
// NaCl has no signal support.
|
||||
#[cfg(not(any(target_os = "nacl", target_os = "emscripten")))]
|
||||
// emscripten has no signal support.
|
||||
#[cfg(not(any(target_os = "emscripten")))]
|
||||
{
|
||||
use mem;
|
||||
// Reset signal handling so the child process starts in a
|
||||
|
|
|
@ -15,15 +15,13 @@ use io;
|
|||
use os::raw::c_char;
|
||||
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_rights_t = u32;
|
||||
pub type zx_status_t = i32;
|
||||
|
||||
pub type zx_size_t = usize;
|
||||
|
||||
pub const ZX_HANDLE_INVALID: zx_handle_t = 0;
|
||||
|
||||
pub type zx_time_t = u64;
|
||||
|
@ -115,36 +113,37 @@ extern {
|
|||
pending: *mut zx_signals_t) -> zx_status_t;
|
||||
|
||||
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,
|
||||
avail: *mut zx_size_t) -> zx_status_t;
|
||||
buffer_size: size_t, actual_size: *mut size_t,
|
||||
avail: *mut size_t) -> zx_status_t;
|
||||
}
|
||||
|
||||
// From `enum special_handles` in system/ulib/launchpad/launchpad.c
|
||||
// HND_LOADER_SVC = 0
|
||||
// HND_EXEC_VMO = 1
|
||||
pub const HND_SPECIAL_COUNT: usize = 2;
|
||||
// HND_SEGMENTS_VMAR = 2
|
||||
const HND_SPECIAL_COUNT: c_int = 3;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct launchpad_t {
|
||||
argc: u32,
|
||||
envc: u32,
|
||||
args: *const c_char,
|
||||
args_len: usize,
|
||||
args_len: size_t,
|
||||
env: *const c_char,
|
||||
env_len: usize,
|
||||
env_len: size_t,
|
||||
|
||||
handles: *mut zx_handle_t,
|
||||
handles_info: *mut u32,
|
||||
handle_count: usize,
|
||||
handle_alloc: usize,
|
||||
handle_count: size_t,
|
||||
handle_alloc: size_t,
|
||||
|
||||
entry: zx_vaddr_t,
|
||||
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,
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// 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
|
||||
/// supported platforms.
|
||||
|
||||
|
|
|
@ -116,11 +116,18 @@ impl<T> Drop for ReentrantMutex<T> {
|
|||
impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
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)) => {
|
||||
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 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 || {
|
||||
/// println!("{}", rx.recv().unwrap());
|
||||
/// let value = rx.recv().expect("Unable to receive from channel");
|
||||
/// println!("{}", value);
|
||||
/// });
|
||||
///
|
||||
/// let _ = sender.join();
|
||||
/// let _ = receiver.join();
|
||||
/// sender.join().expect("The sender thread has panicked");
|
||||
/// receiver.join().expect("The receiver thread has panicked");
|
||||
/// ```
|
||||
///
|
||||
/// 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.");
|
||||
///
|
||||
/// // 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) {
|
||||
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.
|
||||
type_err.cancel();
|
||||
|
||||
// Report non-fatal diagnostics, keep `x as usize` as an expression
|
||||
// in AST and continue parsing.
|
||||
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);
|
||||
err.span_label(self.look_ahead_span(1).to(parser_snapshot_after_type.span),
|
||||
"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 {
|
||||
span: path.span,
|
||||
|
@ -2911,7 +2924,7 @@ impl<'a> Parser<'a> {
|
|||
let expr_str = self.sess.codemap().span_to_snippet(expr.span)
|
||||
.unwrap_or(pprust::expr_to_string(&expr));
|
||||
err.span_suggestion(expr.span,
|
||||
"try comparing the casted value",
|
||||
&format!("try {} the casted value", op_verb),
|
||||
format!("({})", expr_str));
|
||||
err.emit();
|
||||
|
||||
|
|
|
@ -339,8 +339,11 @@ impl serialize::UseSpecializedDecodable for Span {
|
|||
}
|
||||
|
||||
fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Span {{ lo: {:?}, hi: {:?}, ctxt: {:?} }}",
|
||||
span.lo(), span.hi(), span.ctxt())
|
||||
f.debug_struct("Span")
|
||||
.field("lo", &span.lo())
|
||||
.field("hi", &span.hi())
|
||||
.field("ctxt", &span.ctxt())
|
||||
.finish()
|
||||
}
|
||||
|
||||
impl fmt::Debug for Span {
|
||||
|
|
|
@ -1554,16 +1554,14 @@ impl MetricMap {
|
|||
/// elimination.
|
||||
///
|
||||
/// This function is a no-op, and does not even read from `dummy`.
|
||||
#[cfg(not(any(all(target_os = "nacl", target_arch = "le32"),
|
||||
target_arch = "asmjs", target_arch = "wasm32")))]
|
||||
#[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))]
|
||||
pub fn black_box<T>(dummy: T) -> T {
|
||||
// we need to "use" the argument in some way LLVM can't
|
||||
// introspect.
|
||||
unsafe { asm!("" : : "r"(&dummy)) }
|
||||
dummy
|
||||
}
|
||||
#[cfg(any(all(target_os = "nacl", target_arch = "le32"),
|
||||
target_arch = "asmjs", target_arch = "wasm32"))]
|
||||
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))]
|
||||
#[inline(never)]
|
||||
pub fn black_box<T>(dummy: T) -> T {
|
||||
dummy
|
||||
|
|
|
@ -57,7 +57,7 @@ static AtomicOrdering fromRust(LLVMAtomicOrdering Ordering) {
|
|||
llvm_unreachable("Invalid LLVMAtomicOrdering value!");
|
||||
}
|
||||
|
||||
static char *LastError;
|
||||
static LLVM_THREAD_LOCAL char *LastError;
|
||||
|
||||
extern "C" LLVMMemoryBufferRef
|
||||
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// 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]
|
||||
struct StructWithDtor(u32);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// compile-flags:-Zprint-trans-items=eager
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// compile-flags:-Zprint-trans-items=eager
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// compile-flags:-Zprint-trans-items=eager
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// compile-flags:-Zprint-trans-items=eager
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// compile-flags:-Zprint-trans-items=eager
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
// compile-flags:-Zprint-trans-items=eager
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![deny(dead_code)]
|
||||
#![feature(coerce_unsized)]
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// 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/extern-drop-glue
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![crate_type="lib"]
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// 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/inlining-from-extern-crate
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![crate_type="lib"]
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// 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-drop-glue
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![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
|
||||
// incremental compilation
|
||||
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-inlining
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![crate_type="lib"]
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// 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-transitive-inlining
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![crate_type="lib"]
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// 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/vtable-through-const
|
||||
// compile-flags:-Zinline-in-all-cgus
|
||||
|
||||
// This test case makes sure, that references made through constants are
|
||||
// recorded properly in the InliningMap.
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
|
|||
#[no_mangle]
|
||||
pub fn add(x: f32, y: f32) -> f32 {
|
||||
// CHECK: fadd float
|
||||
// CHECK-NOT fast
|
||||
// CHECK-NOT: fast
|
||||
x + y
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Zincremental=tmp/cfail-tests/incr_comp_with_macro_export
|
||||
// revisions: cfail1 cfail2 cfail3
|
||||
// must-compile-successfully
|
||||
|
||||
|
||||
// This test case makes sure that we can compile with incremental compilation
|
||||
// enabled when there are macros exported from this crate. (See #37756)
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
// error-pattern:panic 1
|
||||
// error-pattern:drop 2
|
||||
use std::io::{self, Write};
|
||||
|
||||
struct Droppable(u32);
|
||||
impl Drop for Droppable {
|
||||
|
@ -18,7 +17,7 @@ impl Drop for Droppable {
|
|||
if self.0 == 1 {
|
||||
panic!("panic 1");
|
||||
} else {
|
||||
write!(io::stderr(), "drop {}", self.0);
|
||||
eprint!("drop {}", self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// except according to those terms.
|
||||
// error-pattern:drop 1
|
||||
// error-pattern:drop 2
|
||||
use std::io::{self, Write};
|
||||
|
||||
|
||||
/// 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> {
|
||||
fn drop(&mut self) {
|
||||
if *self.0 {
|
||||
writeln!(io::stderr(), "{} dropped twice", self.1);
|
||||
eprintln!("{} dropped twice", self.1);
|
||||
::std::process::exit(1);
|
||||
}
|
||||
writeln!(io::stderr(), "drop {}", self.1);
|
||||
eprintln!("drop {}", self.1);
|
||||
*self.0 = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
// error-pattern:drop 1
|
||||
use std::io::{self, Write};
|
||||
|
||||
|
||||
/// 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> {
|
||||
fn drop(&mut self) {
|
||||
if *self.0 {
|
||||
writeln!(io::stderr(), "{} dropped twice", self.1);
|
||||
eprintln!("{} dropped twice", self.1);
|
||||
::std::process::exit(1);
|
||||
}
|
||||
writeln!(io::stderr(), "drop {}", self.1);
|
||||
eprintln!("drop {}", self.1);
|
||||
*self.0 = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
// error-pattern:drop 3
|
||||
// error-pattern:drop 2
|
||||
// error-pattern:drop 1
|
||||
use std::io::{self, Write};
|
||||
|
||||
|
||||
/// 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> {
|
||||
fn drop(&mut self) {
|
||||
if *self.0 {
|
||||
writeln!(io::stderr(), "{} dropped twice", self.1);
|
||||
eprintln!("{} dropped twice", self.1);
|
||||
::std::process::exit(1);
|
||||
}
|
||||
writeln!(io::stderr(), "drop {}", self.1);
|
||||
eprintln!("drop {}", self.1);
|
||||
*self.0 = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,15 @@
|
|||
// error-pattern:0 dropped
|
||||
// error-pattern:exit
|
||||
|
||||
use std::io::{self, Write};
|
||||
|
||||
struct Droppable(u8);
|
||||
impl Drop for Droppable {
|
||||
fn drop(&mut self) {
|
||||
write!(io::stderr(), "{} dropped\n", self.0);
|
||||
eprintln!("{} dropped", self.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn converging_fn() {
|
||||
write!(io::stderr(), "converging_fn called\n");
|
||||
eprintln!("converging_fn called");
|
||||
}
|
||||
|
||||
fn mir(d: Droppable) {
|
||||
|
|
|
@ -12,18 +12,16 @@
|
|||
// error-pattern:dropped
|
||||
// error-pattern:exit
|
||||
|
||||
use std::io::{self, Write};
|
||||
|
||||
struct Droppable;
|
||||
impl Drop for Droppable {
|
||||
fn drop(&mut self) {
|
||||
write!(io::stderr(), "dropped\n");
|
||||
eprintln!("dropped");
|
||||
}
|
||||
}
|
||||
|
||||
// return value of this function is copied into the return slot
|
||||
fn complex() -> u64 {
|
||||
write!(io::stderr(), "complex called\n");
|
||||
eprintln!("complex called");
|
||||
42
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
// error-pattern:diverging_fn called
|
||||
// error-pattern:0 dropped
|
||||
|
||||
use std::io::{self, Write};
|
||||
|
||||
struct Droppable(u8);
|
||||
impl Drop for Droppable {
|
||||
fn drop(&mut self) {
|
||||
write!(io::stderr(), "{} dropped", self.0);
|
||||
eprintln!("{} dropped", self.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
#![feature(panic_handler)]
|
||||
|
||||
use std::panic;
|
||||
use std::io::{self, Write};
|
||||
|
||||
fn main() {
|
||||
panic::set_hook(Box::new(|i| {
|
||||
write!(io::stderr(), "greetings from the panic handler");
|
||||
eprint!("greetings from the panic handler");
|
||||
}));
|
||||
panic!("foobar");
|
||||
}
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
#![feature(panic_handler)]
|
||||
|
||||
use std::panic;
|
||||
use std::io::{self, Write};
|
||||
|
||||
fn main() {
|
||||
panic::set_hook(Box::new(|i| {
|
||||
write!(io::stderr(), "greetings from the panic handler");
|
||||
eprint!("greetings from the panic handler");
|
||||
}));
|
||||
panic::take_hook();
|
||||
panic!("foobar");
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
all:
|
||||
$(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" ]
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
# in only one compilation unit.
|
||||
|
||||
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\ internal\ i32\ .*inlined)" -eq "2" ]
|
||||
[ "$$(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-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=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 -
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"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",
|
||||
"llvm-target": "x86_64-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
|
@ -19,8 +19,6 @@
|
|||
// ignore-pretty issue #37195
|
||||
// ignore-emscripten spawning processes is not supported
|
||||
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::env;
|
||||
|
||||
#[path = "backtrace-debuginfo-aux.rs"] mod aux;
|
||||
|
@ -163,7 +161,7 @@ fn main() {
|
|||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() >= 2 {
|
||||
let case = args[1].parse().unwrap();
|
||||
writeln!(&mut io::stderr(), "test case {}", case).unwrap();
|
||||
eprintln!("test case {}", case);
|
||||
outer(case, pos!());
|
||||
println!("done.");
|
||||
} else {
|
||||
|
|
|
@ -35,5 +35,7 @@ fn main() {
|
|||
<
|
||||
5);
|
||||
|
||||
println!("{}", a as usize << long_name);
|
||||
|
||||
println!("{}", a: &mut 4);
|
||||
}
|
||||
|
|
|
@ -76,9 +76,18 @@ help: try comparing the casted value
|
|||
33 |
|
||||
...
|
||||
|
||||
error: expected type, found `4`
|
||||
--> $DIR/issue-22644.rs:38:28
|
||||
error: `<` is interpreted as a start of generic arguments for `usize`, not a shift
|
||||
--> $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
|
||||
|
||||
|
|
|
@ -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
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
|
@ -8,9 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Nacl-specific definitions
|
||||
macro_rules! foo {
|
||||
($rest: tt) => {
|
||||
bar(baz: $rest)
|
||||
}
|
||||
}
|
||||
|
||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
||||
|
||||
pub mod raw;
|
||||
pub mod fs;
|
||||
fn main() {
|
||||
foo!(true);
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -489,15 +489,28 @@ fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf {
|
|||
}
|
||||
|
||||
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 mut inputs = vec![
|
||||
mtime(&testpaths.file),
|
||||
mtime(&config.rustc_path),
|
||||
];
|
||||
let mut inputs = vec![mtime(&testpaths.file), mtime(&config.rustc_path)];
|
||||
for aux in props.aux.iter() {
|
||||
inputs.push(mtime(&testpaths.file.parent().unwrap()
|
||||
.join("auxiliary")
|
||||
.join(aux)));
|
||||
inputs.push(mtime(
|
||||
&testpaths.file.parent().unwrap().join("auxiliary").join(
|
||||
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() {
|
||||
let lib = lib.unwrap();
|
||||
|
|
|
@ -571,9 +571,10 @@ actual:\n\
|
|||
}
|
||||
}
|
||||
|
||||
_=> {
|
||||
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");
|
||||
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path)
|
||||
.to_str()
|
||||
|
@ -664,19 +665,6 @@ actual:\n\
|
|||
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) {
|
||||
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||
|
||||
|
@ -735,7 +723,9 @@ actual:\n\
|
|||
script_str.push_str("version\n");
|
||||
|
||||
// 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_abs_path = rust_src_root.join(rust_pp_module_rel_path)
|
||||
.to_str()
|
||||
|
@ -1717,11 +1707,13 @@ actual:\n\
|
|||
if self.props.check_test_line_numbers_match {
|
||||
self.check_rustdoc_test_option(proc_res);
|
||||
} else {
|
||||
let root = self.find_rust_src_root().unwrap();
|
||||
let res = self.cmd2procres(Command::new(&self.config.docck_python)
|
||||
.arg(root.join("src/etc/htmldocck.py"))
|
||||
.arg(out_dir)
|
||||
.arg(&self.testpaths.file));
|
||||
let root = self.config.find_rust_src_root().unwrap();
|
||||
let res = self.cmd2procres(
|
||||
Command::new(&self.config.docck_python)
|
||||
.arg(root.join("src/etc/htmldocck.py"))
|
||||
.arg(out_dir)
|
||||
.arg(&self.testpaths.file),
|
||||
);
|
||||
if !res.status.success() {
|
||||
self.fatal_proc_rec("htmldocck failed!", &res);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,9 @@ macro_rules! t {
|
|||
|
||||
macro_rules! tidy_error {
|
||||
($bad:expr, $fmt:expr, $($arg:tt)*) => ({
|
||||
use std::io::Write;
|
||||
*$bad = true;
|
||||
write!(::std::io::stderr(), "tidy error: ").expect("could not write to stderr");
|
||||
writeln!(::std::io::stderr(), $fmt, $($arg)*).expect("could not write to stderr");
|
||||
eprint!("tidy error: ");
|
||||
eprintln!($fmt, $($arg)*);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ use tidy::*;
|
|||
use std::process;
|
||||
use std::path::PathBuf;
|
||||
use std::env;
|
||||
use std::io::{self, Write};
|
||||
|
||||
fn main() {
|
||||
let path = env::args_os().skip(1).next().expect("need an argument");
|
||||
|
@ -44,7 +43,7 @@ fn main() {
|
|||
}
|
||||
|
||||
if bad {
|
||||
writeln!(io::stderr(), "some tidy checks failed").expect("could not write to stderr");
|
||||
eprintln!("some tidy checks failed");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue