Skip to content
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

Rollup of 11 pull requests #39180

Merged
merged 26 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8a472a5
Add a more complete doc example for 'include' macro.
frewsxcv Dec 18, 2016
44c2eb9
Move parenthesized statement within sentence.
frewsxcv Dec 18, 2016
4a354ab
Fix 'unhygienically' typo.
frewsxcv Dec 21, 2016
58aac45
Fix a couple of bad Markdown links
chris-morgan Jan 8, 2017
9940db6
Deprecate `#[unsafe_destructor_blind_to_params]`
apasel422 Jan 10, 2017
62e11ad
compiletest: Allow for ignoring tests if certain GDB version is detec…
michaelwoerister Jan 9, 2017
f437598
debuginfo: Ignore optimized enum tests for GDB versions that can't ha…
michaelwoerister Jan 13, 2017
30ba990
ignore-gdb-version: Address review comments.
michaelwoerister Jan 16, 2017
5a462e8
consistent doc wording
king6cong Jan 17, 2017
1cf9d6a
minor typo fix
grimreaper Jan 17, 2017
c525094
Add error explanation for E0491
richardimaoka Jan 16, 2017
5c58653
E0122 should apply with where clauses
circuitfox Jan 18, 2017
871357a
collections: update docs of slice get() and friends
birkenfeld Dec 7, 2016
2c6bc18
Feature gate `&Void`'s uninhabitedness.
canndrew Jan 18, 2017
c8822da
A few improvements to the slice docs.
frewsxcv Jan 18, 2017
ced04ff
Rollup merge of #38457 - frewsxcv:include, r=GuillaumeGomez
GuillaumeGomez Jan 19, 2017
cabfb07
Rollup merge of #38922 - chris-morgan:fs-markdown-link-fix, r=stevekl…
GuillaumeGomez Jan 19, 2017
223e084
Rollup merge of #38970 - apasel422:may-dangle, r=pnkfelix
GuillaumeGomez Jan 19, 2017
7985ae0
Rollup merge of #39039 - michaelwoerister:ignore-gdb-version, r=nrc
GuillaumeGomez Jan 19, 2017
ba76f51
Rollup merge of #39091 - richard-imaoka:E0491-long-explanation, r=Gui…
GuillaumeGomez Jan 19, 2017
9aeccf3
Rollup merge of #39115 - king6cong:master, r=nikomatsakis
GuillaumeGomez Jan 19, 2017
4603c0e
Rollup merge of #39121 - grimreaper:eax/thethe, r=apasel422
GuillaumeGomez Jan 19, 2017
2c04475
Rollup merge of #39149 - circuitfox:E0122-type-def-trait-bounds-where…
GuillaumeGomez Jan 19, 2017
c593ff4
Rollup merge of #39150 - birkenfeld:slice-doc, r=GuillaumeGomez
GuillaumeGomez Jan 19, 2017
87482ee
Rollup merge of #39151 - canndrew:feature-gate-uninhabited-references…
GuillaumeGomez Jan 19, 2017
3946079
Rollup merge of #39165 - frewsxcv:slice, r=GuillaumeGomez
GuillaumeGomez Jan 19, 2017
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
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3371,7 +3371,7 @@ Version 1.0.0-alpha (2015-01-09)
platforms.
* Rust comes with rust-gdb and rust-lldb scripts that launch their
respective debuggers with Rust-appropriate pretty-printing.
* The Windows installation of Rust is distributed with the the
* The Windows installation of Rust is distributed with the
MinGW components currently required to link binaries on that
platform.

Expand Down
59 changes: 41 additions & 18 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<T> [T] {
core_slice::SliceExt::len(self)
}

/// Returns true if the slice has a length of 0.
/// Returns `true` if the slice has a length of 0.
///
/// # Example
///
Expand Down Expand Up @@ -342,15 +342,22 @@ impl<T> [T] {
core_slice::SliceExt::last_mut(self)
}

/// Returns the element of a slice at the given index, or `None` if the
/// index is out of bounds.
/// Returns a reference to an element or subslice depending on the type of
/// index.
///
/// - If given a position, returns a reference to the element at that
/// position or `None` if out of bounds.
/// - If given a range, returns the subslice corresponding to that range,
/// or `None` if out of bounds.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert_eq!(Some(&40), v.get(1));
/// assert_eq!(Some(&[10, 40][..]), v.get(0..2));
/// assert_eq!(None, v.get(3));
/// assert_eq!(None, v.get(0..4));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand All @@ -360,7 +367,10 @@ impl<T> [T] {
core_slice::SliceExt::get(self, index)
}

/// Returns a mutable reference to the element at the given index.
/// Returns a mutable reference to an element or subslice depending on the
/// type of index (see [`get()`]) or `None` if the index is out of bounds.
///
/// [`get()`]: #method.get
///
/// # Examples
///
Expand All @@ -372,7 +382,6 @@ impl<T> [T] {
/// }
/// assert_eq!(x, &[0, 42, 2]);
/// ```
/// or `None` if the index is out of bounds
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
Expand All @@ -381,8 +390,8 @@ impl<T> [T] {
core_slice::SliceExt::get_mut(self, index)
}

/// Returns a pointer to the element at the given index, without doing
/// bounds checking. So use it very carefully!
/// Returns a reference to an element or subslice, without doing bounds
/// checking. So use it very carefully!
///
/// # Examples
///
Expand All @@ -401,8 +410,8 @@ impl<T> [T] {
core_slice::SliceExt::get_unchecked(self, index)
}

/// Returns an unsafe mutable pointer to the element in index. So use it
/// very carefully!
/// Returns a mutable reference to an element or subslice, without doing
/// bounds checking. So use it very carefully!
///
/// # Examples
///
Expand Down Expand Up @@ -540,12 +549,8 @@ impl<T> [T] {
///
/// ```
/// let x = &mut [1, 2, 4];
/// {
/// let iterator = x.iter_mut();
///
/// for elem in iterator {
/// *elem += 2;
/// }
/// for elem in x.iter_mut() {
/// *elem += 2;
/// }
/// assert_eq!(x, &[3, 4, 6]);
/// ```
Expand Down Expand Up @@ -880,7 +885,7 @@ impl<T> [T] {
core_slice::SliceExt::rsplitn_mut(self, n, pred)
}

/// Returns true if the slice contains an element with the given value.
/// Returns `true` if the slice contains an element with the given value.
///
/// # Examples
///
Expand All @@ -896,7 +901,7 @@ impl<T> [T] {
core_slice::SliceExt::contains(self, x)
}

/// Returns true if `needle` is a prefix of the slice.
/// Returns `true` if `needle` is a prefix of the slice.
///
/// # Examples
///
Expand All @@ -907,14 +912,23 @@ impl<T> [T] {
/// assert!(!v.starts_with(&[50]));
/// assert!(!v.starts_with(&[10, 50]));
/// ```
///
/// Always returns `true` if `needle` is an empty slice:
///
/// ```
/// let v = &[10, 40, 30];
/// assert!(v.starts_with(&[]));
/// let v: &[u8] = &[];
/// assert!(v.starts_with(&[]));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn starts_with(&self, needle: &[T]) -> bool
where T: PartialEq
{
core_slice::SliceExt::starts_with(self, needle)
}

/// Returns true if `needle` is a suffix of the slice.
/// Returns `true` if `needle` is a suffix of the slice.
///
/// # Examples
///
Expand All @@ -925,6 +939,15 @@ impl<T> [T] {
/// assert!(!v.ends_with(&[50]));
/// assert!(!v.ends_with(&[50, 30]));
/// ```
///
/// Always returns `true` if `needle` is an empty slice:
///
/// ```
/// let v = &[10, 40, 30];
/// assert!(v.ends_with(&[]));
/// let v: &[u8] = &[];
/// assert!(v.ends_with(&[]));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn ends_with(&self, needle: &[T]) -> bool
where T: PartialEq
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct DepGraphThreadData {
// current buffer, where we accumulate messages
messages: VecCell<DepMessage>,

// whence to receive new buffer when full
// where to receive new buffer when full
swap_in: Receiver<Vec<DepMessage>>,

// where to send buffer when full
Expand Down
35 changes: 34 additions & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,40 @@ struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'kiss must live
```
"##,

E0491: r##"
A reference has a longer lifetime than the data it references.

Erroneous code example:

```compile_fail,E0491
// struct containing a reference requires a lifetime parameter,
// because the data the reference points to must outlive the struct (see E0106)
struct Struct<'a> {
ref_i32: &'a i32,
}

// However, a nested struct like this, the signature itself does not tell
// whether 'a outlives 'b or the other way around.
// So it could be possible that 'b of reference outlives 'a of the data.
struct Nested<'a, 'b> {
ref_struct: &'b Struct<'a>, // compile error E0491
}
```

To fix this issue, you can specify a bound to the lifetime like below:

```
struct Struct<'a> {
ref_i32: &'a i32,
}

// 'a: 'b means 'a outlives 'b
struct Nested<'a: 'b, 'b> {
ref_struct: &'b Struct<'a>,
}
```
"##,

E0496: r##"
A lifetime name is shadowing another lifetime name. Erroneous code example:

Expand Down Expand Up @@ -1697,7 +1731,6 @@ register_diagnostics! {
E0488, // lifetime of variable does not enclose its declaration
E0489, // type/lifetime parameter not in scope here
E0490, // a value of type `..` is borrowed for too long
E0491, // in type `..`, reference has a longer lifetime than the data it...
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
E0566 // conflicting representation hints
}
8 changes: 7 additions & 1 deletion src/librustc/ty/inhabitedness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
ty.uninhabited_from(visited, tcx)
}
}
TyRef(_, ref tm) => tm.ty.uninhabited_from(visited, tcx),
TyRef(_, ref tm) => {
if tcx.sess.features.borrow().never_type {
tm.ty.uninhabited_from(visited, tcx)
} else {
DefIdForest::empty()
}
}

_ => DefIdForest::empty(),
}
Expand Down
10 changes: 10 additions & 0 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,16 @@ fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
}
}

for predicate in generics.where_clause.predicates.iter() {
match *predicate {
hir::WherePredicate::BoundPredicate(..) => {
warn = true;
}
hir::WherePredicate::RegionPredicate(..) => { }
hir::WherePredicate::EqPredicate(..) => { }
}
}

if warn {
// According to accepted RFC #XXX, we should
// eventually accept these, but it will not be
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ use time::SystemTime;
/// # }
/// ```
///
/// [`BufReader`]: ../io/struct.BufReader.html
/// [`Read`]: ../io/trait.Read.html
/// [`BufReader<R>`]: ../io/struct.BufReader.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct File {
inner: fs_imp::File,
Expand Down
25 changes: 20 additions & 5 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,23 +458,38 @@ pub mod builtin {

/// Parse a file as an expression or an item according to the context.
///
/// The file is located relative to the current file. (similarly to how
/// modules are found)
/// The file is located relative to the current file (similarly to how
/// modules are found).
///
/// Using this macro is often a bad idea, because if the file is
/// parsed as an expression, it is going to be placed in the
/// surrounding code unhygenically. This could result in variables
/// surrounding code unhygienically. This could result in variables
/// or functions being different from what the file expected if
/// there are variables or functions that have the same name in
/// the current file.
///
/// # Examples
///
/// Assume there are two files in the same directory with the following
/// contents:
///
/// File 'my_str.in':
///
/// ```ignore
/// fn foo() {
/// include!("/path/to/a/file")
/// "Hello World!"
/// ```
///
/// File 'main.rs':
///
/// ```ignore
/// fn main() {
/// let my_str = include!("my_str.in");
/// println!("{}", my_str);
/// }
/// ```
///
/// Compiling 'main.rs' and running the resulting binary will print "Hello
/// World!".
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,10 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
cfg_fn!(omit_gdb_pretty_printer_section))),
("unsafe_destructor_blind_to_params",
Normal,
Gated(Stability::Unstable,
Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761"),
"dropck_parametricity",
"unsafe_destructor_blind_to_params has unstable semantics \
and may be removed in the future",
"unsafe_destructor_blind_to_params has been replaced by \
may_dangle and will be removed in the future",
cfg_fn!(dropck_parametricity))),
("may_dangle",
Normal,
Expand Down
22 changes: 22 additions & 0 deletions src/test/compile-fail/feature-gate-dropck-ugeh-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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.

#![deny(deprecated)]
#![feature(dropck_parametricity)]

struct Foo;

impl Drop for Foo {
#[unsafe_destructor_blind_to_params]
//~^ ERROR use of deprecated attribute `dropck_parametricity`
fn drop(&mut self) {}
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/feature-gate-dropck-ugeh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct Foo<T> { data: Vec<T> }

impl<T> Drop for Foo<T> {
#[unsafe_destructor_blind_to_params] // This is the UGEH attribute
//~^ ERROR unsafe_destructor_blind_to_params has unstable semantics
//~^ ERROR unsafe_destructor_blind_to_params has been replaced
fn drop(&mut self) { }
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-17994.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
// except according to those terms.

trait Tr {}
type Huh<T> where T: Tr = isize; //~ ERROR type parameter `T` is unused
type Huh<T> where T: Tr = isize; //~ ERROR type parameter `T` is unused
//~| WARNING E0122
fn main() {}
13 changes: 13 additions & 0 deletions src/test/compile-fail/issue-39122.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.
//
// 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.

type Foo<T: std::ops::Add> = T; //~ WARNING E0122

type Bar<T> where T: std::ops::Add = T; //~ WARNING E0122
1 change: 1 addition & 0 deletions src/test/compile-fail/private-in-public-warn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ mod traits_where {
pub type Alias<T> where T: PrivTr = T;
//~^ ERROR private trait `traits_where::PrivTr` in public interface
//~| WARNING hard error
//~| WARNING E0122
pub trait Tr2<T> where T: PrivTr {}
//~^ ERROR private trait `traits_where::PrivTr` in public interface
//~| WARNING hard error
Expand Down
19 changes: 19 additions & 0 deletions src/test/compile-fail/uninhabited-reference-type-feature-gated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

enum Void {}

fn main() {
let x: Result<u32, &'static Void> = Ok(23);
let _ = match x { //~ ERROR non-exhaustive
Ok(n) => n,
};
}

Loading