Skip to content

Commit

Permalink
Auto merge of #47572 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

- Successful merges: #46938, #47334, #47420, #47508, #47510, #47512, #47535, #47559
- Failed merges:
  • Loading branch information
bors committed Jan 19, 2018
2 parents 5965b79 + ce797d5 commit a7b8622
Show file tree
Hide file tree
Showing 41 changed files with 276 additions and 114 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ It's absolutely fine to have multiple build directories with different
[pull-requests]: #pull-requests

Pull requests are the primary mechanism we use to change Rust. GitHub itself
has some [great documentation][pull-requests] on using the Pull Request feature.
has some [great documentation][about-pull-requests] on using the Pull Request feature.
We use the "fork and pull" model [described here][development-models], where
contributors push changes to their personal fork and create pull requests to
bring those changes into the source repository.

[pull-requests]: https://help.github.com/articles/about-pull-requests/
[about-pull-requests]: https://help.github.com/articles/about-pull-requests/
[development-models]: https://help.github.com/articles/about-collaborative-development-models/

Please make pull requests against the `master` branch.
Expand Down
2 changes: 2 additions & 0 deletions src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Rust provides a number of book-length sets of documentation, collectively
nicknamed 'The Rust Bookshelf.'

* [The Rust Programming Language][book] teaches you how to program in Rust.
* [Rust By Example][rbe] teaches you how to program in Rust using editable examples.
* [The Cargo Book][cargo-book] is a guide to Cargo, Rust's build tool and dependency manager.
* [The Unstable Book][unstable-book] has documentation for unstable features.
* [The Rustonomicon][nomicon] is your guidebook to the dark arts of unsafe Rust.
Expand All @@ -51,6 +52,7 @@ before this policy was put into place. That work is being tracked
[refchecklist]: https://github.com/rust-lang-nursery/reference/issues/9
[err]: error-index.html
[book]: book/index.html
[rbe]: rust-by-example/index.html
[nomicon]: nomicon/index.html
[unstable-book]: unstable-book/index.html
[rustdoc-book]: rustdoc/index.html
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// `sp` only covers `T`, change it so that it covers
// `T:` when appropriate
let sp = if has_lifetimes {
sp.to(sp.next_point().next_point())
sp.to(self.tcx.sess.codemap().next_point(
self.tcx.sess.codemap().next_point(sp)))
} else {
sp
};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_borrowck/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
// 3. Where does old loan expire.

let previous_end_span =
Some(old_loan.kill_scope.span(self.tcx(), &self.bccx.region_scope_tree)
.end_point());
Some(self.tcx().sess.codemap().end_point(
old_loan.kill_scope.span(self.tcx(), &self.bccx.region_scope_tree)));

let mut err = match (new_loan.kind, old_loan.kind) {
(ty::MutBorrow, ty::MutBorrow) =>
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
fn region_end_span(&self, region: ty::Region<'tcx>) -> Option<Span> {
match *region {
ty::ReScope(scope) => {
Some(scope.span(self.tcx, &self.region_scope_tree).end_point())
Some(self.tcx.sess.codemap().end_point(
scope.span(self.tcx, &self.region_scope_tree)))
}
_ => None
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,10 +1090,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
debug!("check_for_invalidation_at_exit({:?}): INVALID", place);
// FIXME: should be talking about the region lifetime instead
// of just a span here.
let span = self.tcx.sess.codemap().end_point(span);
self.report_borrowed_value_does_not_live_long_enough(
context,
borrow,
span.end_point(),
span,
flow_state.borrows.operator(),
)
}
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_mir/build/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
if let DropKind::Value { .. } = drop_kind {
scope.needs_cleanup = true;
}

let region_scope_span = region_scope.span(self.hir.tcx(),
&self.hir.region_scope_tree);
// Attribute scope exit drops to scope's closing brace
let scope_end = region_scope_span.with_lo(region_scope_span.hi());
// Attribute scope exit drops to scope's closing brace.
let scope_end = self.hir.tcx().sess.codemap().end_point(region_scope_span);

scope.drops.push(DropData {
span: scope_end,
location: place.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ impl<'a, 'gcx, 'tcx> ActiveBorrows<'a, 'gcx, 'tcx> {
Some(_) => None,
None => {
match self.0.region_span_map.get(region) {
Some(span) => Some(span.end_point()),
None => Some(self.0.mir.span.end_point())
Some(span) => Some(self.0.tcx.sess.codemap().end_point(*span)),
None => Some(self.0.tcx.sess.codemap().end_point(self.0.mir.span))
}
}
}
Expand Down
53 changes: 53 additions & 0 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,59 @@ println!("const value: {}", SomeModule::PRIVATE); // ok!
```
"##,

E0659: r##"
An item usage is ambiguous.
Erroneous code example:
```compile_fail,E0659
pub mod moon {
pub fn foo() {}
}
pub mod earth {
pub fn foo() {}
}
mod collider {
pub use moon::*;
pub use earth::*;
}
fn main() {
collider::foo(); // ERROR: `foo` is ambiguous
}
```
This error generally appears when two items with the same name are imported into
a module. Here, the `foo` functions are imported and reexported from the
`collider` module and therefore, when we're using `collider::foo()`, both
functions collide.
To solve this error, the best solution is generally to keep the path before the
item when using it. Example:
```
pub mod moon {
pub fn foo() {}
}
pub mod earth {
pub fn foo() {}
}
mod collider {
pub use moon;
pub use earth;
}
fn main() {
collider::moon::foo(); // ok!
collider::earth::foo(); // ok!
}
```
"##,

}

register_diagnostics! {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2791,8 +2791,8 @@ impl<'a> Resolver<'a> {
if let Some(sp) = self.current_type_ascription.last() {
let mut sp = *sp;
loop { // try to find the `:`, bail on first non-':'/non-whitespace
sp = sp.next_point();
if let Ok(snippet) = cm.span_to_snippet(sp.to(sp.next_point())) {
sp = cm.next_point(sp);
if let Ok(snippet) = cm.span_to_snippet(sp.to(cm.next_point(sp))) {
debug!("snippet {:?}", snippet);
let line_sp = cm.lookup_char_pos(sp.hi()).line;
let line_base_sp = cm.lookup_char_pos(base_span.lo()).line;
Expand Down Expand Up @@ -3783,7 +3783,7 @@ impl<'a> Resolver<'a> {
self.session.buffer_lint(lint::builtin::LEGACY_IMPORTS, id, span, &msg);
} else {
let mut err =
self.session.struct_span_err(span, &format!("`{}` is ambiguous", name));
struct_span_err!(self.session, span, E0659, "`{}` is ambiguous", name);
err.span_note(b1.span, &msg1);
match b2.def() {
Def::Macro(..) if b2.span == DUMMY_SP =>
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
err.span_label(def_s, "defined here");
}
if sugg_unit {
let sugg_span = expr_sp.end_point();
let sugg_span = sess.codemap().end_point(expr_sp);
// remove closing `)` from the span
let sugg_span = sugg_span.with_hi(sugg_span.lo());
err.span_suggestion(
Expand Down Expand Up @@ -4400,10 +4400,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// statement and the return type has been left as default or has been specified as `()`. If so,
/// it suggests adding a semicolon.
fn suggest_missing_semicolon(&self,
err: &mut DiagnosticBuilder<'tcx>,
expression: &'gcx hir::Expr,
expected: Ty<'tcx>,
cause_span: Span) {
err: &mut DiagnosticBuilder<'tcx>,
expression: &'gcx hir::Expr,
expected: Ty<'tcx>,
cause_span: Span) {
if expected.is_nil() {
// `BlockTailExpression` only relevant if the tail expr would be
// useful on its own.
Expand All @@ -4415,7 +4415,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hir::ExprLoop(..) |
hir::ExprMatch(..) |
hir::ExprBlock(..) => {
let sp = cause_span.next_point();
let sp = self.tcx.sess.codemap().next_point(cause_span);
err.span_suggestion(sp,
"try adding a semicolon",
";".to_string());
Expand Down
18 changes: 10 additions & 8 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,22 @@ r##"<!DOCTYPE html>
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dt><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt></dt>
<dt><kbd>↑</kbd></dt>
<dd>Move up in search results</dd>
<dt></dt>
<dt><kbd>↓</kbd></dt>
<dd>Move down in search results</dd>
<dt></dt>
<dt><kbd>↹</kbd></dt>
<dd>Switch tab</dd>
<dt>&#9166;</dt>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt style="width:31px;">+ / -</dt>
<dd>Collapse/expand all sections</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse all sections</dd>
</dl>
</div>
Expand Down
18 changes: 12 additions & 6 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,13 @@ body.blur > :not(#help) {
flex: 0 0 auto;
box-shadow: 0 0 6px rgba(0,0,0,.2);
width: 550px;
height: 354px;
height: auto;
border: 1px solid;
}
#help dt {
float: left;
border-radius: 4px;
border: 1px solid;
width: 23px;
text-align: center;
clear: left;
display: block;
margin-top: -1px;
}
#help dd { margin: 5px 35px; }
#help .infos { padding-left: 0; }
Expand Down Expand Up @@ -1134,3 +1129,14 @@ h3.important {
left: -42px;
margin-top: 2px;
}

kbd {
display: inline-block;
padding: 3px 5px;
font: 15px "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
line-height: 10px;
vertical-align: middle;
border: solid 1px;
border-radius: 3px;
box-shadow: inset 0 -1px 0;
}
13 changes: 8 additions & 5 deletions src/librustdoc/html/static/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ a.test-arrow {
border-color: #bfbfbf;
}

#help dt {
border-color: #bfbfbf;
background: #fff;
}

.since {
color: grey;
}
Expand Down Expand Up @@ -348,3 +343,11 @@ pre.ignore:hover, .information:hover + pre.ignore {
border-bottom-color: #e0e0e0;
}
}

kbd {
color: #444d56;
background-color: #fafbfc;
border-color: #d1d5da;
border-bottom-color: #c6cbd1;
box-shadow-color: #c6cbd1;
}
5 changes: 4 additions & 1 deletion src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use fmt;
use hash;
use io;
use mem;
use net::{lookup_host, ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
use net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
#[allow(deprecated)]
use net::lookup_host;
use option;
use sys::net::netc as c;
use sys_common::{FromInner, AsInner, IntoInner};
Expand Down Expand Up @@ -845,6 +847,7 @@ impl ToSocketAddrs for (Ipv6Addr, u16) {
}
}

#[allow(deprecated)]
fn resolve_socket_addr(s: &str, p: u16) -> io::Result<vec::IntoIter<SocketAddr>> {
let ips = lookup_host(s)?;
let v: Vec<_> = ips.map(|mut a| { a.set_port(p); a }).collect();
Expand Down
7 changes: 7 additions & 0 deletions src/libstd/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,15 @@ fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
pub struct LookupHost(net_imp::LookupHost);

#[unstable(feature = "lookup_host", reason = "unsure about the returned \
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
#[allow(deprecated)]
impl Iterator for LookupHost {
type Item = SocketAddr;
fn next(&mut self) -> Option<SocketAddr> { self.0.next() }
Expand All @@ -149,6 +152,8 @@ impl Iterator for LookupHost {
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
#[allow(deprecated)]
impl fmt::Debug for LookupHost {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("LookupHost { .. }")
Expand Down Expand Up @@ -181,6 +186,8 @@ impl fmt::Debug for LookupHost {
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
#[allow(deprecated)]
pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
net_imp::lookup_host(host).map(LookupHost)
}
4 changes: 0 additions & 4 deletions src/libstd/sys/unix/l4re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,5 @@ pub mod net {
pub fn lookup_host(_: &str) -> io::Result<LookupHost> {
unimpl!();
}

pub fn res_init_if_glibc_before_2_26() -> io::Result<()> {
unimpl!();
}
}

Loading

0 comments on commit a7b8622

Please sign in to comment.