Auto merge of #23248 - Manishearth:rollup, r=Manishearth

This commit is contained in:
bors 2015-03-10 11:53:54 +00:00
commit 5f47c0613e
18 changed files with 571 additions and 199 deletions

2
configure vendored
View file

@ -701,8 +701,8 @@ probe CFG_ADB adb
if [ ! -z "$CFG_PANDOC" ]
then
# Extract "MAJOR MINOR" from Pandoc's version number
PV_MAJOR_MINOR=$(pandoc --version | grep '^pandoc' |
# Extract "MAJOR MINOR" from Pandoc's version number
sed -E 's/pandoc(.exe)? ([0-9]+)\.([0-9]+).*/\2 \3/')
MIN_PV_MAJOR="1"

View file

@ -7,224 +7,267 @@ rustc \- The Rust compiler
.SH DESCRIPTION
This program is a compiler for the Rust language, available at
<\fBhttps://www.rust-lang.org\fR>.
.UR https://www.rust\-lang.org
.UE .
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
Display the help message
Display the help message.
.TP
\fB\-\-cfg\fR SPEC
Configure the compilation environment
\fB\-\-cfg\fR \fISPEC\fR
Configure the compilation environment.
.TP
\fB\-L\fR [KIND=]PATH
Add a directory to the library search path. The optional KIND can be one of:
dependency = only lookup transitive dependencies here
crate = only lookup local `extern crate` directives here
native = only lookup native libraries here
framework = only look for OSX frameworks here
all = look for anything here (the default)
\fB\-L\fR [\fIKIND\fR=]\fIPATH\fR
Add a directory to the library search path.
The optional \fIKIND\fR can be one of:
.RS
.TP
\fB\-l\fR [KIND=]NAME
Link the generated crate(s) to the specified native library NAME. The optional
KIND can be one of, static, dylib, or framework. If omitted, dylib is assumed.
\fBdependency\fR
only lookup transitive dependencies here
.TP
\fB\-\-crate-type\fR [bin|lib|rlib|dylib|staticlib]
Comma separated list of types of crates for the compiler to emit
.B crate
only lookup local `extern crate` directives here
.TP
\fB\-\-crate-name NAME\fR
Specify the name of the crate being built
.B native
only lookup native libraries here
.TP
\fB\-\-emit\fR [asm|llvm-bc|llvm-ir|obj|link|dep-info]
Configure the output that rustc will produce
.B framework
only look for OSX frameworks here
.TP
\fB\-\-print\fR [crate-name|file-names|sysroot]
Comma separated list of compiler information to print on stdout
.B all
look for anything here (the default)
.RE
.TP
\fB\-l\fR [\fIKIND\fR=]\fINAME\fR
Link the generated crate(s) to the specified native library \fINAME\fR.
The optional \fIKIND\fR can be one of \fIstatic\fR, \fIdylib\fR, or
\fIframework\fR.
If omitted, \fIdylib\fR is assumed.
.TP
\fB\-\-crate\-type\fR [bin|lib|rlib|dylib|staticlib]
Comma separated list of types of crates for the compiler to emit.
.TP
\fB\-\-crate\-name\fR \fINAME\fR
Specify the name of the crate being built.
.TP
\fB\-\-emit\fR [asm|llvm\-bc|llvm\-ir|obj|link|dep\-info]
Configure the output that \fBrustc\fR will produce.
.TP
\fB\-\-print\fR [crate\-name|file\-names|sysroot]
Comma separated list of compiler information to print on stdout.
.TP
\fB\-g\fR
Equivalent to \fI\-C\fR debuginfo=2
Equivalent to \fI\-C\ debuginfo=2\fR.
.TP
\fB\-O\fR
Equivalent to \fI\-C\fR opt-level=2
Equivalent to \fI\-C\ opt\-level=2\fR.
.TP
\fB\-o\fR FILENAME
Write output to <filename>. Ignored if multiple \fI\-\-emit\fR outputs are
specified.
\fB\-o\fR \fIFILENAME\fR
Write output to \fIFILENAME\fR.
Ignored if multiple \fI\-\-emit\fR outputs are specified.
.TP
\fB\-\-out\-dir\fR DIR
Write output to compiler-chosen filename in <dir>. Ignored if \fI\-o\fR is
specified. Defaults to the current directory.
\fB\-\-out\-dir\fR \fIDIR\fR
Write output to compiler\[hy]chosen filename in \fIDIR\fR.
Ignored if \fI\-o\fR is specified.
Defaults to the current directory.
.TP
\fB\-\-explain\fR OPT
Provide a detailed explanation of an error message
\fB\-\-explain\fR \fIOPT\fR
Provide a detailed explanation of an error message.
.TP
\fB\-\-test\fR
Build a test harness
Build a test harness.
.TP
\fB\-\-target\fR TRIPLE
Target triple cpu-manufacturer-kernel[-os] to compile for (see chapter 3.4 of
http://www.sourceware.org/autobook/ for details)
\fB\-\-target\fR \fITRIPLE\fR
Target triple \fIcpu\fR\-\fImanufacturer\fR\-\fIkernel\fR[\-\fIos\fR]
to compile for (see chapter 3.4 of
.UR http://www.sourceware.org/autobook/
.UE
for details).
.TP
\fB\-W\fR help
Print 'lint' options and default settings
\fB\-W help\fR
Print 'lint' options and default settings.
.TP
\fB\-W\fR OPT, \fB\-\-warn\fR OPT
Set lint warnings
\fB\-W\fR \fIOPT\fR, \fB\-\-warn\fR \fIOPT\fR
Set lint warnings.
.TP
\fB\-A\fR OPT, \fB\-\-allow\fR OPT
Set lint allowed
\fB\-A\fR \fIOPT\fR, \fB\-\-allow\fR \fIOPT\fR
Set lint allowed.
.TP
\fB\-D\fR OPT, \fB\-\-deny\fR OPT
Set lint denied
\fB\-D\fR \fIOPT\fR, \fB\-\-deny\fR \fIOPT\fR
Set lint denied.
.TP
\fB\-F\fR OPT, \fB\-\-forbid\fR OPT
Set lint forbidden
\fB\-F\fR \fIOPT\fR, \fB\-\-forbid\fR \fIOPT\fR
Set lint forbidden.
.TP
\fB\-C\fR FLAG[=VAL], \fB\-\-codegen\fR FLAG[=VAL]
Set a codegen-related flag to the value specified. Use "-C help" to print
available flags. See CODEGEN OPTIONS below
\fB\-C\fR \fIFLAG\fR[=\fIVAL\fR], \fB\-\-codegen\fR \fIFLAG\fR[=\fIVAL\fR]
Set a codegen\[hy]related flag to the value specified.
Use \fI\-C help\fR to print available flags.
See CODEGEN OPTIONS below.
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version info and exit
Print version info and exit.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Use verbose output
Use verbose output.
.TP
\fB\-\-extern\fR NAME=PATH
Specify where an external rust library is located
\fB\-\-extern\fR \fINAME\fR=\fIPATH\fR
Specify where an external rust library is located.
.TP
\fB\-\-sysroot\fR PATH
Override the system root
\fB\-\-sysroot\fR \fIPATH\fR
Override the system root.
.TP
\fB\-Z\fR FLAG
Set internal debugging options. Use "-Z help" to print available options.
\fB\-Z\fR \fIFLAG\fR
Set internal debugging options.
Use \fI\-Z help\fR to print available options.
.TP
\fB\-\-color\fR auto|always|never
Configure coloring of output:
auto = colorize, if output goes to a tty (default);
always = always colorize output;
never = never colorize output
.RS
.TP
.B auto
colorize, if output goes to a tty (default);
.TP
.B always
always colorize output;
.TP
.B never
never colorize output.
.RE
.SH CODEGEN OPTIONS
.TP
\fBar\fR=/path/to/ar
\fBar\fR=\fI/path/to/ar\fR
Path to the archive utility to use when assembling archives.
.TP
\fBlinker\fR=/path/to/cc
\fBlinker\fR=\fI/path/to/cc\fR
Path to the linker utility to use when linking libraries, executables, and
objects.
.TP
\fBlink-args\fR='-flag1 -flag2'
A space-separated list of extra arguments to pass to the linker when the linker
\fBlink\-args\fR='\fI\-flag1 \-flag2\fR'
A space\[hy]separated list of extra arguments to pass to the linker when the linker
is invoked.
.TP
\fBlto\fR
Perform LLVM link-time optimizations.
Perform LLVM link\[hy]time optimizations.
.TP
\fBtarget-cpu\fR=help
Selects a target processor. If the value is 'help', then a list of available
CPUs is printed.
\fBtarget\-cpu\fR=\fIhelp\fR
Selects a target processor.
If the value is 'help', then a list of available CPUs is printed.
.TP
\fBtarget-feature\fR='+feature1,-feature2'
A comma-separated list of features to enable or disable for the target. A
preceding '+' enables a feature while a preceding '-' disables it. Available
features can be discovered through target-cpu=help.
\fBtarget\-feature\fR='\fI+feature1\fR,\fI\-feature2\fR'
A comma\[hy]separated list of features to enable or disable for the target.
A preceding '+' enables a feature while a preceding '\-' disables it.
Available features can be discovered through \fItarget\-cpu=help\fR.
.TP
\fBpasses\fR=list
A space-separated list of extra LLVM passes to run. A value of 'list' will
cause rustc to print all known passes and exit. The passes specified are
appended at the end of the normal pass manager.
\fBpasses\fR=\fIval\fR
A space\[hy]separated list of extra LLVM passes to run.
A value of 'list' will cause \fBrustc\fR to print all known passes and
exit.
The passes specified are appended at the end of the normal pass manager.
.TP
\fBllvm-args\fR='-arg1 -arg2'
A space-separated list of arguments to pass through to LLVM.
\fBllvm\-args\fR='\fI\-arg1\fR \fI\-arg2\fR'
A space\[hy]separated list of arguments to pass through to LLVM.
.TP
\fBsave-temps\fR
If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated
\fBsave\-temps\fR
If specified, the compiler will save more files (.bc, .o, .no\-opt.bc) generated
throughout compilation in the output directory.
.TP
\fBrpath\fR
If specified, then the rpath value for dynamic libraries will be set in
either dynamic library or executable outputs.
.TP
\fBno-prepopulate-passes\fR
Suppresses pre-population of the LLVM pass manager that is run over the module.
\fBno\-prepopulate\-passes\fR
Suppresses pre\[hy]population of the LLVM pass manager that is run over the module.
.TP
\fBno-vectorize-loops\fR
\fBno\-vectorize\-loops\fR
Suppresses running the loop vectorization LLVM pass, regardless of optimization
level.
.TP
\fBno-vectorize-slp\fR
\fBno\-vectorize\-slp\fR
Suppresses running the LLVM SLP vectorization pass, regardless of optimization
level.
.TP
\fBsoft-float\fR
\fBsoft\-float\fR
Generates software floating point library calls instead of hardware
instructions.
.TP
\fBprefer-dynamic\fR
\fBprefer\-dynamic\fR
Prefers dynamic linking to static linking.
.TP
\fBno-integrated-as\fR
\fBno\-integrated\-as\fR
Force usage of an external assembler rather than LLVM's integrated one.
.TP
\fBno-redzone\fR
\fBno\-redzone\fR
Disable the use of the redzone.
.TP
\fBrelocation-model\fR=[pic,static,dynamic-no-pic]
The relocation model to use. (Default: pic)
\fBrelocation\-model\fR=[pic,static,dynamic\-no\-pic]
The relocation model to use.
(Default: \fIpic\fR)
.TP
\fBcode-model\fR=[small,kernel,medium,large]
\fBcode\-model\fR=[small,kernel,medium,large]
Choose the code model to use.
.TP
\fBmetadata\fR=val
\fBmetadata\fR=\fIval\fR
Metadata to mangle symbol names with.
.TP
\fBextra-filename\fR=val
\fBextra\-filename\fR=\fIval\fR
Extra data to put in each output filename.
.TP
\fBcodegen-units\fR=val
Divide crate into N units to optimize in parallel.
\fBcodegen\-units\fR=\fIn\fR
Divide crate into \fIn\fR units to optimize in parallel.
.TP
\fBremark\fR=val
\fBremark\fR=\fIval\fR
Print remarks for these optimization passes (space separated, or "all").
.TP
\fBno-stack-check\fR
Disable checks for stack exhaustion (a memory-safety hazard!).
\fBno\-stack\-check\fR
Disable checks for stack exhaustion (a memory\[hy]safety hazard!).
.TP
\fBdebuginfo\fR=val
\fBdebuginfo\fR=\fIval\fR
Debug info emission level:
0 = no debug info;
1 = line-tables only (for stacktraces and breakpoints);
2 = full debug info with variable and type information.
.RS
.TP
\fBopt-level\fR=val
Optimize with possible levels 0-3
.B 0
no debug info;
.TP
.B 1
line\[hy]tables only (for stacktraces and breakpoints);
.TP
.B 2
full debug info with variable and type information.
.RE
.TP
\fBopt\-level\fR=\fIVAL\fR
Optimize with possible levels 0\[en]3
.SH "EXAMPLES"
To build an executable from a source file with a main function:
$ rustc -o hello hello.rs
$ rustc \-o hello hello.rs
To build a library from a source file:
$ rustc --crate-type=lib hello-lib.rs
$ rustc \-\-crate\-type=lib hello\-lib.rs
To build either with a crate (.rs) file:
$ rustc hello.rs
To build an executable with debug info:
$ rustc -g -o hello hello.rs
$ rustc \-g \-o hello hello.rs
.SH "SEE ALSO"
rustdoc
.BR rustdoc (1)
.SH "BUGS"
See <\fBhttps://github.com/rust-lang/rust/issues\fR> for issues.
See
.UR https://github.com/rust\-lang/rust/issues
.UE
for issues.
.SH "AUTHOR"
See \fBAUTHORS.txt\fR in the Rust source distribution.
See \fIAUTHORS.txt\fR in the Rust source distribution.
.SH "COPYRIGHT"
This work is dual-licensed under Apache 2.0 and MIT terms. See \fBCOPYRIGHT\fR
file in the rust source distribution.
This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.
See \fICOPYRIGHT\fR file in the rust source distribution.

View file

@ -8,76 +8,79 @@ rustdoc \- generate documentation from Rust source code
.SH DESCRIPTION
This tool generates API reference documentation by extracting comments from
source code written in the Rust language, available at
<\fBhttps://www.rust-lang.org\fR>. It accepts several input formats and provides
several output formats for the generated documentation.
.UR https://www.rust\-lang.org
.UE .
It accepts several input formats and provides several output formats
for the generated documentation.
.SH OPTIONS
.TP
-r --input-format <val>
\fB\-r\fR, \fB\-\-input\-format\fR \fIFORMAT\fR
html or json (default: inferred)
.TP
-w --output-format <val>
\fB\-w\fR, \fB\-\-output\-format\fR \fIFORMAT\fR
html or json (default: html)
.TP
-o --output <val>
where to place the output (default: doc/ for html, doc.json for json)
\fB\-o\fR, \fB\-\-output\fR \fIOUTPUT\fR
where to place the output (default: \fIdoc/\fR for html,
\fIdoc.json\fR for json)
.TP
--passes <val>
space-separated list of passes to run (default: '')
\fB\-\-passes\fR \fILIST\fR
space\[hy]separated list of passes to run (default: '')
.TP
--no-defaults
\fB\-\-no\-defaults\fR
don't run the default passes
.TP
--plugins <val>
\fB\-\-plugins\fR \fILIST\fR
space-separated list of plugins to run (default: '')
.TP
--plugin-path <val>
directory to load plugins from (default: /tmp/rustdoc_ng/plugins)
\fB\-\-plugin\-path\fR \fIDIR\fR
directory to load plugins from (default: \fI/tmp/rustdoc_ng/plugins\fR)
.TP
--target <val>
\fB\-\-target\fR \fITRIPLE\fR
target triple to document
.TP
--crate-name <val>
\fB\-\-crate\-name\fR \fINAME\fR
specify the name of this crate
.TP
-L --library-path <val>
\fB\-L\fR, \fB\-\-library\-path\fR \fIDIR\fR
directory to add to crate search path
.TP
--cfg <val>
pass a --cfg to rustc
\fB\-\-cfg\fR \fISPEC\fR
pass a \fI\-\-cfg\fR to rustc
.TP
--extern <val>
pass an --extern to rustc
\fB\-\-extern\fR \fIVAL\fR
pass an \fI\-\-extern\fR to rustc
.TP
--test
\fB\-\-test\fR
run code examples as tests
.TP
--test-args <val>
\fB\-\-test\-args\fR \fIARGS\fR
pass arguments to the test runner
.TP
--html-in-header <val>
\fB\-\-html\-in\-header\fR \fIFILE\fR
file to add to <head>
.TP
--html-before-content <val>
\fB\-\-html\-before\-content\fR \fIFILE\fR
file to add in <body>, before content
.TP
--html-after-content <val>
\fB\-\-html\-after\-content\fR \fIFILE\fR
file to add in <body>, after content
.TP
--markdown-css <val>
\fB\-\-markdown\-css\fR \fIFILE\fR
CSS files to include via <link> in a rendered Markdown file
.TP
--markdown-playground-url <val>
\fB\-\-markdown\-playground\-url\fR \fIURL\fR
URL to send code snippets to
.TP
--markdown-no-toc
\fB\-\-markdown\-no\-toc\fR
don't include table of contents
.TP
-h, --help
\fB\-h\fR, \fB\-\-help\fR
Print help
.TP
-V, --version
\fB\-V\fR, \fB\-\-version\fR
Print rustdoc's version
.SH "OUTPUT FORMATS"
@ -85,14 +88,15 @@ Print rustdoc's version
The rustdoc tool can generate output in either an HTML or JSON format.
If using an HTML format, then the specified output destination will be the root
directory of an HTML structure for all the documentation. Pages will be placed
into this directory, and source files will also possibly be rendered into it as
well.
directory of an HTML structure for all the documentation.
Pages will be placed into this directory, and source files will also
possibly be rendered into it as well.
If using a JSON format, then the specified output destination will have the
rustdoc output serialized as JSON into it. This output format exists to
pre-compile documentation for crates, and for usage in non-rustdoc tools. The
JSON output is the following hash:
rustdoc output serialized as JSON into it.
This output format exists to pre\[hy]compile documentation for crates,
and for usage in non\[hy]rustdoc tools.
The JSON output is the following hash:
{
"schema": VERSION,
@ -100,11 +104,12 @@ JSON output is the following hash:
"plugins": ...,
}
The schema version indicates what the structure of crate/plugins will look
like. Within a schema version the structure will remain the same. The `crate`
field will contain all relevant documentation for the source being documented,
and the `plugins` field will contain the output of the plugins run over the
crate.
The schema version indicates what the structure of crate/plugins will
look like.
Within a schema version the structure will remain the same.
The \fIcrate\fR field will contain all relevant documentation for the
source being documented, and the \fIplugins\fR field will contain the
output of the plugins run over the crate.
.SH "EXAMPLES"
@ -112,25 +117,28 @@ To generate documentation for the source in the current directory:
$ rustdoc hello.rs
List all available passes that rustdoc has, along with default passes:
$ rustdoc --passes list
$ rustdoc \-\-passes list
To precompile the documentation for a crate, and then use it to render html at
a later date:
$ rustdoc -w json hello.rs
$ rustdoc \-w json hello.rs
$ rustdoc doc.json
The generated HTML can be viewed with any standard web browser.
.SH "SEE ALSO"
rustc
.BR rustc (1)
.SH "BUGS"
See <\fBhttps://github.com/rust-lang/rust/issues\fR> for issues.
See
.UR https://github.com/rust\-lang/rust/issues
.UE
for issues.
.SH "AUTHOR"
See \fBAUTHORS.txt\fR in the Rust source distribution.
See \fIAUTHORS.txt\fR in the Rust source distribution.
.SH "COPYRIGHT"
This work is dual-licensed under Apache 2.0 and MIT terms. See \fBCOPYRIGHT\fR
file in the rust source distribution.
This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.
See \fICOPYRIGHT\fR file in the rust source distribution.

View file

@ -229,14 +229,14 @@ cases mentioned in [Number literals](#number-literals) below.
##### Characters and strings
| | Example | Number of `#` pairs allowed | Available characters | Escapes | Equivalent to |
|---|---------|-----------------------------|----------------------|---------|---------------|
| [Character](#character-literals) | `'H'` | `N/A` | All unicode | `\'` & [Byte escapes](#byte-escapes) & [Unicode escapes](#unicode-escapes) | `N/A` |
| [String](#string-literals) | `"hello"` | `N/A` | All unicode | `\"` & [Byte escapes](#byte-escapes) & [Unicode escapes](#unicode-escapes) | `N/A` |
| [Raw](#raw-string-literals) | `r##"hello"##` | `0...` | All unicode | `N/A` | `N/A` |
| [Byte](#byte-literals) | `b'H'` | `N/A` | All ASCII | `\'` & [Byte escapes](#byte-escapes) | `u8` |
| [Byte string](#byte-string-literals) | `b"hello"` | `N/A` | All ASCII | `\"` & [Byte escapes](#byte-escapes) | `&'static [u8]` |
| [Raw byte string](#raw-byte-string-literals) | `br##"hello"##` | `0...` | All ASCII | `N/A` | `&'static [u8]` (unsure...not stated) |
| | Example | # sets | Characters | Escapes |
|----------------------------------------------|---------------|--------|-------------|---------------------|
| [Character](#character-literals) | 'H' | N/A | All Unicode | \' & [Byte](#byte-escapes) & [Unicode](#unicode-escapes) |
| [String](#string-literals) | "hello" | N/A | All Unicode | \" & [Byte](#byte-escapes) & [Unicode](#unicode-escapes) |
| [Raw](#raw-string-literals) | r#"hello"# | 0... | All Unicode | N/A |
| [Byte](#byte-literals) | b'H' | N/A | All ASCII | \' & [Byte](#byte-escapes) |
| [Byte string](#byte-string-literals) | b"hello" | N/A | All ASCII | \" & [Byte](#byte-escapes) |
| [Raw byte string](#raw-byte-string-literals) | br#"hello"# | 0... | All ASCII | N/A |
##### Byte escapes

View file

@ -555,6 +555,13 @@ Here we have a `pub use` for each function we want to bring into the
`japanese` scope. We could alternatively use the wildcard syntax to include
everything from `greetings` into the current scope: `pub use self::greetings::*`.
What about the `self`? Well, by default, `use` declarations are absolute paths,
starting from your crate root. `self` makes that path relative to your current
place in the hierarchy instead. There's one more special form of `use`: you can
`use super::` to reach one level up the tree from your current location. Some
people like to think of `self` as `.` and `super` as `..`, from many shells'
display for the current directory and the parent directory.
Also, note that we `pub use`d before we declared our `mod`s. Rust requires that
`use` declarations go first.

View file

@ -1500,31 +1500,14 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
// panic occur before the ADT as a whole is ready.
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
// First we trans the base, if we have one, to the dest
if let Some(base) = optbase {
assert_eq!(discr, 0);
match ty::expr_kind(bcx.tcx(), &*base.expr) {
ty::RvalueDpsExpr | ty::RvalueDatumExpr if !bcx.fcx.type_needs_drop(ty) => {
bcx = trans_into(bcx, &*base.expr, SaveIn(addr));
},
ty::RvalueStmtExpr => bcx.tcx().sess.bug("unexpected expr kind for struct base expr"),
_ => {
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &*base.expr, "base"));
for &(i, t) in &base.fields {
let datum = base_datum.get_element(
bcx, t, |srcval| adt::trans_field_ptr(bcx, &*repr, srcval, discr, i));
assert!(type_is_sized(bcx.tcx(), datum.ty));
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
bcx = datum.store_to(bcx, dest);
}
}
}
}
debug_location.apply(bcx.fcx);
if ty::type_is_simd(bcx.tcx(), ty) {
// Issue 23112: The original logic appeared vulnerable to same
// order-of-eval bug. But, SIMD values are tuple-structs;
// i.e. functional record update (FRU) syntax is unavailable.
//
// To be safe, double-check that we did not get here via FRU.
assert!(optbase.is_none());
// This is the constructor of a SIMD type, such types are
// always primitive machine types and so do not have a
// destructor or require any clean-up.
@ -1543,8 +1526,45 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
vec_val = InsertElement(bcx, vec_val, value, position);
}
Store(bcx, vec_val, addr);
} else if let Some(base) = optbase {
// Issue 23112: If there is a base, then order-of-eval
// requires field expressions eval'ed before base expression.
// First, trans field expressions to temporary scratch values.
let scratch_vals: Vec<_> = fields.iter().map(|&(i, ref e)| {
let datum = unpack_datum!(bcx, trans(bcx, &**e));
(i, datum)
}).collect();
debug_location.apply(bcx.fcx);
// Second, trans the base to the dest.
assert_eq!(discr, 0);
match ty::expr_kind(bcx.tcx(), &*base.expr) {
ty::RvalueDpsExpr | ty::RvalueDatumExpr if !bcx.fcx.type_needs_drop(ty) => {
bcx = trans_into(bcx, &*base.expr, SaveIn(addr));
},
ty::RvalueStmtExpr => bcx.tcx().sess.bug("unexpected expr kind for struct base expr"),
_ => {
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &*base.expr, "base"));
for &(i, t) in &base.fields {
let datum = base_datum.get_element(
bcx, t, |srcval| adt::trans_field_ptr(bcx, &*repr, srcval, discr, i));
assert!(type_is_sized(bcx.tcx(), datum.ty));
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
bcx = datum.store_to(bcx, dest);
}
}
}
// Finally, move scratch field values into actual field locations
for (i, datum) in scratch_vals.into_iter() {
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
bcx = datum.store_to(bcx, dest);
}
} else {
// Now, we just overwrite the fields we've explicitly specified
// No base means we can write all fields directly in place.
for &(i, ref e) in fields {
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
let e_ty = expr_ty_adjusted(bcx, &**e);

View file

@ -83,7 +83,7 @@ h2 {
h3 {
font-size: 1.3em;
}
h1, h2, h3:not(.impl):not(.method):not(.type), h4:not(.method):not(.type) {
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
color: black;
font-weight: 500;
margin: 20px 0 15px 0;
@ -93,7 +93,7 @@ h1.fqn {
border-bottom: 1px dashed #D5D5D5;
margin-top: 0;
}
h2, h3:not(.impl):not(.method):not(.type), h4:not(.method):not(.type) {
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
border-bottom: 1px solid #DDDDDD;
}
h3.impl, h3.method, h4.method, h3.type, h4.type {

View file

@ -318,6 +318,7 @@
use prelude::v1::*;
use sync::Arc;
use error;
use fmt;
use mem;
use cell::UnsafeCell;
@ -975,6 +976,18 @@ impl<T> fmt::Display for SendError<T> {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> error::Error for SendError<T> {
fn description(&self) -> &str {
"sending on a closed channel"
}
fn cause(&self) -> Option<&error::Error> {
None
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> fmt::Debug for TrySendError<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -999,6 +1012,25 @@ impl<T> fmt::Display for TrySendError<T> {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> error::Error for TrySendError<T> {
fn description(&self) -> &str {
match *self {
TrySendError::Full(..) => {
"sending on a full channel"
}
TrySendError::Disconnected(..) => {
"sending on a closed channel"
}
}
}
fn cause(&self) -> Option<&error::Error> {
None
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for RecvError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -1006,6 +1038,18 @@ impl fmt::Display for RecvError {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl error::Error for RecvError {
fn description(&self) -> &str {
"receiving on a closed channel"
}
fn cause(&self) -> Option<&error::Error> {
None
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for TryRecvError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -1020,6 +1064,25 @@ impl fmt::Display for TryRecvError {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl error::Error for TryRecvError {
fn description(&self) -> &str {
match *self {
TryRecvError::Empty => {
"receiving on an empty channel"
}
TryRecvError::Disconnected => {
"receiving on a closed channel"
}
}
}
fn cause(&self) -> Option<&error::Error> {
None
}
}
#[cfg(test)]
mod test {
use prelude::v1::*;

View file

@ -0,0 +1,50 @@
// 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.
// Test that `quote`-related macro are gated by `quote` feature gate.
// (To sanity-check the code, uncomment this.)
// #![feature(quote)]
// FIXME the error message that is current emitted seems pretty bad.
#![feature(rustc_private)]
#![allow(dead_code, unused_imports, unused_variables)]
#[macro_use]
extern crate syntax;
use syntax::ast;
use syntax::codemap::Span;
use syntax::parse;
struct ParseSess;
impl ParseSess {
fn cfg(&self) -> ast::CrateConfig { loop { } }
fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess { loop { } }
fn call_site(&self) -> Span { loop { } }
fn ident_of(&self, st: &str) -> ast::Ident { loop { } }
fn name_of(&self, st: &str) -> ast::Name { loop { } }
}
pub fn main() {
let ecx = &ParseSess;
let x = quote_tokens!(ecx, 3); //~ ERROR macro undefined: 'quote_tokens!'
let x = quote_expr!(ecx, 3); //~ ERROR macro undefined: 'quote_expr!'
let x = quote_ty!(ecx, 3); //~ ERROR macro undefined: 'quote_ty!'
let x = quote_method!(ecx, 3); //~ ERROR macro undefined: 'quote_method!'
let x = quote_item!(ecx, 3); //~ ERROR macro undefined: 'quote_item!'
let x = quote_pat!(ecx, 3); //~ ERROR macro undefined: 'quote_pat!'
let x = quote_arm!(ecx, 3); //~ ERROR macro undefined: 'quote_arm!'
let x = quote_stmt!(ecx, 3); //~ ERROR macro undefined: 'quote_stmt!'
let x = quote_matcher!(ecx, 3); //~ ERROR macro undefined: 'quote_matcher!'
let x = quote_attr!(ecx, 3); //~ ERROR macro undefined: 'quote_attr!'
}

View file

@ -0,0 +1,19 @@
// 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.
// Test that `#[link_args]` attribute is gated by `link_args`
// feature gate.
#[link_args = "aFdEfSeVEEE"]
extern {}
//~^ ERROR the `link_args` attribute is not portable across platforms
//~| HELP add #![feature(link_args)] to the crate attributes to enable
fn main() { }

View file

@ -0,0 +1,19 @@
// 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.
extern {
#[link_name = "llvm.sqrt.f32"]
fn sqrt(x: f32) -> f32;
//~^ ERROR linking to LLVM intrinsics is experimental
//~| HELP add #![feature(link_llvm_intrinsics)] to the crate attributes
}
fn main(){
}

View file

@ -8,8 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that `#[plugin_registrar]` attribute is gated by `plugin_registrar`
// feature gate.
// the registration function isn't typechecked yet
#[plugin_registrar]
pub fn registrar() {} //~ ERROR compiler plugins are experimental
pub fn registrar() {}
//~^ ERROR compiler plugins are experimental
//~| HELP add #![feature(plugin_registrar)] to the crate attributes to enable
fn main() {}

View file

@ -0,0 +1,25 @@
// 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.
// Test that `#[thread_local]` attribute is gated by `thread_local`
// feature gate.
//
// (Note that the `thread_local!` macro is explicitly *not* gated; it
// is given permission to expand into this unstable attribute even
// when the surrounding context does not have permission to use it.)
#[thread_local] //~ ERROR `#[thread_local]` is an experimental feature
static FOO: i32 = 3;
pub fn main() {
FOO.with(|x| {
println!("x: {}", x);
});
}

View file

@ -0,0 +1,23 @@
// 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.
// Test that `#[unsafe_destructor]` attribute is gated by `unsafe_destructor`
// feature gate.
struct D<'a>(&'a u32);
#[unsafe_destructor]
impl<'a> Drop for D<'a> {
//~^ ERROR `#[unsafe_destructor]` allows too many unsafe patterns
fn drop(&mut self) { }
}
//~^ HELP: add #![feature(unsafe_destructor)] to the crate attributes to enable
pub fn main() { }

View file

@ -12,11 +12,12 @@ struct S { f0: String, f1: int }
pub fn main() {
let s = "Hello, world!".to_string();
let _s = S {
let s = S {
f0: s.to_string(),
..S {
f0: s,
f1: 23
}
};
assert_eq!(s.f0, "Hello, world!");
}

View file

@ -15,8 +15,9 @@ struct S {
pub fn main() {
let s = "Hello, world!".to_string();
let _s = S {
let s = S {
f1: s.to_string(),
f0: s
};
assert_eq!(s.f0, "Hello, world!");
}

View file

@ -0,0 +1,46 @@
// 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.
// Checks that functional-record-update order-of-eval is as expected
// even when no Drop-implementations are involved.
use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT};
struct W { wrapped: u32 }
struct S { f0: W, _f1: i32 }
pub fn main() {
const VAL: u32 = 0x89AB_CDEF;
let w = W { wrapped: VAL };
let s = S {
f0: { event(0x01); W { wrapped: w.wrapped + 1 } },
..S {
f0: { event(0x02); w},
_f1: 23
}
};
assert_eq!(s.f0.wrapped, VAL + 1);
let actual = event_log();
let expect = 0x01_02;
assert!(expect == actual,
"expect: 0x{:x} actual: 0x{:x}", expect, actual);
}
static LOG: AtomicUsize = ATOMIC_USIZE_INIT;
fn event_log() -> usize {
LOG.load(Ordering::SeqCst)
}
fn event(tag: u8) {
let old_log = LOG.load(Ordering::SeqCst);
let new_log = (old_log << 8) + tag as usize;
LOG.store(new_log, Ordering::SeqCst);
}

View file

@ -0,0 +1,43 @@
// 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.
// Checks that struct-literal expression order-of-eval is as expected
// even when no Drop-implementations are involved.
use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT};
struct W { wrapped: u32 }
struct S { f0: W, _f1: i32 }
pub fn main() {
const VAL: u32 = 0x89AB_CDEF;
let w = W { wrapped: VAL };
let s = S {
_f1: { event(0x01); 23 },
f0: { event(0x02); w },
};
assert_eq!(s.f0.wrapped, VAL);
let actual = event_log();
let expect = 0x01_02;
assert!(expect == actual,
"expect: 0x{:x} actual: 0x{:x}", expect, actual);
}
static LOG: AtomicUsize = ATOMIC_USIZE_INIT;
fn event_log() -> usize {
LOG.load(Ordering::SeqCst)
}
fn event(tag: u8) {
let old_log = LOG.load(Ordering::SeqCst);
let new_log = (old_log << 8) + tag as usize;
LOG.store(new_log, Ordering::SeqCst);
}