Skip to content

Commit f97a746

Browse files
committed
---
yaml --- r: 234719 b: refs/heads/tmp c: d557f4a h: refs/heads/master i: 234717: 9a8a4da 234715: ff2d65b 234711: 11a71f5 234703: a42f4c5 234687: f26a807 v: v3
1 parent eb52d18 commit f97a746

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+457
-267
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: cbc9517b023f3484816b59fd13993027c412748d
28+
refs/heads/tmp: d557f4a60f8071ec70e9147540d87b4eae153027
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/COMPILER_TESTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Compiler Test Documentation
22

3-
In the Rust project, we use a special set of comands imbedded in
3+
In the Rust project, we use a special set of comands embedded in
44
comments to test the Rust compiler. There are two groups of commands:
55

66
1. Header commands
@@ -29,11 +29,11 @@ The error levels that you can have are:
2929
3. `NOTE`
3030
4. `HELP` and `SUGGESTION`*
3131

32-
\* **Note**: `SUGGESTION` must follow emediatly after `HELP`.
32+
\* **Note**: `SUGGESTION` must follow immediately after `HELP`.
3333

3434
## Summary of Header Commands
3535

36-
Header commands specify something about the entire test file, as a
36+
Header commands specify something about the entire test file as a
3737
whole, instead of just a few lines inside the test.
3838

3939
* `ignore-X` where `X` is an architecture, OS or stage will ignore the test accordingly

branches/tmp/RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version 1.3.0 (September 2015)
1+
Version 1.3.0 (2015-09-17)
22
==============================
33

44
* ~900 changes, numerous bugfixes

branches/tmp/configure

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,12 @@ envopt CPP
10951095
envopt CFLAGS
10961096
envopt CXXFLAGS
10971097

1098+
# stdc++ name in use
1099+
# used to manage non-standard name (on OpenBSD for example)
1100+
program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p")
1101+
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
1102+
putvar CFG_STDCPP_NAME
1103+
10981104
# a little post-processing of various config values
10991105
CFG_PREFIX=${CFG_PREFIX%/}
11001106
CFG_MANDIR=${CFG_MANDIR%/}

branches/tmp/mk/llvm.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
7373

7474
ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
7575
LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
76-
-print-file-name=libstdc++.a))"
76+
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
7777
else
7878
LLVM_STDCPP_RUSTFLAGS_$(1) =
7979
endif
@@ -83,7 +83,7 @@ endif
8383
LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
8484
$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
8585
$(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
86-
$$(LLVM_CONFIG_$(1))
86+
$$(LLVM_CONFIG_$(1)) "$(CFG_STDCPP_NAME)"
8787
endef
8888

8989
$(foreach host,$(CFG_HOST), \

branches/tmp/src/doc/reference.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,22 @@ let px: i32 = match p { Point(x, _) => x };
11781178
```
11791179

11801180
A _unit-like struct_ is a structure without any fields, defined by leaving off
1181-
the list of fields entirely. Such types will have a single value. For example:
1181+
the list of fields entirely. Such a structure implicitly defines a constant of
1182+
its type with the same name. For example:
11821183

11831184
```
1185+
# #![feature(braced_empty_structs)]
11841186
struct Cookie;
1185-
let c = [Cookie, Cookie, Cookie, Cookie];
1187+
let c = [Cookie, Cookie {}, Cookie, Cookie {}];
1188+
```
1189+
1190+
is equivalent to
1191+
1192+
```
1193+
# #![feature(braced_empty_structs)]
1194+
struct Cookie {}
1195+
const Cookie: Cookie = Cookie {};
1196+
let c = [Cookie, Cookie {}, Cookie, Cookie {}];
11861197
```
11871198

11881199
The precise memory layout of a structure is not specified. One can specify a
@@ -2411,6 +2422,7 @@ The currently implemented features of the reference compiler are:
24112422
terms of encapsulation).
24122423
* - `default_type_parameter_fallback` - Allows type parameter defaults to
24132424
influence type inference.
2425+
* - `braced_empty_structs` - Allows use of empty structs with braces.
24142426

24152427
If a feature is promoted to a language feature, then all existing programs will
24162428
start to receive compilation warnings about `#![feature]` directives which enabled

branches/tmp/src/doc/trpl/error-handling.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
8787
Here's another example that is slightly less contrived. A program that accepts
8888
an integer as an argument, doubles it and prints it.
8989

90-
<a name="code-unwrap-double"/>
90+
<div id="code-unwrap-double">
9191
```rust,should_panic
9292
9393
use std::env;
@@ -99,6 +99,7 @@ fn main() {
9999
println!("{}", 2 * n);
100100
}
101101
```
102+
</div>
102103

103104
If you give this program zero arguments (error 1) or if the first argument
104105
isn't an integer (error 2), the program will panic just like in the first
@@ -139,7 +140,7 @@ system is an important concept because it will cause the compiler to force the
139140
programmer to handle that absence. Let's take a look at an example that tries
140141
to find a character in a string:
141142

142-
<a name="code-option-ex-string-find"/>
143+
<div id="code-option-ex-string-find">
143144
```rust
144145
// Searches `haystack` for the Unicode character `needle`. If one is found, the
145146
// byte offset of the character is returned. Otherwise, `None` is returned.
@@ -152,6 +153,7 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
152153
None
153154
}
154155
```
156+
</div>
155157

156158
Notice that when this function finds a matching character, it doen't just
157159
return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or

branches/tmp/src/etc/mklldeps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
components = sys.argv[2].split() # splits on whitespace
1818
enable_static = sys.argv[3]
1919
llvm_config = sys.argv[4]
20+
stdcpp_name = sys.argv[5]
2021

2122
f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2223
// file at the top-level directory of this distribution and at
@@ -77,15 +78,15 @@ def run(args):
7778
out = run([llvm_config, '--cxxflags'])
7879
if enable_static == '1':
7980
assert('stdlib=libc++' not in out)
80-
f.write("#[link(name = \"stdc++\", kind = \"static\")]\n")
81+
f.write("#[link(name = \"" + stdcpp_name + "\", kind = \"static\")]\n")
8182
else:
8283
# Note that we use `cfg_attr` here because on MSVC the C++ standard library
8384
# is not c++ or stdc++, but rather the linker takes care of linking the
8485
# right standard library.
8586
if 'stdlib=libc++' in out:
8687
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"c++\"))]\n")
8788
else:
88-
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"stdc++\"))]\n")
89+
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"" + stdcpp_name + "\"))]\n")
8990

9091
# Attach everything to an extern block
9192
f.write("extern {}\n")

branches/tmp/src/librustc_borrowck/borrowck/check_loans.rs

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -464,40 +464,36 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
464464

465465
match (new_loan.kind, old_loan.kind) {
466466
(ty::MutBorrow, ty::MutBorrow) => {
467-
self.bccx.span_err(
468-
new_loan.span,
469-
&format!("cannot borrow `{}`{} as mutable \
470-
more than once at a time",
471-
nl, new_loan_msg))
467+
span_err!(self.bccx, new_loan.span, E0499,
468+
"cannot borrow `{}`{} as mutable \
469+
more than once at a time",
470+
nl, new_loan_msg);
472471
}
473472

474473
(ty::UniqueImmBorrow, _) => {
475-
self.bccx.span_err(
476-
new_loan.span,
477-
&format!("closure requires unique access to `{}` \
478-
but {} is already borrowed{}",
479-
nl, ol_pronoun, old_loan_msg));
474+
span_err!(self.bccx, new_loan.span, E0500,
475+
"closure requires unique access to `{}` \
476+
but {} is already borrowed{}",
477+
nl, ol_pronoun, old_loan_msg);
480478
}
481479

482480
(_, ty::UniqueImmBorrow) => {
483-
self.bccx.span_err(
484-
new_loan.span,
485-
&format!("cannot borrow `{}`{} as {} because \
486-
previous closure requires unique access",
487-
nl, new_loan_msg, new_loan.kind.to_user_str()));
481+
span_err!(self.bccx, new_loan.span, E0501,
482+
"cannot borrow `{}`{} as {} because \
483+
previous closure requires unique access",
484+
nl, new_loan_msg, new_loan.kind.to_user_str());
488485
}
489486

490487
(_, _) => {
491-
self.bccx.span_err(
492-
new_loan.span,
493-
&format!("cannot borrow `{}`{} as {} because \
494-
{} is also borrowed as {}{}",
495-
nl,
496-
new_loan_msg,
497-
new_loan.kind.to_user_str(),
498-
ol_pronoun,
499-
old_loan.kind.to_user_str(),
500-
old_loan_msg));
488+
span_err!(self.bccx, new_loan.span, E0502,
489+
"cannot borrow `{}`{} as {} because \
490+
{} is also borrowed as {}{}",
491+
nl,
492+
new_loan_msg,
493+
new_loan.kind.to_user_str(),
494+
ol_pronoun,
495+
old_loan.kind.to_user_str(),
496+
old_loan_msg);
501497
}
502498
}
503499

@@ -617,11 +613,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
617613
match self.analyze_restrictions_on_use(id, copy_path, ty::ImmBorrow) {
618614
UseOk => { }
619615
UseWhileBorrowed(loan_path, loan_span) => {
620-
self.bccx.span_err(
621-
span,
622-
&format!("cannot use `{}` because it was mutably borrowed",
623-
&self.bccx.loan_path_to_string(copy_path))
624-
);
616+
span_err!(self.bccx, span, E0503,
617+
"cannot use `{}` because it was mutably borrowed",
618+
&self.bccx.loan_path_to_string(copy_path));
625619
self.bccx.span_note(
626620
loan_span,
627621
&format!("borrow of `{}` occurs here",
@@ -642,18 +636,19 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
642636
match self.analyze_restrictions_on_use(id, move_path, ty::MutBorrow) {
643637
UseOk => { }
644638
UseWhileBorrowed(loan_path, loan_span) => {
645-
let err_message = match move_kind {
639+
match move_kind {
646640
move_data::Captured =>
647-
format!("cannot move `{}` into closure because it is borrowed",
648-
&self.bccx.loan_path_to_string(move_path)),
641+
span_err!(self.bccx, span, E0504,
642+
"cannot move `{}` into closure because it is borrowed",
643+
&self.bccx.loan_path_to_string(move_path)),
649644
move_data::Declared |
650645
move_data::MoveExpr |
651646
move_data::MovePat =>
652-
format!("cannot move out of `{}` because it is borrowed",
653-
&self.bccx.loan_path_to_string(move_path))
647+
span_err!(self.bccx, span, E0505,
648+
"cannot move out of `{}` because it is borrowed",
649+
&self.bccx.loan_path_to_string(move_path))
654650
};
655651

656-
self.bccx.span_err(span, &err_message[..]);
657652
self.bccx.span_note(
658653
loan_span,
659654
&format!("borrow of `{}` occurs here",
@@ -820,10 +815,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
820815
span: Span,
821816
loan_path: &LoanPath<'tcx>,
822817
loan: &Loan) {
823-
self.bccx.span_err(
824-
span,
825-
&format!("cannot assign to `{}` because it is borrowed",
826-
self.bccx.loan_path_to_string(loan_path)));
818+
span_err!(self.bccx, span, E0506,
819+
"cannot assign to `{}` because it is borrowed",
820+
self.bccx.loan_path_to_string(loan_path));
827821
self.bccx.span_note(
828822
loan.span,
829823
&format!("borrow of `{}` occurs here",

branches/tmp/src/librustc_borrowck/borrowck/gather_loans/move_error.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
119119
mc::cat_deref(_, _, mc::Implicit(..)) |
120120
mc::cat_deref(_, _, mc::UnsafePtr(..)) |
121121
mc::cat_static_item => {
122-
bccx.span_err(move_from.span,
123-
&format!("cannot move out of {}",
124-
move_from.descriptive_string(bccx.tcx)));
122+
span_err!(bccx, move_from.span, E0507,
123+
"cannot move out of {}",
124+
move_from.descriptive_string(bccx.tcx));
125125
}
126126

127127
mc::cat_interior(ref b, mc::InteriorElement(Kind::Index, _)) => {
128128
let expr = bccx.tcx.map.expect_expr(move_from.id);
129129
if let hir::ExprIndex(..) = expr.node {
130-
bccx.span_err(move_from.span,
131-
&format!("cannot move out of type `{}`, \
132-
a non-copy fixed-size array",
133-
b.ty));
130+
span_err!(bccx, move_from.span, E0508,
131+
"cannot move out of type `{}`, \
132+
a non-copy fixed-size array",
133+
b.ty);
134134
}
135135
}
136136

@@ -139,11 +139,10 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
139139
match b.ty.sty {
140140
ty::TyStruct(def, _) |
141141
ty::TyEnum(def, _) if def.has_dtor() => {
142-
bccx.span_err(
143-
move_from.span,
144-
&format!("cannot move out of type `{}`, \
145-
which defines the `Drop` trait",
146-
b.ty));
142+
span_err!(bccx, move_from.span, E0509,
143+
"cannot move out of type `{}`, \
144+
which defines the `Drop` trait",
145+
b.ty);
147146
},
148147
_ => {
149148
bccx.span_bug(move_from.span, "this path should not cause illegal move")

branches/tmp/src/librustc_borrowck/borrowck/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
803803
self.tcx.sess.span_err(s, m);
804804
}
805805

806+
pub fn span_err_with_code(&self, s: Span, msg: &str, code: &str) {
807+
self.tcx.sess.span_err_with_code(s, msg, code);
808+
}
809+
806810
pub fn span_bug(&self, s: Span, m: &str) {
807811
self.tcx.sess.span_bug(s, m);
808812
}

branches/tmp/src/librustc_borrowck/diagnostics.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,50 @@ fn mutable() {
263263
You can read more about cell types in the API documentation:
264264
265265
https://doc.rust-lang.org/std/cell/
266-
"##
266+
"##,
267+
268+
E0499: r##"
269+
A variable was borrowed as mutable more than once. Erroneous code example:
270+
271+
```
272+
let mut i = 0;
273+
let mut x = &mut i;
274+
let mut a = &mut i;
275+
// error: cannot borrow `i` as mutable more than once at a time
276+
```
277+
278+
Please note that in rust, you can either have many immutable references, or one
279+
mutable reference. Take a look at
280+
https://doc.rust-lang.org/stable/book/references-and-borrowing.html for more
281+
information. Example:
282+
283+
284+
```
285+
let mut i = 0;
286+
let mut x = &mut i; // ok!
287+
288+
// or:
289+
let mut i = 0;
290+
let a = &i; // ok!
291+
let b = &i; // still ok!
292+
let c = &i; // still ok!
293+
```
294+
"##,
267295

268296
}
269297

270298
register_diagnostics! {
271299
E0385, // {} in an aliasable location
272300
E0388, // {} in a static location
273-
E0389 // {} in a `&` reference
301+
E0389, // {} in a `&` reference
302+
E0500, // closure requires unique access to `..` but .. is already borrowed
303+
E0501, // cannot borrow `..`.. as .. because previous closure requires unique access
304+
E0502, // cannot borrow `..`.. as .. because .. is also borrowed as ...
305+
E0503, // cannot use `..` because it was mutably borrowed
306+
E0504, // cannot move `..` into closure because it is borrowed
307+
E0505, // cannot move out of `..` because it is borrowed
308+
E0506, // cannot assign to `..` because it is borrowed
309+
E0507, // cannot move out of ..
310+
E0508, // cannot move out of type `..`, a non-copy fixed-size array
311+
E0509, // cannot move out of type `..`, which defines the `Drop` trait
274312
}

0 commit comments

Comments
 (0)