Skip to content

Commit c8b94c6

Browse files
committed
Auto merge of #46829 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 11 pull requests - Successful merges: #46700, #46786, #46790, #46800, #46801, #46802, #46804, #46805, #46812, #46824, #46825 - Failed merges:
2 parents b76f224 + b5f6884 commit c8b94c6

Some content is hidden

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

45 files changed

+328
-467
lines changed

src/libcore/num/mod.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,13 @@ macro_rules! int_impl {
273273
/// Basic usage:
274274
///
275275
/// ```
276-
/// let n = 0x0123456789ABCDEFi64;
277-
/// let m = -0x1032547698BADCFFi64;
276+
/// let n: i16 = 0b0000000_01010101;
277+
/// assert_eq!(n, 85);
278278
///
279-
/// assert_eq!(n.swap_bytes(), m);
279+
/// let m = n.swap_bytes();
280+
///
281+
/// assert_eq!(m, 0b01010101_00000000);
282+
/// assert_eq!(m, 21760);
280283
/// ```
281284
#[stable(feature = "rust1", since = "1.0.0")]
282285
#[inline]
@@ -1466,10 +1469,13 @@ macro_rules! uint_impl {
14661469
/// Basic usage:
14671470
///
14681471
/// ```
1469-
/// let n = 0x0123456789ABCDEFu64;
1470-
/// let m = 0xEFCDAB8967452301u64;
1472+
/// let n: u16 = 0b0000000_01010101;
1473+
/// assert_eq!(n, 85);
1474+
///
1475+
/// let m = n.swap_bytes();
14711476
///
1472-
/// assert_eq!(n.swap_bytes(), m);
1477+
/// assert_eq!(m, 0b01010101_00000000);
1478+
/// assert_eq!(m, 21760);
14731479
/// ```
14741480
#[stable(feature = "rust1", since = "1.0.0")]
14751481
#[inline]

src/librustc/traits/error_reporting.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
484484
-> DiagnosticBuilder<'tcx>
485485
{
486486
let msg = "impl has stricter requirements than trait";
487-
let mut err = struct_span_err!(self.tcx.sess,
488-
error_span,
489-
E0276,
490-
"{}", msg);
487+
let sp = self.tcx.sess.codemap().def_span(error_span);
488+
489+
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
491490

492491
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
493492
let span = self.tcx.sess.codemap().def_span(trait_item_span);
494493
err.span_label(span, format!("definition of `{}` from trait", item_name));
495494
}
496495

497-
err.span_label(
498-
error_span,
499-
format!("impl has extra requirement {}", requirement));
496+
err.span_label(sp, format!("impl has extra requirement {}", requirement));
500497

501498
err
502499
}
@@ -647,7 +644,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
647644

648645
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
649646
let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap();
650-
let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap();
647+
let closure_span = self.tcx.sess.codemap()
648+
.def_span(self.tcx.hir.span_if_local(closure_def_id).unwrap());
651649
let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap();
652650
let mut err = struct_span_err!(
653651
self.tcx.sess, closure_span, E0525,
@@ -656,6 +654,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
656654
kind,
657655
found_kind);
658656

657+
err.span_label(
658+
closure_span,
659+
format!("this closure implements `{}`, not `{}`", found_kind, kind));
659660
err.span_label(
660661
obligation.cause.span,
661662
format!("the requirement to implement `{}` derives from here", kind));
@@ -667,12 +668,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
667668
let closure_hir_id = self.tcx.hir.node_to_hir_id(node_id);
668669
match (found_kind, tables.closure_kind_origins().get(closure_hir_id)) {
669670
(ty::ClosureKind::FnOnce, Some((span, name))) => {
670-
err.span_note(*span, &format!(
671+
err.span_label(*span, format!(
671672
"closure is `FnOnce` because it moves the \
672673
variable `{}` out of its environment", name));
673674
},
674675
(ty::ClosureKind::FnMut, Some((span, name))) => {
675-
err.span_note(*span, &format!(
676+
err.span_label(*span, format!(
676677
"closure is `FnMut` because it mutates the \
677678
variable `{}` here", name));
678679
},

src/librustc/traits/specialize/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -341,24 +341,28 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
341341
}),
342342
if used_to_be_allowed { " (E0119)" } else { "" }
343343
);
344+
let impl_span = tcx.sess.codemap().def_span(
345+
tcx.span_of_impl(impl_def_id).unwrap()
346+
);
344347
let mut err = if used_to_be_allowed {
345348
tcx.struct_span_lint_node(
346349
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
347350
tcx.hir.as_local_node_id(impl_def_id).unwrap(),
348-
tcx.span_of_impl(impl_def_id).unwrap(),
351+
impl_span,
349352
&msg)
350353
} else {
351354
struct_span_err!(tcx.sess,
352-
tcx.span_of_impl(impl_def_id).unwrap(),
355+
impl_span,
353356
E0119,
354357
"{}",
355358
msg)
356359
};
357360

358361
match tcx.span_of_impl(overlap.with_impl) {
359362
Ok(span) => {
360-
err.span_label(span, format!("first implementation here"));
361-
err.span_label(tcx.span_of_impl(impl_def_id).unwrap(),
363+
err.span_label(tcx.sess.codemap().def_span(span),
364+
format!("first implementation here"));
365+
err.span_label(impl_span,
362366
format!("conflicting implementation{}",
363367
overlap.self_desc
364368
.map_or(String::new(),

src/librustc_lint/builtin.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl MissingDoc {
352352
let has_doc = attrs.iter().any(|a| a.is_value_str() && a.check_name("doc"));
353353
if !has_doc {
354354
cx.span_lint(MISSING_DOCS,
355-
sp,
355+
cx.tcx.sess.codemap().def_span(sp),
356356
&format!("missing documentation for {}", desc));
357357
}
358358
}
@@ -914,15 +914,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
914914
// no break */ }`) shouldn't be linted unless it actually
915915
// recurs.
916916
if !reached_exit_without_self_call && !self_call_spans.is_empty() {
917+
let sp = cx.tcx.sess.codemap().def_span(sp);
917918
let mut db = cx.struct_span_lint(UNCONDITIONAL_RECURSION,
918919
sp,
919920
"function cannot return without recurring");
921+
db.span_label(sp, "cannot return without recurring");
920922
// offer some help to the programmer.
921923
for call in &self_call_spans {
922-
db.span_note(*call, "recursive call site");
924+
db.span_label(*call, "recursive call site");
923925
}
924-
db.help("a `loop` may express intention \
925-
better if this is on purpose");
926+
db.help("a `loop` may express intention better if this is on purpose");
926927
db.emit();
927928
}
928929

src/librustc_mir/transform/check_unsafety.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,13 @@ fn is_enclosed(tcx: TyCtxt,
388388
}
389389

390390
fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet<ast::NodeId>, id: ast::NodeId) {
391-
let span = tcx.hir.span(id);
392-
let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, "unnecessary `unsafe` block");
393-
db.span_label(span, "unnecessary `unsafe` block");
391+
let span = tcx.sess.codemap().def_span(tcx.hir.span(id));
392+
let msg = "unnecessary `unsafe` block";
393+
let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg);
394+
db.span_label(span, msg);
394395
if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) {
395-
db.span_note(tcx.hir.span(id),
396-
&format!("because it's nested under this `unsafe` {}", kind));
396+
db.span_label(tcx.sess.codemap().def_span(tcx.hir.span(id)),
397+
format!("because it's nested under this `unsafe` {}", kind));
397398
}
398399
db.emit();
399400
}

src/librustc_resolve/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3840,7 +3840,7 @@ impl<'a> Resolver<'a> {
38403840
false => "defined",
38413841
};
38423842

3843-
let (name, span) = (ident.name, new_binding.span);
3843+
let (name, span) = (ident.name, self.session.codemap().def_span(new_binding.span));
38443844

38453845
if let Some(s) = self.name_already_seen.get(&name) {
38463846
if s == &span {
@@ -3885,8 +3885,8 @@ impl<'a> Resolver<'a> {
38853885

38863886
err.span_label(span, format!("`{}` re{} here", name, new_participle));
38873887
if old_binding.span != syntax_pos::DUMMY_SP {
3888-
err.span_label(old_binding.span, format!("previous {} of the {} `{}` here",
3889-
old_noun, old_kind, name));
3888+
err.span_label(self.session.codemap().def_span(old_binding.span),
3889+
format!("previous {} of the {} `{}` here", old_noun, old_kind, name));
38903890
}
38913891

38923892
// See https://github.com/rust-lang/rust/issues/32354

src/librustc_trans/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
406406
let zero = C_null(bcx.ccx.isize_ty());
407407
// `offset == 0`
408408
let is_zero = bcx.icmp(llvm::IntPredicate::IntEQ, offset, zero);
409-
// `if offset == 0 { 0 } else { offset - align }`
410-
bcx.select(is_zero, zero, bcx.sub(offset, align))
409+
// `if offset == 0 { 0 } else { align - offset }`
410+
bcx.select(is_zero, zero, bcx.sub(align, offset))
411411
}
412412
name if name.starts_with("simd_") => {
413413
match generic_simd_intrinsic(bcx, name,

src/librustdoc/clean/inline.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,7 @@ fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
448448
///
449449
/// The inverse of this filtering logic can be found in the `Clean`
450450
/// implementation for `AssociatedType`
451-
fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics)
452-
-> clean::Generics {
451+
fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean::Generics {
453452
for pred in &mut g.where_predicates {
454453
match *pred {
455454
clean::WherePredicate::BoundPredicate {

src/librustdoc/clean/mod.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -1190,16 +1190,36 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
11901190
pub struct Generics {
11911191
pub lifetimes: Vec<Lifetime>,
11921192
pub type_params: Vec<TyParam>,
1193-
pub where_predicates: Vec<WherePredicate>
1193+
pub where_predicates: Vec<WherePredicate>,
11941194
}
11951195

11961196
impl Clean<Generics> for hir::Generics {
11971197
fn clean(&self, cx: &DocContext) -> Generics {
1198-
Generics {
1198+
let mut g = Generics {
11991199
lifetimes: self.lifetimes.clean(cx),
12001200
type_params: self.ty_params.clean(cx),
12011201
where_predicates: self.where_clause.predicates.clean(cx)
1202+
};
1203+
1204+
// Some duplicates are generated for ?Sized bounds between type params and where
1205+
// predicates. The point in here is to move the bounds definitions from type params
1206+
// to where predicates when such cases occur.
1207+
for where_pred in &mut g.where_predicates {
1208+
match *where_pred {
1209+
WherePredicate::BoundPredicate { ty: Generic(ref name), ref mut bounds } => {
1210+
if bounds.is_empty() {
1211+
for type_params in &mut g.type_params {
1212+
if &type_params.name == name {
1213+
mem::swap(bounds, &mut type_params.bounds);
1214+
break
1215+
}
1216+
}
1217+
}
1218+
}
1219+
_ => continue,
1220+
}
12021221
}
1222+
g
12031223
}
12041224
}
12051225

@@ -1225,7 +1245,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
12251245
let mut where_predicates = preds.predicates.to_vec().clean(cx);
12261246

12271247
// Type parameters and have a Sized bound by default unless removed with
1228-
// ?Sized. Scan through the predicates and mark any type parameter with
1248+
// ?Sized. Scan through the predicates and mark any type parameter with
12291249
// a Sized bound, removing the bounds as we find them.
12301250
//
12311251
// Note that associated types also have a sized bound by default, but we

src/librustdoc/clean/simplify.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec<WP>) -> Vec<WP> {
3838
let mut lifetimes = Vec::new();
3939
let mut equalities = Vec::new();
4040
let mut tybounds = Vec::new();
41+
4142
for clause in clauses {
4243
match clause {
4344
WP::BoundPredicate { ty, bounds } => {

src/librustdoc/html/static/main.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,9 @@
681681
}
682682

683683
function checkPath(startsWith, lastElem, ty) {
684+
if (startsWith.length === 0) {
685+
return 0;
686+
}
684687
var ret_lev = MAX_LEV_DISTANCE + 1;
685688
var path = ty.path.split("::");
686689

@@ -706,18 +709,7 @@
706709
lev_total += lev;
707710
}
708711
if (aborted === false) {
709-
var extra = MAX_LEV_DISTANCE + 1;
710-
if (i + startsWith.length < path.length) {
711-
extra = levenshtein(path[i + startsWith.length], lastElem);
712-
}
713-
if (extra > MAX_LEV_DISTANCE) {
714-
extra = levenshtein(ty.name, lastElem);
715-
}
716-
if (extra < MAX_LEV_DISTANCE + 1) {
717-
lev_total += extra;
718-
ret_lev = Math.min(ret_lev,
719-
Math.round(lev_total / (startsWith.length + 1)));
720-
}
712+
ret_lev = Math.min(ret_lev, Math.round(lev_total / startsWith.length));
721713
}
722714
}
723715
return ret_lev;
@@ -934,6 +926,13 @@
934926
}
935927

936928
lev += lev_add;
929+
if (lev > 0 && val.length > 3 && searchWords[j].startsWith(val)) {
930+
if (val.length < 6) {
931+
lev -= 1;
932+
} else {
933+
lev = 0;
934+
}
935+
}
937936
if (in_args <= MAX_LEV_DISTANCE) {
938937
if (results_in_args[fullId] === undefined) {
939938
results_in_args[fullId] = {
@@ -1447,7 +1446,7 @@
14471446

14481447
// Draw a convenient sidebar of known crates if we have a listing
14491448
if (rootPath === '../') {
1450-
var sidebar = document.getElementsByClassName('sidebar')[0];
1449+
var sidebar = document.getElementsByClassName('sidebar-elems')[0];
14511450
var div = document.createElement('div');
14521451
div.className = 'block crate';
14531452
div.innerHTML = '<h3>Crates</h3>';

src/librustdoc/html/static/rustdoc.css

+20
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,26 @@ h4 > .important-traits {
10111011
left: -22px;
10121012
top: 24px;
10131013
}
1014+
1015+
#titles > div > div.count {
1016+
float: left;
1017+
width: 100%;
1018+
}
1019+
1020+
#titles {
1021+
height: 50px;
1022+
}
1023+
}
1024+
1025+
1026+
@media (max-width: 416px) {
1027+
#titles {
1028+
height: 73px;
1029+
}
1030+
1031+
#titles > div {
1032+
height: 73px;
1033+
}
10141034
}
10151035

10161036
.modal {
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(align_offset)]
12+
13+
fn main() {
14+
let x = 1 as *const u8;
15+
assert_eq!(x.align_offset(8), 7);
16+
}

src/test/rustdoc/where-sized.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "foo"]
12+
13+
// @has foo/fn.foo.html
14+
// @has - '//*[@class="rust fn"]' 'pub fn foo<X, Y: ?Sized>(_: &X)'
15+
// @has - '//*[@class="rust fn"]' 'where X: ?Sized,'
16+
pub fn foo<X, Y: ?Sized>(_: &X) where X: ?Sized {}

src/test/ui/blind-item-item-shadow.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0255]: the name `foo` is defined multiple times
22
--> $DIR/blind-item-item-shadow.rs:13:5
33
|
44
11 | mod foo { pub mod foo { } }
5-
| ---------------------------- previous definition of the module `foo` here
5+
| ------- previous definition of the module `foo` here
66
12 |
77
13 | use foo::foo;
88
| ^^^^^^^^ `foo` reimported here

0 commit comments

Comments
 (0)