Skip to content

Rollup of 6 pull requests #24169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Apr 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cb1e6a2
book: use `mod test` consistently
callahad Apr 4, 2015
48a023c
Convert lifetime shadowing into a hard error, as promised.
nikomatsakis Apr 4, 2015
92d0026
Replace alpha state by pre-1.0
GuillaumeGomez Apr 6, 2015
49f2a56
Fix tests
nikomatsakis Apr 6, 2015
d166772
Try to improve PhantomData docs with more examples
nikomatsakis Apr 4, 2015
3b9847e
Fix code formatting in `core::ops::Add` example
tbu- Apr 6, 2015
59d8898
traits.md: Fix example of using traits to match description
joshtriplett Apr 6, 2015
8fcc5bd
Fix broken link and markup in `trait Any` docs.
mbrubeck Apr 6, 2015
6e86c63
Remove outdated notice from BufRead::lines docs.
mbrubeck Apr 6, 2015
bef00ab
use normative source for Grapheme class data
kwantam Apr 6, 2015
600101b
Update intro.md
xfq Apr 7, 2015
7eb723d
Add test for #22560
lgrz Apr 7, 2015
6eea426
Update hello-world.md
xfq Apr 7, 2015
fc2494b
Fix charset of debuginfo test on FreeBSD
wg Apr 7, 2015
6f9ec06
Add `ignore-tidy-linelength` and fix formatting
lgrz Apr 7, 2015
4dd6edd
Rollup merge of #23277 - aochagavia:intro, r=steveklabnik
Manishearth Apr 7, 2015
4faf0be
Rollup merge of #24042 - callahad:bug_24030, r=steveklabnik
Manishearth Apr 7, 2015
daf2e36
Rollup merge of #24057 - nikomatsakis:lifetime-shadowing-hard-error, …
Manishearth Apr 7, 2015
6f852f5
Rollup merge of #24059 - nikomatsakis:issue-22914-phantomdata-docs, r…
Manishearth Apr 7, 2015
50cb31f
Rollup merge of #24088 - GuillaumeGomez:patch-1, r=alexcrichton
Manishearth Apr 7, 2015
6efb835
Rollup merge of #24110 - tbu-:pr_doc_fix_add, r=alexcrichton
Manishearth Apr 7, 2015
322e4a1
Rollup merge of #24112 - joshtriplett:patch-1, r=steveklabnik
Manishearth Apr 7, 2015
b3bcbb1
Rollup merge of #24113 - mbrubeck:doc-edit, r=steveklabnik
Manishearth Apr 7, 2015
ae64d8e
doc ignore (fixup #24059)
Manishearth Apr 7, 2015
1fd89b6
Auto merge of #24156 - Manishearth:rollup, r=Manishearth
bors Apr 7, 2015
7b2e118
Rollup merge of #24132 - kwantam:master, r=alexcrichton
Manishearth Apr 7, 2015
6295406
Rollup merge of #24139 - xfq:patch-1, r=steveklabnik
Manishearth Apr 7, 2015
2b34643
Rollup merge of #24147 - lstat:needstest-22560, r=alexcrichton
Manishearth Apr 7, 2015
fe2cff7
Rollup merge of #24148 - xfq:patch-2, r=steveklabnik
Manishearth Apr 7, 2015
c4bd1c2
Rollup merge of #24150 - wg:master, r=alexcrichton
Manishearth Apr 7, 2015
4e067f5
Rollup merge of #24166 - lgvz:email, r=steveklabnik
Manishearth Apr 7, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {

// write debugger script
let mut script_str = String::with_capacity(2048);
let charset = if cfg!(target_os = "bitrig") { "auto" } else { "UTF-8" };
script_str.push_str(&format!("set charset {}\n", charset));
script_str.push_str(&format!("set charset {}\n", charset()));
script_str.push_str(&format!("file {}\n", exe_file.to_str().unwrap()));
script_str.push_str("target remote :5039\n");
script_str.push_str(&format!("set solib-search-path \
Expand Down Expand Up @@ -517,8 +516,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
.to_string();
// write debugger script
let mut script_str = String::with_capacity(2048);
let charset = if cfg!(target_os = "bitrig") { "auto" } else { "UTF-8" };
script_str.push_str(&format!("set charset {}\n", charset));
script_str.push_str(&format!("set charset {}\n", charset()));
script_str.push_str("show version\n");

match config.gdb_version {
Expand Down Expand Up @@ -1791,3 +1789,11 @@ fn run_codegen_test(config: &Config, props: &TestProps,
(base_lines as f64) / (clang_lines as f64),
0.001);
}

fn charset() -> &'static str {
if cfg!(any(target_os = "bitrig", target_os = "freebsd")) {
"auto"
} else {
"UTF-8"
}
}
6 changes: 3 additions & 3 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and safety.
# Tools

Getting started on a new Rust project is incredibly easy, thanks to Rust's
package manager, [Cargo](http://crates.io).
package manager, [Cargo](https://crates.io/).

To start a new project with Cargo, use `cargo new`:

Expand Down Expand Up @@ -149,8 +149,8 @@ Enough about tools, let's talk code!
Rust's defining feature is "memory safety without garbage collection". Let's
take a moment to talk about what that means. *Memory safety* means that the
programming language eliminates certain kinds of bugs, such as [buffer
overflows](http://en.wikipedia.org/wiki/Buffer_overflow) and [dangling
pointers](http://en.wikipedia.org/wiki/Dangling_pointer). These problems occur
overflows](https://en.wikipedia.org/wiki/Buffer_overflow) and [dangling
pointers](https://en.wikipedia.org/wiki/Dangling_pointer). These problems occur
when you have unrestricted access to memory. As an example, here's some Ruby
code:

Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/benchmark-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn add_two(a: i32) -> i32 {
}

#[cfg(test)]
mod tests {
mod test {
use super::*;
use test::Bencher;

Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/hello-cargo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% Hello, Cargo!

[Cargo](http://crates.io) is a tool that Rustaceans use to help manage their
Rust projects. Cargo is currently in an alpha state, just like Rust, and so it
Rust projects. Cargo is currently in a pre-1.0 state, just like Rust, and so it
is still a work in progress. However, it is already good enough to use for many
Rust projects, and so it is assumed that Rust projects will use Cargo from the
beginning.
Expand Down
8 changes: 4 additions & 4 deletions src/doc/trpl/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ If you come from a dynamically typed language like Ruby, Python, or JavaScript,
you may not be used to these two steps being separate. Rust is an
*ahead-of-time compiled language*, which means that you can compile a
program, give it to someone else, and they don't need to have Rust installed.
If you give someone a `.rb` or `.py` or `.js` file, they need to have
Ruby/Python/JavaScript installed, but you just need one command to both compile
and run your program. Everything is a tradeoff in language design, and Rust has
made its choice.
If you give someone a `.rb` or `.py` or `.js` file, they need to have a
Ruby/Python/JavaScript implementation installed, but you just need one command
to both compile and run your program. Everything is a tradeoff in language design,
and Rust has made its choice.

Congratulations! You have officially written a Rust program. That makes you a
Rust programmer! Welcome.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ pub fn add_two(a: i32) -> i32 {
}

#[cfg(test)]
mod tests {
mod test {
use super::*;

#[test]
Expand Down
3 changes: 1 addition & 2 deletions src/doc/trpl/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ everything is fine:

```{rust}
# #![feature(core)]
use shapes::HasArea;

mod shapes {
use std::f64::consts;

Expand All @@ -251,6 +249,7 @@ mod shapes {
}
}

use shapes::HasArea;

fn main() {
let c = shapes::Circle {
Expand Down
80 changes: 23 additions & 57 deletions src/etc/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

# This script uses the following Unicode tables:
# - DerivedCoreProperties.txt
# - DerivedNormalizationProps.txt
# - EastAsianWidth.txt
# - auxiliary/GraphemeBreakProperty.txt
# - PropList.txt
# - ReadMe.txt
# - Scripts.txt
# - UnicodeData.txt
#
Expand Down Expand Up @@ -51,41 +54,20 @@
'Cc': ['C'], 'Cf': ['C'], 'Cs': ['C'], 'Co': ['C'], 'Cn': ['C'],
}


# Grapheme cluster data
# taken from UAX29, http://www.unicode.org/reports/tr29/
# these code points are excluded from the Control category
# NOTE: CR and LF are also technically excluded, but for
# the sake of convenience we leave them in the Control group
# and manually check them in the appropriate place. This is
# still compliant with the implementation requirements.
grapheme_control_exceptions = set([0x200c, 0x200d])

# the Regional_Indicator category
grapheme_regional_indicator = [(0x1f1e6, 0x1f1ff)]

# "The following ... are specifically excluded" from the SpacingMark category
# http://www.unicode.org/reports/tr29/#SpacingMark
grapheme_spacingmark_exceptions = [(0x102b, 0x102c), (0x1038, 0x1038),
(0x1062, 0x1064), (0x1067, 0x106d), (0x1083, 0x1083), (0x1087, 0x108c),
(0x108f, 0x108f), (0x109a, 0x109c), (0x19b0, 0x19b4), (0x19b8, 0x19b9),
(0x19bb, 0x19c0), (0x19c8, 0x19c9), (0x1a61, 0x1a61), (0x1a63, 0x1a64),
(0xaa7b, 0xaa7b), (0xaa7d, 0xaa7d)]

# these are included in the SpacingMark category
grapheme_spacingmark_extra = set([0xe33, 0xeb3])
# these are the surrogate codepoints, which are not valid rust characters
surrogate_codepoints = (0xd800, 0xdfff)

def fetch(f):
if not os.path.exists(f):
if not os.path.exists(os.path.basename(f)):
os.system("curl -O http://www.unicode.org/Public/UNIDATA/%s"
% f)

if not os.path.exists(f):
if not os.path.exists(os.path.basename(f)):
sys.stderr.write("cannot load %s" % f)
exit(1)

def is_surrogate(n):
return 0xD800 <= n <= 0xDFFF
return surrogate_codepoints[0] <= n <= surrogate_codepoints[1]

def load_unicode_data(f):
fetch(f)
Expand Down Expand Up @@ -228,7 +210,7 @@ def load_properties(f, interestingprops):
re1 = re.compile("^([0-9A-F]+) +; (\w+)")
re2 = re.compile("^([0-9A-F]+)\.\.([0-9A-F]+) +; (\w+)")

for line in fileinput.input(f):
for line in fileinput.input(os.path.basename(f)):
prop = None
d_lo = 0
d_hi = 0
Expand Down Expand Up @@ -623,20 +605,14 @@ def optimize_width_table(wtable):
(canon_decomp, compat_decomp, gencats, combines,
lowerupper, upperlower) = load_unicode_data("UnicodeData.txt")
want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"]
other_derived = ["Default_Ignorable_Code_Point", "Grapheme_Extend"]
other_derived = ["Default_Ignorable_Code_Point"]
derived = load_properties("DerivedCoreProperties.txt", want_derived + other_derived)
scripts = load_properties("Scripts.txt", [])
props = load_properties("PropList.txt",
["White_Space", "Join_Control", "Noncharacter_Code_Point"])
norm_props = load_properties("DerivedNormalizationProps.txt",
["Full_Composition_Exclusion"])

# grapheme cluster category from DerivedCoreProperties
# the rest are defined below
grapheme_cats = {}
grapheme_cats["Extend"] = derived["Grapheme_Extend"]
del(derived["Grapheme_Extend"])

# bsearch_range_table is used in all the property modules below
emit_bsearch_range_table(rf)

Expand Down Expand Up @@ -691,34 +667,24 @@ def optimize_width_table(wtable):

### grapheme cluster module
# from http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Break_Property_Values
# Hangul syllable categories
want_hangul = ["L", "V", "T", "LV", "LVT"]
grapheme_cats.update(load_properties("HangulSyllableType.txt", want_hangul))
grapheme_cats = load_properties("auxiliary/GraphemeBreakProperty.txt", [])

# Control
# Note 1:
# This category also includes Cs (surrogate codepoints), but Rust's `char`s are
# Unicode Scalar Values only, and surrogates are thus invalid `char`s.
grapheme_cats["Control"] = set()
for cat in ["Zl", "Zp", "Cc", "Cf"]:
grapheme_cats["Control"] |= set(ungroup_cat(gencats[cat]))
# Thus, we have to remove Cs from the Control category
# Note 2:
# 0x0a and 0x0d (CR and LF) are not in the Control category for Graphemes.
# However, the Graphemes iterator treats these as a special case, so they
# should be included in grapheme_cats["Control"] for our implementation.
grapheme_cats["Control"] = group_cat(list(
grapheme_cats["Control"]
- grapheme_control_exceptions
| (set(ungroup_cat(gencats["Cn"]))
& set(ungroup_cat(derived["Default_Ignorable_Code_Point"])))))

# Regional Indicator
grapheme_cats["RegionalIndicator"] = grapheme_regional_indicator

# Prepend - "Currently there are no characters with this value"
# (from UAX#29, Unicode 7.0)

# SpacingMark
grapheme_cats["SpacingMark"] = group_cat(list(
set(ungroup_cat(gencats["Mc"]))
- set(ungroup_cat(grapheme_cats["Extend"]))
| grapheme_spacingmark_extra
- set(ungroup_cat(grapheme_spacingmark_exceptions))))
(set(ungroup_cat(grapheme_cats["Control"]))
| set(ungroup_cat(grapheme_cats["CR"]))
| set(ungroup_cat(grapheme_cats["LF"])))
- set(ungroup_cat([surrogate_codepoints]))))
del(grapheme_cats["CR"])
del(grapheme_cats["LF"])

grapheme_table = []
for cat in grapheme_cats:
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ use marker::{Reflect, Sized};
// Any trait
///////////////////////////////////////////////////////////////////////////////

/// A type to emulate dynamic typing. See the [module-level documentation][mod] for more details.
/// A type to emulate dynamic typing.
///
/// Every type with no non-`'static` references implements `Any`.
/// See the [module-level documentation][mod] for more details.
///
/// [mod]: ../index.html
/// [mod]: index.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Any: Reflect + 'static {
/// Get the `TypeId` of `self`
Expand Down
67 changes: 58 additions & 9 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,49 @@ impl<A:?Sized,R:?Sized,T:?Sized> PhantomFn<A,R> for T { }
///
/// # Examples
///
/// When handling external resources over a foreign function interface, `PhantomData<T>` can
/// prevent mismatches by enforcing types in the method implementations:
/// ## Unused lifetime parameter
///
/// Perhaps the most common time that `PhantomData` is required is
/// with a struct that has an unused lifetime parameter, typically as
/// part of some unsafe code. For example, here is a struct `Slice`
/// that has two pointers of type `*const T`, presumably pointing into
/// an array somewhere:
///
/// ```ignore
/// struct Slice<'a, T> {
/// start: *const T,
/// end: *const T,
/// }
/// ```
///
/// The intention is that the underlying data is only valid for the
/// lifetime `'a`, so `Slice` should not outlive `'a`. However, this
/// intent is not expressed in the code, since there are no uses of
/// the lifetime `'a` and hence it is not clear what data it applies
/// to. We can correct this by telling the compiler to act *as if* the
/// `Slice` struct contained a borrowed reference `&'a T`:
///
/// ```
/// use std::marker::PhantomData;
///
/// struct Slice<'a, T:'a> {
/// start: *const T,
/// end: *const T,
/// phantom: PhantomData<&'a T>
/// }
/// ```
///
/// This also in turn requires that we annotate `T:'a`, indicating
/// that `T` is a type that can be borrowed for the lifetime `'a`.
///
/// ## Unused type parameters
///
/// It sometimes happens that there are unused type parameters that
/// indicate what type of data a struct is "tied" to, even though that
/// data is not actually found in the struct itself. Here is an
/// example where this arises when handling external resources over a
/// foreign function interface. `PhantomData<T>` can prevent
/// mismatches by enforcing types in the method implementations:
///
/// ```
/// # trait ResType { fn foo(&self); };
Expand Down Expand Up @@ -351,13 +392,21 @@ impl<A:?Sized,R:?Sized,T:?Sized> PhantomFn<A,R> for T { }
/// }
/// ```
///
/// Another example: embedding a `PhantomData<T>` will inform the compiler
/// that one or more instances of the type `T` could be dropped when
/// instances of the type itself is dropped, though that may not be
/// apparent from the other structure of the type itself. This is
/// commonly necessary if the structure is using an unsafe pointer
/// like `*mut T` whose referent may be dropped when the type is
/// dropped, as a `*mut T` is otherwise not treated as owned.
/// ## Indicating ownership
///
/// Adding a field of type `PhantomData<T>` also indicates that your
/// struct owns data of type `T`. This in turn implies that when your
/// struct is dropped, it may in turn drop one or more instances of
/// the type `T`, though that may not be apparent from the other
/// structure of the type itself. This is commonly necessary if the
/// structure is using an unsafe pointer like `*mut T` whose referent
/// may be dropped when the type is dropped, as a `*mut T` is
/// otherwise not treated as owned.
///
/// If your struct does not in fact *own* the data of type `T`, it is
/// better to use a reference type, like `PhantomData<&'a T>`
/// (ideally) or `PhantomData<*const T>` (if no lifetime applies), so
/// as not to indicate ownership.
#[lang="phantom_data"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct PhantomData<T:?Sized>;
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ macro_rules! forward_ref_binop {
/// type Output = Foo;
///
/// fn add(self, _rhs: Foo) -> Foo {
/// println!("Adding!");
/// self
/// }
/// println!("Adding!");
/// self
/// }
/// }
///
/// fn main() {
/// Foo + Foo;
/// Foo + Foo;
/// }
/// ```
#[lang="add"]
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl<'a> LifetimeContext<'a> {
EarlyScope(_, lifetimes, s) |
LateScope(lifetimes, s) => {
if let Some((_, lifetime_def)) = search_lifetimes(lifetimes, lifetime) {
self.sess.span_warn(
self.sess.span_err(
lifetime.span,
&format!("lifetime name `{}` shadows another \
lifetime name that is already in scope",
Expand All @@ -516,10 +516,6 @@ impl<'a> LifetimeContext<'a> {
lifetime_def.span,
&format!("shadowed lifetime `{}` declared here",
token::get_name(lifetime.name)));
self.sess.span_note(
lifetime.span,
"shadowed lifetimes are deprecated \
and will become a hard error before 1.0");
return;
}

Expand Down
3 changes: 0 additions & 3 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ pub trait BufRead: Read {
/// The iterator returned from this function will yield instances of
/// `io::Result<String>`. Each string returned will *not* have a newline
/// byte (the 0xA byte) at the end.
///
/// This function will yield errors whenever `read_string` would have also
/// yielded an error.
#[stable(feature = "rust1", since = "1.0.0")]
fn lines(self) -> Lines<Self> where Self: Sized {
Lines { buf: self }
Expand Down
Loading