Skip to content

Commit a7b8622

Browse files
committed
Auto merge of #47572 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 8 pull requests - Successful merges: #46938, #47334, #47420, #47508, #47510, #47512, #47535, #47559 - Failed merges:
2 parents 5965b79 + ce797d5 commit a7b8622

Some content is hidden

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

41 files changed

+276
-114
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,12 @@ It's absolutely fine to have multiple build directories with different
301301
[pull-requests]: #pull-requests
302302

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

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

312312
Please make pull requests against the `master` branch.

src/doc/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Rust provides a number of book-length sets of documentation, collectively
2828
nicknamed 'The Rust Bookshelf.'
2929

3030
* [The Rust Programming Language][book] teaches you how to program in Rust.
31+
* [Rust By Example][rbe] teaches you how to program in Rust using editable examples.
3132
* [The Cargo Book][cargo-book] is a guide to Cargo, Rust's build tool and dependency manager.
3233
* [The Unstable Book][unstable-book] has documentation for unstable features.
3334
* [The Rustonomicon][nomicon] is your guidebook to the dark arts of unsafe Rust.
@@ -51,6 +52,7 @@ before this policy was put into place. That work is being tracked
5152
[refchecklist]: https://github.com/rust-lang-nursery/reference/issues/9
5253
[err]: error-index.html
5354
[book]: book/index.html
55+
[rbe]: rust-by-example/index.html
5456
[nomicon]: nomicon/index.html
5557
[unstable-book]: unstable-book/index.html
5658
[rustdoc-book]: rustdoc/index.html

src/librustc/infer/error_reporting/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
958958
// `sp` only covers `T`, change it so that it covers
959959
// `T:` when appropriate
960960
let sp = if has_lifetimes {
961-
sp.to(sp.next_point().next_point())
961+
sp.to(self.tcx.sess.codemap().next_point(
962+
self.tcx.sess.codemap().next_point(sp)))
962963
} else {
963964
sp
964965
};

src/librustc_borrowck/borrowck/check_loans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
484484
// 3. Where does old loan expire.
485485

486486
let previous_end_span =
487-
Some(old_loan.kill_scope.span(self.tcx(), &self.bccx.region_scope_tree)
488-
.end_point());
487+
Some(self.tcx().sess.codemap().end_point(
488+
old_loan.kill_scope.span(self.tcx(), &self.bccx.region_scope_tree)));
489489

490490
let mut err = match (new_loan.kind, old_loan.kind) {
491491
(ty::MutBorrow, ty::MutBorrow) =>

src/librustc_borrowck/borrowck/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
13431343
fn region_end_span(&self, region: ty::Region<'tcx>) -> Option<Span> {
13441344
match *region {
13451345
ty::ReScope(scope) => {
1346-
Some(scope.span(self.tcx, &self.region_scope_tree).end_point())
1346+
Some(self.tcx.sess.codemap().end_point(
1347+
scope.span(self.tcx, &self.region_scope_tree)))
13471348
}
13481349
_ => None
13491350
}

src/librustc_mir/borrow_check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1090,10 +1090,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
10901090
debug!("check_for_invalidation_at_exit({:?}): INVALID", place);
10911091
// FIXME: should be talking about the region lifetime instead
10921092
// of just a span here.
1093+
let span = self.tcx.sess.codemap().end_point(span);
10931094
self.report_borrowed_value_does_not_live_long_enough(
10941095
context,
10951096
borrow,
1096-
span.end_point(),
1097+
span,
10971098
flow_state.borrows.operator(),
10981099
)
10991100
}

src/librustc_mir/build/scope.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
695695
if let DropKind::Value { .. } = drop_kind {
696696
scope.needs_cleanup = true;
697697
}
698+
698699
let region_scope_span = region_scope.span(self.hir.tcx(),
699700
&self.hir.region_scope_tree);
700-
// Attribute scope exit drops to scope's closing brace
701-
let scope_end = region_scope_span.with_lo(region_scope_span.hi());
701+
// Attribute scope exit drops to scope's closing brace.
702+
let scope_end = self.hir.tcx().sess.codemap().end_point(region_scope_span);
703+
702704
scope.drops.push(DropData {
703705
span: scope_end,
704706
location: place.clone(),

src/librustc_mir/dataflow/impls/borrows.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ impl<'a, 'gcx, 'tcx> ActiveBorrows<'a, 'gcx, 'tcx> {
537537
Some(_) => None,
538538
None => {
539539
match self.0.region_span_map.get(region) {
540-
Some(span) => Some(span.end_point()),
541-
None => Some(self.0.mir.span.end_point())
540+
Some(span) => Some(self.0.tcx.sess.codemap().end_point(*span)),
541+
None => Some(self.0.tcx.sess.codemap().end_point(self.0.mir.span))
542542
}
543543
}
544544
}

src/librustc_resolve/diagnostics.rs

+53
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,59 @@ println!("const value: {}", SomeModule::PRIVATE); // ok!
16211621
```
16221622
"##,
16231623

1624+
E0659: r##"
1625+
An item usage is ambiguous.
1626+
1627+
Erroneous code example:
1628+
1629+
```compile_fail,E0659
1630+
pub mod moon {
1631+
pub fn foo() {}
1632+
}
1633+
1634+
pub mod earth {
1635+
pub fn foo() {}
1636+
}
1637+
1638+
mod collider {
1639+
pub use moon::*;
1640+
pub use earth::*;
1641+
}
1642+
1643+
fn main() {
1644+
collider::foo(); // ERROR: `foo` is ambiguous
1645+
}
1646+
```
1647+
1648+
This error generally appears when two items with the same name are imported into
1649+
a module. Here, the `foo` functions are imported and reexported from the
1650+
`collider` module and therefore, when we're using `collider::foo()`, both
1651+
functions collide.
1652+
1653+
To solve this error, the best solution is generally to keep the path before the
1654+
item when using it. Example:
1655+
1656+
```
1657+
pub mod moon {
1658+
pub fn foo() {}
1659+
}
1660+
1661+
pub mod earth {
1662+
pub fn foo() {}
1663+
}
1664+
1665+
mod collider {
1666+
pub use moon;
1667+
pub use earth;
1668+
}
1669+
1670+
fn main() {
1671+
collider::moon::foo(); // ok!
1672+
collider::earth::foo(); // ok!
1673+
}
1674+
```
1675+
"##,
1676+
16241677
}
16251678

16261679
register_diagnostics! {

src/librustc_resolve/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2791,8 +2791,8 @@ impl<'a> Resolver<'a> {
27912791
if let Some(sp) = self.current_type_ascription.last() {
27922792
let mut sp = *sp;
27932793
loop { // try to find the `:`, bail on first non-':'/non-whitespace
2794-
sp = sp.next_point();
2795-
if let Ok(snippet) = cm.span_to_snippet(sp.to(sp.next_point())) {
2794+
sp = cm.next_point(sp);
2795+
if let Ok(snippet) = cm.span_to_snippet(sp.to(cm.next_point(sp))) {
27962796
debug!("snippet {:?}", snippet);
27972797
let line_sp = cm.lookup_char_pos(sp.hi()).line;
27982798
let line_base_sp = cm.lookup_char_pos(base_span.lo()).line;
@@ -3783,7 +3783,7 @@ impl<'a> Resolver<'a> {
37833783
self.session.buffer_lint(lint::builtin::LEGACY_IMPORTS, id, span, &msg);
37843784
} else {
37853785
let mut err =
3786-
self.session.struct_span_err(span, &format!("`{}` is ambiguous", name));
3786+
struct_span_err!(self.session, span, E0659, "`{}` is ambiguous", name);
37873787
err.span_note(b1.span, &msg1);
37883788
match b2.def() {
37893789
Def::Macro(..) if b2.span == DUMMY_SP =>

src/librustc_typeck/check/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
24102410
err.span_label(def_s, "defined here");
24112411
}
24122412
if sugg_unit {
2413-
let sugg_span = expr_sp.end_point();
2413+
let sugg_span = sess.codemap().end_point(expr_sp);
24142414
// remove closing `)` from the span
24152415
let sugg_span = sugg_span.with_hi(sugg_span.lo());
24162416
err.span_suggestion(
@@ -4400,10 +4400,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
44004400
/// statement and the return type has been left as default or has been specified as `()`. If so,
44014401
/// it suggests adding a semicolon.
44024402
fn suggest_missing_semicolon(&self,
4403-
err: &mut DiagnosticBuilder<'tcx>,
4404-
expression: &'gcx hir::Expr,
4405-
expected: Ty<'tcx>,
4406-
cause_span: Span) {
4403+
err: &mut DiagnosticBuilder<'tcx>,
4404+
expression: &'gcx hir::Expr,
4405+
expected: Ty<'tcx>,
4406+
cause_span: Span) {
44074407
if expected.is_nil() {
44084408
// `BlockTailExpression` only relevant if the tail expr would be
44094409
// useful on its own.
@@ -4415,7 +4415,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
44154415
hir::ExprLoop(..) |
44164416
hir::ExprMatch(..) |
44174417
hir::ExprBlock(..) => {
4418-
let sp = cause_span.next_point();
4418+
let sp = self.tcx.sess.codemap().next_point(cause_span);
44194419
err.span_suggestion(sp,
44204420
"try adding a semicolon",
44214421
";".to_string());

src/librustdoc/html/layout.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,22 @@ r##"<!DOCTYPE html>
9494
<h2>Keyboard Shortcuts</h2>
9595
9696
<dl>
97-
<dt>?</dt>
97+
<dt><kbd>?</kbd></dt>
9898
<dd>Show this help dialog</dd>
99-
<dt>S</dt>
99+
<dt><kbd>S</kbd></dt>
100100
<dd>Focus the search field</dd>
101-
<dt></dt>
101+
<dt><kbd>↑</kbd></dt>
102102
<dd>Move up in search results</dd>
103-
<dt></dt>
103+
<dt><kbd>↓</kbd></dt>
104104
<dd>Move down in search results</dd>
105-
<dt></dt>
105+
<dt><kbd>↹</kbd></dt>
106106
<dd>Switch tab</dd>
107-
<dt>&#9166;</dt>
107+
<dt><kbd>&#9166;</kbd></dt>
108108
<dd>Go to active search result</dd>
109-
<dt style="width:31px;">+ / -</dt>
110-
<dd>Collapse/expand all sections</dd>
109+
<dt><kbd>+</kbd></dt>
110+
<dd>Expand all sections</dd>
111+
<dt><kbd>-</kbd></dt>
112+
<dd>Collapse all sections</dd>
111113
</dl>
112114
</div>
113115

src/librustdoc/html/static/rustdoc.css

+12-6
Original file line numberDiff line numberDiff line change
@@ -585,18 +585,13 @@ body.blur > :not(#help) {
585585
flex: 0 0 auto;
586586
box-shadow: 0 0 6px rgba(0,0,0,.2);
587587
width: 550px;
588-
height: 354px;
588+
height: auto;
589589
border: 1px solid;
590590
}
591591
#help dt {
592592
float: left;
593-
border-radius: 4px;
594-
border: 1px solid;
595-
width: 23px;
596-
text-align: center;
597593
clear: left;
598594
display: block;
599-
margin-top: -1px;
600595
}
601596
#help dd { margin: 5px 35px; }
602597
#help .infos { padding-left: 0; }
@@ -1134,3 +1129,14 @@ h3.important {
11341129
left: -42px;
11351130
margin-top: 2px;
11361131
}
1132+
1133+
kbd {
1134+
display: inline-block;
1135+
padding: 3px 5px;
1136+
font: 15px "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
1137+
line-height: 10px;
1138+
vertical-align: middle;
1139+
border: solid 1px;
1140+
border-radius: 3px;
1141+
box-shadow: inset 0 -1px 0;
1142+
}

src/librustdoc/html/static/styles/main.css

+8-5
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,6 @@ a.test-arrow {
194194
border-color: #bfbfbf;
195195
}
196196

197-
#help dt {
198-
border-color: #bfbfbf;
199-
background: #fff;
200-
}
201-
202197
.since {
203198
color: grey;
204199
}
@@ -348,3 +343,11 @@ pre.ignore:hover, .information:hover + pre.ignore {
348343
border-bottom-color: #e0e0e0;
349344
}
350345
}
346+
347+
kbd {
348+
color: #444d56;
349+
background-color: #fafbfc;
350+
border-color: #d1d5da;
351+
border-bottom-color: #c6cbd1;
352+
box-shadow-color: #c6cbd1;
353+
}

src/libstd/net/addr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use fmt;
1212
use hash;
1313
use io;
1414
use mem;
15-
use net::{lookup_host, ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
15+
use net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
16+
#[allow(deprecated)]
17+
use net::lookup_host;
1618
use option;
1719
use sys::net::netc as c;
1820
use sys_common::{FromInner, AsInner, IntoInner};
@@ -845,6 +847,7 @@ impl ToSocketAddrs for (Ipv6Addr, u16) {
845847
}
846848
}
847849

850+
#[allow(deprecated)]
848851
fn resolve_socket_addr(s: &str, p: u16) -> io::Result<vec::IntoIter<SocketAddr>> {
849852
let ips = lookup_host(s)?;
850853
let v: Vec<_> = ips.map(|mut a| { a.set_port(p); a }).collect();

src/libstd/net/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,15 @@ fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
134134
iterator and returning socket \
135135
addresses",
136136
issue = "27705")]
137+
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
137138
pub struct LookupHost(net_imp::LookupHost);
138139

139140
#[unstable(feature = "lookup_host", reason = "unsure about the returned \
140141
iterator and returning socket \
141142
addresses",
142143
issue = "27705")]
144+
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
145+
#[allow(deprecated)]
143146
impl Iterator for LookupHost {
144147
type Item = SocketAddr;
145148
fn next(&mut self) -> Option<SocketAddr> { self.0.next() }
@@ -149,6 +152,8 @@ impl Iterator for LookupHost {
149152
iterator and returning socket \
150153
addresses",
151154
issue = "27705")]
155+
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
156+
#[allow(deprecated)]
152157
impl fmt::Debug for LookupHost {
153158
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
154159
f.pad("LookupHost { .. }")
@@ -181,6 +186,8 @@ impl fmt::Debug for LookupHost {
181186
iterator and returning socket \
182187
addresses",
183188
issue = "27705")]
189+
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
190+
#[allow(deprecated)]
184191
pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
185192
net_imp::lookup_host(host).map(LookupHost)
186193
}

src/libstd/sys/unix/l4re.rs

-4
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,5 @@ pub mod net {
437437
pub fn lookup_host(_: &str) -> io::Result<LookupHost> {
438438
unimpl!();
439439
}
440-
441-
pub fn res_init_if_glibc_before_2_26() -> io::Result<()> {
442-
unimpl!();
443-
}
444440
}
445441

0 commit comments

Comments
 (0)