From 6351ebb7e55345d799499c8a326530d3ce35e00a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 13 Dec 2017 00:20:45 +0100 Subject: [PATCH 01/12] make doc search more relevant --- src/librustdoc/html/static/main.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 81971157b84..0c775f2a58e 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -681,6 +681,9 @@ } function checkPath(startsWith, lastElem, ty) { + if (startsWith.length === 0) { + return 0; + } var ret_lev = MAX_LEV_DISTANCE + 1; var path = ty.path.split("::"); @@ -706,18 +709,7 @@ lev_total += lev; } if (aborted === false) { - var extra = MAX_LEV_DISTANCE + 1; - if (i + startsWith.length < path.length) { - extra = levenshtein(path[i + startsWith.length], lastElem); - } - if (extra > MAX_LEV_DISTANCE) { - extra = levenshtein(ty.name, lastElem); - } - if (extra < MAX_LEV_DISTANCE + 1) { - lev_total += extra; - ret_lev = Math.min(ret_lev, - Math.round(lev_total / (startsWith.length + 1))); - } + ret_lev = Math.min(ret_lev, Math.round(lev_total / startsWith.length)); } } return ret_lev; @@ -934,6 +926,9 @@ } lev += lev_add; + if (searchWords[j].startsWith(val)) { + lev -= 1; + } if (in_args <= MAX_LEV_DISTANCE) { if (results_in_args[fullId] === undefined) { results_in_args[fullId] = { From 97c18f420e33b6468949cf42662b3fdac809f14e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 15 Dec 2017 15:42:38 +0100 Subject: [PATCH 02/12] Improve results a bit --- src/librustdoc/html/static/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 0c775f2a58e..1b9035367f7 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -926,8 +926,12 @@ } lev += lev_add; - if (searchWords[j].startsWith(val)) { - lev -= 1; + if (lev > 0 && val.length > 3 && searchWords[j].startsWith(val)) { + if (val.length < 6) { + lev -= 1; + } else { + lev = 0; + } } if (in_args <= MAX_LEV_DISTANCE) { if (results_in_args[fullId] === undefined) { From 05cb6a5857a0b3966dfb48e6cc779b6a2137d6c6 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 17 Dec 2017 16:02:11 -0500 Subject: [PATCH 03/12] Display binary notation for numeric swap_bytes methods. This better illustrates what's happening to the bits behind the scenes. --- src/libcore/num/mod.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 9ee86d0f1a0..245ca83f28f 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -273,10 +273,13 @@ macro_rules! int_impl { /// Basic usage: /// /// ``` - /// let n = 0x0123456789ABCDEFi64; - /// let m = -0x1032547698BADCFFi64; + /// let n: i16 = 0b0000000_01010101; + /// assert_eq!(n, 85); /// - /// assert_eq!(n.swap_bytes(), m); + /// let m = n.swap_bytes(); + /// + /// assert_eq!(m, 0b01010101_00000000); + /// assert_eq!(m, 21760); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -1466,10 +1469,13 @@ macro_rules! uint_impl { /// Basic usage: /// /// ``` - /// let n = 0x0123456789ABCDEFu64; - /// let m = 0xEFCDAB8967452301u64; + /// let n: u16 = 0b0000000_01010101; + /// assert_eq!(n, 85); /// - /// assert_eq!(n.swap_bytes(), m); + /// let m = n.swap_bytes(); + /// + /// assert_eq!(m, 0b01010101_00000000); + /// assert_eq!(m, 21760); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] From 61181aeead9c4c83ff119320760ead6be2d98c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Dec 2017 22:44:32 -0800 Subject: [PATCH 04/12] Point at def span on redefined name diagnostic --- src/librustc_resolve/lib.rs | 6 +++--- src/test/ui/blind-item-item-shadow.stderr | 2 +- src/test/ui/enum-and-module-in-same-scope.stderr | 15 +++++---------- src/test/ui/issue-19498.stderr | 6 +++--- src/test/ui/issue-21546.stderr | 16 ++++++++-------- src/test/ui/issue-24081.stderr | 8 ++++---- .../ui/resolve-conflict-item-vs-import.stderr | 2 +- 7 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c42ac7aaa93..864a61108b1 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3840,7 +3840,7 @@ impl<'a> Resolver<'a> { false => "defined", }; - let (name, span) = (ident.name, new_binding.span); + let (name, span) = (ident.name, self.session.codemap().def_span(new_binding.span)); if let Some(s) = self.name_already_seen.get(&name) { if s == &span { @@ -3885,8 +3885,8 @@ impl<'a> Resolver<'a> { err.span_label(span, format!("`{}` re{} here", name, new_participle)); if old_binding.span != syntax_pos::DUMMY_SP { - err.span_label(old_binding.span, format!("previous {} of the {} `{}` here", - old_noun, old_kind, name)); + err.span_label(self.session.codemap().def_span(old_binding.span), + format!("previous {} of the {} `{}` here", old_noun, old_kind, name)); } // See https://github.com/rust-lang/rust/issues/32354 diff --git a/src/test/ui/blind-item-item-shadow.stderr b/src/test/ui/blind-item-item-shadow.stderr index b9f3e742c66..855b3799eb5 100644 --- a/src/test/ui/blind-item-item-shadow.stderr +++ b/src/test/ui/blind-item-item-shadow.stderr @@ -2,7 +2,7 @@ error[E0255]: the name `foo` is defined multiple times --> $DIR/blind-item-item-shadow.rs:13:5 | 11 | mod foo { pub mod foo { } } - | ---------------------------- previous definition of the module `foo` here + | ------- previous definition of the module `foo` here 12 | 13 | use foo::foo; | ^^^^^^^^ `foo` reimported here diff --git a/src/test/ui/enum-and-module-in-same-scope.stderr b/src/test/ui/enum-and-module-in-same-scope.stderr index 723e13f4109..ddbee0655e4 100644 --- a/src/test/ui/enum-and-module-in-same-scope.stderr +++ b/src/test/ui/enum-and-module-in-same-scope.stderr @@ -1,16 +1,11 @@ error[E0428]: the name `Foo` is defined multiple times --> $DIR/enum-and-module-in-same-scope.rs:15:1 | -11 | / enum Foo { -12 | | X -13 | | } - | |_- previous definition of the type `Foo` here -14 | -15 | / mod Foo { //~ ERROR the name `Foo` is defined multiple times -16 | | pub static X: isize = 42; -17 | | fn f() { f() } // Check that this does not result in a resolution error -18 | | } - | |_^ `Foo` redefined here +11 | enum Foo { + | -------- previous definition of the type `Foo` here +... +15 | mod Foo { //~ ERROR the name `Foo` is defined multiple times + | ^^^^^^^ `Foo` redefined here | = note: `Foo` must be defined only once in the type namespace of this module diff --git a/src/test/ui/issue-19498.stderr b/src/test/ui/issue-19498.stderr index e7a308eacfe..489abf715de 100644 --- a/src/test/ui/issue-19498.stderr +++ b/src/test/ui/issue-19498.stderr @@ -5,7 +5,7 @@ error[E0255]: the name `A` is defined multiple times | ------- previous import of the module `A` here 12 | use self::B; 13 | mod A {} //~ ERROR the name `A` is defined multiple times - | ^^^^^^^^ `A` redefined here + | ^^^^^ `A` redefined here | = note: `A` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import @@ -20,7 +20,7 @@ error[E0255]: the name `B` is defined multiple times | ------- previous import of the module `B` here ... 15 | pub mod B {} //~ ERROR the name `B` is defined multiple times - | ^^^^^^^^^^^^ `B` redefined here + | ^^^^^^^^^ `B` redefined here | = note: `B` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import @@ -34,7 +34,7 @@ error[E0255]: the name `D` is defined multiple times 18 | use C::D; | ---- previous import of the module `D` here 19 | mod D {} //~ ERROR the name `D` is defined multiple times - | ^^^^^^^^ `D` redefined here + | ^^^^^ `D` redefined here | = note: `D` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import diff --git a/src/test/ui/issue-21546.stderr b/src/test/ui/issue-21546.stderr index 9ec8dcdd83a..ec953103a1c 100644 --- a/src/test/ui/issue-21546.stderr +++ b/src/test/ui/issue-21546.stderr @@ -2,7 +2,7 @@ error[E0428]: the name `Foo` is defined multiple times --> $DIR/issue-21546.rs:17:1 | 14 | mod Foo { } - | ----------- previous definition of the module `Foo` here + | ------- previous definition of the module `Foo` here ... 17 | struct Foo; | ^^^^^^^^^^^ `Foo` redefined here @@ -13,7 +13,7 @@ error[E0428]: the name `Bar` is defined multiple times --> $DIR/issue-21546.rs:24:1 | 21 | mod Bar { } - | ----------- previous definition of the module `Bar` here + | ------- previous definition of the module `Bar` here ... 24 | struct Bar(i32); | ^^^^^^^^^^^^^^^^ `Bar` redefined here @@ -27,7 +27,7 @@ error[E0428]: the name `Baz` is defined multiple times | ---------------- previous definition of the type `Baz` here ... 32 | mod Baz { } - | ^^^^^^^^^^^ `Baz` redefined here + | ^^^^^^^ `Baz` redefined here | = note: `Baz` must be defined only once in the type namespace of this module @@ -35,10 +35,10 @@ error[E0428]: the name `Qux` is defined multiple times --> $DIR/issue-21546.rs:40:1 | 37 | struct Qux { x: bool } - | ---------------------- previous definition of the type `Qux` here + | ---------- previous definition of the type `Qux` here ... 40 | mod Qux { } - | ^^^^^^^^^^^ `Qux` redefined here + | ^^^^^^^ `Qux` redefined here | = note: `Qux` must be defined only once in the type namespace of this module @@ -49,7 +49,7 @@ error[E0428]: the name `Quux` is defined multiple times | ------------ previous definition of the type `Quux` here ... 48 | mod Quux { } - | ^^^^^^^^^^^^ `Quux` redefined here + | ^^^^^^^^ `Quux` redefined here | = note: `Quux` must be defined only once in the type namespace of this module @@ -57,10 +57,10 @@ error[E0428]: the name `Corge` is defined multiple times --> $DIR/issue-21546.rs:56:1 | 53 | enum Corge { A, B } - | ------------------- previous definition of the type `Corge` here + | ---------- previous definition of the type `Corge` here ... 56 | mod Corge { } - | ^^^^^^^^^^^^^ `Corge` redefined here + | ^^^^^^^^^ `Corge` redefined here | = note: `Corge` must be defined only once in the type namespace of this module diff --git a/src/test/ui/issue-24081.stderr b/src/test/ui/issue-24081.stderr index 37a2fba3852..969cf3577fb 100644 --- a/src/test/ui/issue-24081.stderr +++ b/src/test/ui/issue-24081.stderr @@ -20,7 +20,7 @@ error[E0255]: the name `Sub` is defined multiple times | ------------- previous import of the trait `Sub` here ... 19 | struct Sub { x: f32 } //~ ERROR the name `Sub` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^ `Sub` redefined here + | ^^^^^^^^^^ `Sub` redefined here | = note: `Sub` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import @@ -35,7 +35,7 @@ error[E0255]: the name `Mul` is defined multiple times | ------------- previous import of the trait `Mul` here ... 21 | enum Mul { A, B } //~ ERROR the name `Mul` is defined multiple times - | ^^^^^^^^^^^^^^^^^ `Mul` redefined here + | ^^^^^^^^ `Mul` redefined here | = note: `Mul` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import @@ -50,7 +50,7 @@ error[E0255]: the name `Div` is defined multiple times | ------------- previous import of the trait `Div` here ... 23 | mod Div { } //~ ERROR the name `Div` is defined multiple times - | ^^^^^^^^^^^ `Div` redefined here + | ^^^^^^^ `Div` redefined here | = note: `Div` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import @@ -65,7 +65,7 @@ error[E0255]: the name `Rem` is defined multiple times | ------------- previous import of the trait `Rem` here ... 25 | trait Rem { } //~ ERROR the name `Rem` is defined multiple times - | ^^^^^^^^^^^^^^ `Rem` redefined here + | ^^^^^^^^^ `Rem` redefined here | = note: `Rem` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import diff --git a/src/test/ui/resolve-conflict-item-vs-import.stderr b/src/test/ui/resolve-conflict-item-vs-import.stderr index a52dcb37a2f..03ef66681e4 100644 --- a/src/test/ui/resolve-conflict-item-vs-import.stderr +++ b/src/test/ui/resolve-conflict-item-vs-import.stderr @@ -5,7 +5,7 @@ error[E0255]: the name `transmute` is defined multiple times | ------------------- previous import of the value `transmute` here 12 | 13 | fn transmute() {} - | ^^^^^^^^^^^^^^^^^ `transmute` redefined here + | ^^^^^^^^^^^^^^ `transmute` redefined here | = note: `transmute` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import From ea64ab7d4eea9b5ba89b21eeed4ad897ff6a2ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Dec 2017 23:46:55 -0800 Subject: [PATCH 05/12] Use def span for conflicting impls and recursive fn --- src/librustc/traits/specialize/mod.rs | 12 +- src/librustc_lint/builtin.rs | 9 +- .../ui/coherence-overlap-downstream.stderr | 8 +- .../ui/coherence-overlap-issue-23516.stderr | 4 +- src/test/ui/coherence-overlap-upstream.stderr | 4 +- src/test/ui/e0119/complex-impl.stderr | 2 +- src/test/ui/e0119/conflict-with-std.stderr | 25 +-- src/test/ui/e0119/issue-23563.stderr | 6 +- src/test/ui/e0119/issue-27403.stderr | 8 +- src/test/ui/e0119/issue-28981.stderr | 2 +- src/test/ui/e0119/so-37347311.stderr | 8 +- ...ture-gate-overlapping_marker_traits.stderr | 4 +- src/test/ui/issue-28568.stderr | 15 +- .../ui/lint-unconditional-recursion.stderr | 211 ++++++------------ ...specialization-feature-gate-overlap.stderr | 14 +- 15 files changed, 111 insertions(+), 221 deletions(-) diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 6a96d01d5f9..afe29cc0e7b 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -341,15 +341,18 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx }), if used_to_be_allowed { " (E0119)" } else { "" } ); + let impl_span = tcx.sess.codemap().def_span( + tcx.span_of_impl(impl_def_id).unwrap() + ); let mut err = if used_to_be_allowed { tcx.struct_span_lint_node( lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS, tcx.hir.as_local_node_id(impl_def_id).unwrap(), - tcx.span_of_impl(impl_def_id).unwrap(), + impl_span, &msg) } else { struct_span_err!(tcx.sess, - tcx.span_of_impl(impl_def_id).unwrap(), + impl_span, E0119, "{}", msg) @@ -357,8 +360,9 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx match tcx.span_of_impl(overlap.with_impl) { Ok(span) => { - err.span_label(span, format!("first implementation here")); - err.span_label(tcx.span_of_impl(impl_def_id).unwrap(), + err.span_label(tcx.sess.codemap().def_span(span), + format!("first implementation here")); + err.span_label(impl_span, format!("conflicting implementation{}", overlap.self_desc .map_or(String::new(), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 07874a8cc69..5417634144b 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -352,7 +352,7 @@ impl MissingDoc { let has_doc = attrs.iter().any(|a| a.is_value_str() && a.check_name("doc")); if !has_doc { cx.span_lint(MISSING_DOCS, - sp, + cx.tcx.sess.codemap().def_span(sp), &format!("missing documentation for {}", desc)); } } @@ -914,15 +914,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // no break */ }`) shouldn't be linted unless it actually // recurs. if !reached_exit_without_self_call && !self_call_spans.is_empty() { + let sp = cx.tcx.sess.codemap().def_span(sp); let mut db = cx.struct_span_lint(UNCONDITIONAL_RECURSION, sp, "function cannot return without recurring"); + db.span_label(sp, "cannot return without recurring"); // offer some help to the programmer. for call in &self_call_spans { - db.span_note(*call, "recursive call site"); + db.span_label(*call, "recursive call site"); } - db.help("a `loop` may express intention \ - better if this is on purpose"); + db.help("a `loop` may express intention better if this is on purpose"); db.emit(); } diff --git a/src/test/ui/coherence-overlap-downstream.stderr b/src/test/ui/coherence-overlap-downstream.stderr index 8a3ef97fd55..c94ffd60d26 100644 --- a/src/test/ui/coherence-overlap-downstream.stderr +++ b/src/test/ui/coherence-overlap-downstream.stderr @@ -2,17 +2,17 @@ error[E0119]: conflicting implementations of trait `Sweet`: --> $DIR/coherence-overlap-downstream.rs:18:1 | 17 | impl Sweet for T { } - | ----------------------------- first implementation here + | ------------------------- first implementation here 18 | impl Sweet for T { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: --> $DIR/coherence-overlap-downstream.rs:24:1 | 23 | impl Foo for T where T: Bar {} - | ------------------------------------------ first implementation here + | --------------------------------------- first implementation here 24 | impl Foo for i32 {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` | = note: downstream crates may implement trait `Bar<_>` for type `i32` diff --git a/src/test/ui/coherence-overlap-issue-23516.stderr b/src/test/ui/coherence-overlap-issue-23516.stderr index 8e107e06a9e..c27e1ad7620 100644 --- a/src/test/ui/coherence-overlap-issue-23516.stderr +++ b/src/test/ui/coherence-overlap-issue-23516.stderr @@ -2,9 +2,9 @@ error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed: --> $DIR/coherence-overlap-issue-23516.rs:18:1 | 17 | impl Sweet for T { } - | ----------------------------- first implementation here + | ------------------------- first implementation here 18 | impl Sweet for Box { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` | = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` diff --git a/src/test/ui/coherence-overlap-upstream.stderr b/src/test/ui/coherence-overlap-upstream.stderr index 48961572b72..9b5b67fe9c7 100644 --- a/src/test/ui/coherence-overlap-upstream.stderr +++ b/src/test/ui/coherence-overlap-upstream.stderr @@ -2,9 +2,9 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i16`: --> $DIR/coherence-overlap-upstream.rs:22:1 | 21 | impl Foo for T where T: Remote {} - | ------------------------------------ first implementation here + | --------------------------------- first implementation here 22 | impl Foo for i16 {} - | ^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i16` + | ^^^^^^^^^^^^^^^^ conflicting implementation for `i16` | = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions diff --git a/src/test/ui/e0119/complex-impl.stderr b/src/test/ui/e0119/complex-impl.stderr index e4f8020145c..926dac3f9b1 100644 --- a/src/test/ui/e0119/complex-impl.stderr +++ b/src/test/ui/e0119/complex-impl.stderr @@ -2,7 +2,7 @@ error[E0119]: conflicting implementations of trait `complex_impl_support::Extern --> $DIR/complex-impl.rs:19:1 | 19 | impl External for (Q, R) {} //~ ERROR must be used - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `complex_impl_support`: - impl<'a, 'b, 'c, T, U, V, W> complex_impl_support::External for (T, complex_impl_support::M<'a, 'b, 'c, std::boxed::Box, V, W>) diff --git a/src/test/ui/e0119/conflict-with-std.stderr b/src/test/ui/e0119/conflict-with-std.stderr index 21f2dd05b4d..4c1f9405fb9 100644 --- a/src/test/ui/e0119/conflict-with-std.stderr +++ b/src/test/ui/e0119/conflict-with-std.stderr @@ -1,12 +1,8 @@ error[E0119]: conflicting implementations of trait `std::convert::AsRef` for type `std::boxed::Box`: --> $DIR/conflict-with-std.rs:17:1 | -17 | / impl AsRef for Box { //~ ERROR conflicting implementations -18 | | fn as_ref(&self) -> &Q { -19 | | &**self -20 | | } -21 | | } - | |_^ +17 | impl AsRef for Box { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `alloc`: - impl std::convert::AsRef for std::boxed::Box @@ -15,12 +11,8 @@ error[E0119]: conflicting implementations of trait `std::convert::AsRef` for error[E0119]: conflicting implementations of trait `std::convert::From` for type `S`: --> $DIR/conflict-with-std.rs:24:1 | -24 | / impl From for S { //~ ERROR conflicting implementations -25 | | fn from(s: S) -> S { -26 | | s -27 | | } -28 | | } - | |_^ +24 | impl From for S { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl std::convert::From for T; @@ -28,13 +20,8 @@ error[E0119]: conflicting implementations of trait `std::convert::From` for t error[E0119]: conflicting implementations of trait `std::convert::TryFrom` for type `X`: --> $DIR/conflict-with-std.rs:31:1 | -31 | / impl TryFrom for X { //~ ERROR conflicting implementations -32 | | type Error = (); -33 | | fn try_from(u: X) -> Result { -34 | | Ok(u) -35 | | } -36 | | } - | |_^ +31 | impl TryFrom for X { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl std::convert::TryFrom for T diff --git a/src/test/ui/e0119/issue-23563.stderr b/src/test/ui/e0119/issue-23563.stderr index 9dddf193063..8bbae56d843 100644 --- a/src/test/ui/e0119/issue-23563.stderr +++ b/src/test/ui/e0119/issue-23563.stderr @@ -1,10 +1,8 @@ error[E0119]: conflicting implementations of trait `a::LolFrom<&[_]>` for type `LocalType<_>`: --> $DIR/issue-23563.rs:23:1 | -23 | / impl<'a, T> LolFrom<&'a [T]> for LocalType { //~ ERROR conflicting implementations of trait -24 | | fn from(_: &'a [T]) -> LocalType { LocalType(None) } -25 | | } - | |_^ +23 | impl<'a, T> LolFrom<&'a [T]> for LocalType { //~ ERROR conflicting implementations of trait + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `issue_23563_a`: - impl a::LolFrom for U diff --git a/src/test/ui/e0119/issue-27403.stderr b/src/test/ui/e0119/issue-27403.stderr index 68d7235f6aa..4417ea9099f 100644 --- a/src/test/ui/e0119/issue-27403.stderr +++ b/src/test/ui/e0119/issue-27403.stderr @@ -1,12 +1,8 @@ error[E0119]: conflicting implementations of trait `std::convert::Into<_>` for type `GenX<_>`: --> $DIR/issue-27403.rs:15:1 | -15 | / impl Into for GenX { //~ ERROR conflicting implementations -16 | | fn into(self) -> S { -17 | | self.inner -18 | | } -19 | | } - | |_^ +15 | impl Into for GenX { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl std::convert::Into for T diff --git a/src/test/ui/e0119/issue-28981.stderr b/src/test/ui/e0119/issue-28981.stderr index aac9f7ae964..3ea1c9adc9b 100644 --- a/src/test/ui/e0119/issue-28981.stderr +++ b/src/test/ui/e0119/issue-28981.stderr @@ -2,7 +2,7 @@ error[E0119]: conflicting implementations of trait `std::ops::Deref` for type `& --> $DIR/issue-28981.rs:15:1 | 15 | impl Deref for Foo { } //~ ERROR must be used - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl<'a, T> std::ops::Deref for &'a T diff --git a/src/test/ui/e0119/so-37347311.stderr b/src/test/ui/e0119/so-37347311.stderr index 351c0e1bbb6..84fb049df35 100644 --- a/src/test/ui/e0119/so-37347311.stderr +++ b/src/test/ui/e0119/so-37347311.stderr @@ -1,12 +1,8 @@ error[E0119]: conflicting implementations of trait `std::convert::From>` for type `MyError<_>`: --> $DIR/so-37347311.rs:21:1 | -21 | / impl From for MyError { //~ ERROR conflicting implementations -22 | | fn from(error: S::Error) -> MyError { -23 | | MyError::StorageProblem(error) -24 | | } -25 | | } - | |_^ +21 | impl From for MyError { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl std::convert::From for T; diff --git a/src/test/ui/feature-gate-overlapping_marker_traits.stderr b/src/test/ui/feature-gate-overlapping_marker_traits.stderr index 9028b14fcd7..c1725a62ada 100644 --- a/src/test/ui/feature-gate-overlapping_marker_traits.stderr +++ b/src/test/ui/feature-gate-overlapping_marker_traits.stderr @@ -2,9 +2,9 @@ error[E0119]: conflicting implementations of trait `MyMarker`: --> $DIR/feature-gate-overlapping_marker_traits.rs:16:1 | 15 | impl MyMarker for T {} - | ---------------------------------- first implementation here + | ------------------------------- first implementation here 16 | impl MyMarker for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/issue-28568.stderr b/src/test/ui/issue-28568.stderr index 2b4025ac122..61717ee60ff 100644 --- a/src/test/ui/issue-28568.stderr +++ b/src/test/ui/issue-28568.stderr @@ -1,16 +1,11 @@ error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `MyStruct`: --> $DIR/issue-28568.rs:17:1 | -13 | / impl Drop for MyStruct { -14 | | fn drop(&mut self) { } -15 | | } - | |_- first implementation here -16 | -17 | / impl Drop for MyStruct { -18 | | //~^ ERROR conflicting implementations of trait -19 | | fn drop(&mut self) { } -20 | | } - | |_^ conflicting implementation for `MyStruct` +13 | impl Drop for MyStruct { + | ---------------------- first implementation here +... +17 | impl Drop for MyStruct { + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyStruct` error: aborting due to previous error diff --git a/src/test/ui/lint-unconditional-recursion.stderr b/src/test/ui/lint-unconditional-recursion.stderr index 40eaab1437f..f6f97654b57 100644 --- a/src/test/ui/lint-unconditional-recursion.stderr +++ b/src/test/ui/lint-unconditional-recursion.stderr @@ -1,239 +1,156 @@ error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:14:1 | -14 | / fn foo() { //~ ERROR function cannot return without recurring -15 | | foo(); -16 | | } - | |_^ +14 | fn foo() { //~ ERROR function cannot return without recurring + | ^^^^^^^^ cannot return without recurring +15 | foo(); + | ----- recursive call site | note: lint level defined here --> $DIR/lint-unconditional-recursion.rs:11:9 | 11 | #![deny(unconditional_recursion)] | ^^^^^^^^^^^^^^^^^^^^^^^ -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:15:5 - | -15 | foo(); - | ^^^^^ = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:24:1 | -24 | / fn baz() { //~ ERROR function cannot return without recurring -25 | | if true { -26 | | baz() -27 | | } else { -28 | | baz() -29 | | } -30 | | } - | |_^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:26:9 - | +24 | fn baz() { //~ ERROR function cannot return without recurring + | ^^^^^^^^ cannot return without recurring +25 | if true { 26 | baz() - | ^^^^^ -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:28:9 - | + | ----- recursive call site +27 | } else { 28 | baz() - | ^^^^^ + | ----- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:36:1 | -36 | / fn quz() -> bool { //~ ERROR function cannot return without recurring -37 | | if true { -38 | | while quz() {} -39 | | true -... | -42 | | } -43 | | } - | |_^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:38:15 - | +36 | fn quz() -> bool { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^^^^ cannot return without recurring +37 | if true { 38 | while quz() {} - | ^^^^^ -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:41:16 - | + | ----- recursive call site +... 41 | loop { quz(); } - | ^^^^^ + | ----- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:47:5 | -47 | / fn bar(&self) { //~ ERROR function cannot return without recurring -48 | | self.bar() -49 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:48:9 - | +47 | fn bar(&self) { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^ cannot return without recurring 48 | self.bar() - | ^^^^^^^^^^ + | ---------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:53:5 | -53 | / fn bar(&self) { //~ ERROR function cannot return without recurring -54 | | loop { -55 | | self.bar() -56 | | } -57 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:55:13 - | +53 | fn bar(&self) { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^ cannot return without recurring +54 | loop { 55 | self.bar() - | ^^^^^^^^^^ + | ---------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:62:5 | -62 | / fn bar(&self) { //~ ERROR function cannot return without recurring -63 | | 0.bar() -64 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:63:9 - | +62 | fn bar(&self) { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^ cannot return without recurring 63 | 0.bar() - | ^^^^^^^ + | ------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:75:5 | -75 | / fn bar(&self) { //~ ERROR function cannot return without recurring -76 | | Foo2::bar(self) -77 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:76:9 - | +75 | fn bar(&self) { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^ cannot return without recurring 76 | Foo2::bar(self) - | ^^^^^^^^^^^^^^^ + | --------------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:81:5 | -81 | / fn bar(&self) { //~ ERROR function cannot return without recurring -82 | | loop { -83 | | Foo2::bar(self) -84 | | } -85 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:83:13 - | +81 | fn bar(&self) { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^ cannot return without recurring +82 | loop { 83 | Foo2::bar(self) - | ^^^^^^^^^^^^^^^ + | --------------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:91:5 | -91 | / fn qux(&self) { //~ ERROR function cannot return without recurring -92 | | self.qux(); -93 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:92:9 - | +91 | fn qux(&self) { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^ cannot return without recurring 92 | self.qux(); - | ^^^^^^^^^^ + | ---------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:96:5 | -96 | / fn as_ref(&self) -> &Self { //~ ERROR function cannot return without recurring -97 | | Baz::as_ref(self) -98 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:97:9 - | +96 | fn as_ref(&self) -> &Self { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring 97 | Baz::as_ref(self) - | ^^^^^^^^^^^^^^^^^ + | ----------------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:103:5 | -103 | / fn default() -> Baz { //~ ERROR function cannot return without recurring -104 | | let x = Default::default(); -105 | | x -106 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:104:17 - | +103 | fn default() -> Baz { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^^^^^^^ cannot return without recurring 104 | let x = Default::default(); - | ^^^^^^^^^^^^^^^^^^ + | ------------------ recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:112:5 | -112 | / fn deref(&self) -> &() { //~ ERROR function cannot return without recurring -113 | | &**self -114 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:113:10 - | +112 | fn deref(&self) -> &() { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring 113 | &**self - | ^^^^^^ + | ------ recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:119:5 | -119 | / fn index(&self, x: usize) -> &Baz { //~ ERROR function cannot return without recurring -120 | | &self[x] -121 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:120:10 - | +119 | fn index(&self, x: usize) -> &Baz { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring 120 | &self[x] - | ^^^^^^^ + | ------- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recurring --> $DIR/lint-unconditional-recursion.rs:128:5 | -128 | / fn deref(&self) -> &Baz { //~ ERROR function cannot return without recurring -129 | | self.as_ref() -130 | | } - | |_____^ - | -note: recursive call site - --> $DIR/lint-unconditional-recursion.rs:129:9 - | +128 | fn deref(&self) -> &Baz { //~ ERROR function cannot return without recurring + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring 129 | self.as_ref() - | ^^^^ + | ---- recursive call site + | = help: a `loop` may express intention better if this is on purpose error: aborting due to 14 previous errors diff --git a/src/test/ui/specialization-feature-gate-overlap.stderr b/src/test/ui/specialization-feature-gate-overlap.stderr index 7fe2891c908..6ff261c696d 100644 --- a/src/test/ui/specialization-feature-gate-overlap.stderr +++ b/src/test/ui/specialization-feature-gate-overlap.stderr @@ -1,15 +1,11 @@ error[E0119]: conflicting implementations of trait `Foo` for type `u8`: --> $DIR/specialization-feature-gate-overlap.rs:23:1 | -19 | / impl Foo for T { -20 | | fn foo(&self) {} -21 | | } - | |_- first implementation here -22 | -23 | / impl Foo for u8 { //~ ERROR E0119 -24 | | fn foo(&self) {} -25 | | } - | |_^ conflicting implementation for `u8` +19 | impl Foo for T { + | ----------------- first implementation here +... +23 | impl Foo for u8 { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^ conflicting implementation for `u8` error: aborting due to previous error From 0df39bfff7840800454d6704fe4eee646d1f0ec7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 17 Dec 2017 14:08:09 +0100 Subject: [PATCH 06/12] Fix ?Sized where bound not being displayed at the correct place --- src/librustdoc/clean/inline.rs | 3 +-- src/librustdoc/clean/mod.rs | 26 +++++++++++++++++++++++--- src/librustdoc/clean/simplify.rs | 1 + src/test/rustdoc/where-sized.rs | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc/where-sized.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 60592cc186e..914365b003e 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -448,8 +448,7 @@ fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static { /// /// The inverse of this filtering logic can be found in the `Clean` /// implementation for `AssociatedType` -fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) - -> clean::Generics { +fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean::Generics { for pred in &mut g.where_predicates { match *pred { clean::WherePredicate::BoundPredicate { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 91908de98a6..fe7dfc4477f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1190,16 +1190,36 @@ impl<'tcx> Clean for ty::ProjectionTy<'tcx> { pub struct Generics { pub lifetimes: Vec, pub type_params: Vec, - pub where_predicates: Vec + pub where_predicates: Vec, } impl Clean for hir::Generics { fn clean(&self, cx: &DocContext) -> Generics { - Generics { + let mut g = Generics { lifetimes: self.lifetimes.clean(cx), type_params: self.ty_params.clean(cx), where_predicates: self.where_clause.predicates.clean(cx) + }; + + // Some duplicates are generated for ?Sized bounds between type params and where + // predicates. The point in here is to move the bounds definitions from type params + // to where predicates when such cases occur. + for where_pred in &mut g.where_predicates { + match *where_pred { + WherePredicate::BoundPredicate { ty: Generic(ref name), ref mut bounds } => { + if bounds.is_empty() { + for type_params in &mut g.type_params { + if &type_params.name == name { + mem::swap(bounds, &mut type_params.bounds); + break + } + } + } + } + _ => continue, + } } + g } } @@ -1225,7 +1245,7 @@ impl<'a, 'tcx> Clean for (&'a ty::Generics, let mut where_predicates = preds.predicates.to_vec().clean(cx); // Type parameters and have a Sized bound by default unless removed with - // ?Sized. Scan through the predicates and mark any type parameter with + // ?Sized. Scan through the predicates and mark any type parameter with // a Sized bound, removing the bounds as we find them. // // Note that associated types also have a sized bound by default, but we diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index dd36b28bb39..63ebb16e5e0 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -38,6 +38,7 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec) -> Vec { let mut lifetimes = Vec::new(); let mut equalities = Vec::new(); let mut tybounds = Vec::new(); + for clause in clauses { match clause { WP::BoundPredicate { ty, bounds } => { diff --git a/src/test/rustdoc/where-sized.rs b/src/test/rustdoc/where-sized.rs new file mode 100644 index 00000000000..c175c839c0f --- /dev/null +++ b/src/test/rustdoc/where-sized.rs @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +// @has foo/fn.foo.html +// @has - '//*[@class="rust fn"]' 'pub fn foo(_: &X)' +// @has - '//*[@class="rust fn"]' 'where X: ?Sized,' +pub fn foo(_: &X) where X: ?Sized {} From 749d8a880f4502f2d8104bfb1faf15c38fd72d53 Mon Sep 17 00:00:00 2001 From: kennytm Date: Mon, 18 Dec 2017 22:52:24 +0800 Subject: [PATCH 07/12] Fix the wrong subtraction in align_offset intrinsic. --- src/librustc_trans/intrinsic.rs | 4 ++-- src/test/run-pass/align-offset-sign.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/align-offset-sign.rs diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index f1cb8b224b3..3cd60e7f1bc 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -406,8 +406,8 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, let zero = C_null(bcx.ccx.isize_ty()); // `offset == 0` let is_zero = bcx.icmp(llvm::IntPredicate::IntEQ, offset, zero); - // `if offset == 0 { 0 } else { offset - align }` - bcx.select(is_zero, zero, bcx.sub(offset, align)) + // `if offset == 0 { 0 } else { align - offset }` + bcx.select(is_zero, zero, bcx.sub(align, offset)) } name if name.starts_with("simd_") => { match generic_simd_intrinsic(bcx, name, diff --git a/src/test/run-pass/align-offset-sign.rs b/src/test/run-pass/align-offset-sign.rs new file mode 100644 index 00000000000..aaa0419d061 --- /dev/null +++ b/src/test/run-pass/align-offset-sign.rs @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(align_offset)] + +fn main() { + let x = 1 as *const u8; + assert_eq!(x.align_offset(8), 7); +} From c08dab841d5fc45fe683291cd8146ad70f2283e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Dec 2017 22:33:56 -0800 Subject: [PATCH 08/12] Point at def span in "impl has stricter requirements" diagnostic --- src/librustc/traits/error_reporting.rs | 11 ++++------- .../ui/compare-method/proj-outlives-region.stderr | 2 +- src/test/ui/compare-method/region-extra-2.stderr | 11 ++++------- src/test/ui/compare-method/region-extra.stderr | 2 +- src/test/ui/compare-method/region-unrelated.stderr | 2 +- .../trait-bound-on-type-parameter.stderr | 2 +- .../compare-method/traits-misc-mismatch-1.stderr | 14 +++++++------- .../compare-method/traits-misc-mismatch-2.stderr | 11 ++++------- 8 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 635921134be..ce1cbe5c3e7 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -484,19 +484,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { -> DiagnosticBuilder<'tcx> { let msg = "impl has stricter requirements than trait"; - let mut err = struct_span_err!(self.tcx.sess, - error_span, - E0276, - "{}", msg); + let sp = self.tcx.sess.codemap().def_span(error_span); + + let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg); if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) { let span = self.tcx.sess.codemap().def_span(trait_item_span); err.span_label(span, format!("definition of `{}` from trait", item_name)); } - err.span_label( - error_span, - format!("impl has extra requirement {}", requirement)); + err.span_label(sp, format!("impl has extra requirement {}", requirement)); err } diff --git a/src/test/ui/compare-method/proj-outlives-region.stderr b/src/test/ui/compare-method/proj-outlives-region.stderr index f871f034a92..e6e93d14b3c 100644 --- a/src/test/ui/compare-method/proj-outlives-region.stderr +++ b/src/test/ui/compare-method/proj-outlives-region.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | --------------------- definition of `foo` from trait ... 19 | fn foo() where U: 'a { } //~ ERROR E0276 - | ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a` + | ^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a` error: aborting due to previous error diff --git a/src/test/ui/compare-method/region-extra-2.stderr b/src/test/ui/compare-method/region-extra-2.stderr index af974d50183..2b8a268fdcc 100644 --- a/src/test/ui/compare-method/region-extra-2.stderr +++ b/src/test/ui/compare-method/region-extra-2.stderr @@ -1,14 +1,11 @@ error[E0276]: impl has stricter requirements than trait --> $DIR/region-extra-2.rs:19:5 | -15 | fn renew<'b: 'a>(self) -> &'b mut [T]; - | -------------------------------------- definition of `renew` from trait +15 | fn renew<'b: 'a>(self) -> &'b mut [T]; + | -------------------------------------- definition of `renew` from trait ... -19 | / fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b { -20 | | //~^ ERROR E0276 -21 | | &mut self[..] -22 | | } - | |_____^ impl has extra requirement `'a: 'b` +19 | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/compare-method/region-extra.stderr b/src/test/ui/compare-method/region-extra.stderr index d46376b4a42..d89b3a921b9 100644 --- a/src/test/ui/compare-method/region-extra.stderr +++ b/src/test/ui/compare-method/region-extra.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | --------- definition of `foo` from trait ... 19 | fn foo() where 'a: 'b { } //~ ERROR impl has stricter - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b` + | ^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/compare-method/region-unrelated.stderr b/src/test/ui/compare-method/region-unrelated.stderr index 1df83c7fb0c..156143cd54c 100644 --- a/src/test/ui/compare-method/region-unrelated.stderr +++ b/src/test/ui/compare-method/region-unrelated.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | --------------------- definition of `foo` from trait ... 19 | fn foo() where V: 'a { } - | ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a` + | ^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a` error: aborting due to previous error diff --git a/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr b/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr index 7112a00c7b7..e3a1eb9ee66 100644 --- a/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr +++ b/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | ---------------------------- definition of `b` from trait ... 25 | fn b(&self, _x: F) -> F { panic!() } //~ ERROR E0276 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: std::marker::Sync` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: std::marker::Sync` error: aborting due to previous error diff --git a/src/test/ui/compare-method/traits-misc-mismatch-1.stderr b/src/test/ui/compare-method/traits-misc-mismatch-1.stderr index f221ebe3302..ba5284eb653 100644 --- a/src/test/ui/compare-method/traits-misc-mismatch-1.stderr +++ b/src/test/ui/compare-method/traits-misc-mismatch-1.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | -------------------------------- definition of `test_error1_fn` from trait ... 36 | fn test_error1_fn(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Ord` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Ord` error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-1.rs:40:5 @@ -14,7 +14,7 @@ error[E0276]: impl has stricter requirements than trait | -------------------------------------- definition of `test_error2_fn` from trait ... 40 | fn test_error2_fn(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B` error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-1.rs:44:5 @@ -23,7 +23,7 @@ error[E0276]: impl has stricter requirements than trait | -------------------------------------- definition of `test_error3_fn` from trait ... 44 | fn test_error3_fn(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B` error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-1.rs:54:5 @@ -32,7 +32,7 @@ error[E0276]: impl has stricter requirements than trait | ------------------------------- definition of `test_error5_fn` from trait ... 54 | fn test_error5_fn(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B` error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-1.rs:60:5 @@ -41,7 +41,7 @@ error[E0276]: impl has stricter requirements than trait | ------------------------------- definition of `test_error7_fn` from trait ... 60 | fn test_error7_fn(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Eq` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Eq` error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-1.rs:63:5 @@ -50,7 +50,7 @@ error[E0276]: impl has stricter requirements than trait | ------------------------------- definition of `test_error8_fn` from trait ... 63 | fn test_error8_fn(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: C` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: C` error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-1.rs:76:5 @@ -59,7 +59,7 @@ error[E0276]: impl has stricter requirements than trait | ---------------------------------- definition of `method` from trait ... 76 | fn method>(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter` error: aborting due to 7 previous errors diff --git a/src/test/ui/compare-method/traits-misc-mismatch-2.stderr b/src/test/ui/compare-method/traits-misc-mismatch-2.stderr index 622e144c53a..983d87d5b88 100644 --- a/src/test/ui/compare-method/traits-misc-mismatch-2.stderr +++ b/src/test/ui/compare-method/traits-misc-mismatch-2.stderr @@ -1,14 +1,11 @@ error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-2.rs:23:5 | -19 | fn zip>(self, other: U) -> ZipIterator; - | ------------------------------------------------------------------ definition of `zip` from trait +19 | fn zip>(self, other: U) -> ZipIterator; + | ------------------------------------------------------------------ definition of `zip` from trait ... -23 | / fn zip>(self, other: U) -> ZipIterator { -24 | | //~^ ERROR E0276 -25 | | ZipIterator{a: self, b: other} -26 | | } - | |_____^ impl has extra requirement `U: Iterator` +23 | fn zip>(self, other: U) -> ZipIterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: Iterator` error: aborting due to previous error From 0555d256dd395ff65aa4435d26de36806edb2729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Dec 2017 22:22:24 -0800 Subject: [PATCH 09/12] Rework expected closure error * point at def span * add label to primary span * use `span_label`s instead of `span_note`s --- src/librustc/traits/error_reporting.rs | 10 +++++++--- .../closure_context/issue-26046-fn-mut.stderr | 19 ++++++------------- .../issue-26046-fn-once.stderr | 19 ++++++------------- ...-infer-fn-once-move-from-projection.stderr | 11 ++++------- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 635921134be..f249a6131ae 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -647,7 +647,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => { let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap(); - let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap(); + let closure_span = self.tcx.sess.codemap() + .def_span(self.tcx.hir.span_if_local(closure_def_id).unwrap()); let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap(); let mut err = struct_span_err!( self.tcx.sess, closure_span, E0525, @@ -656,6 +657,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { kind, found_kind); + err.span_label( + closure_span, + format!("this closure implements `{}`, not `{}`", found_kind, kind)); err.span_label( obligation.cause.span, format!("the requirement to implement `{}` derives from here", kind)); @@ -667,12 +671,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let closure_hir_id = self.tcx.hir.node_to_hir_id(node_id); match (found_kind, tables.closure_kind_origins().get(closure_hir_id)) { (ty::ClosureKind::FnOnce, Some((span, name))) => { - err.span_note(*span, &format!( + err.span_label(*span, format!( "closure is `FnOnce` because it moves the \ variable `{}` out of its environment", name)); }, (ty::ClosureKind::FnMut, Some((span, name))) => { - err.span_note(*span, &format!( + err.span_label(*span, format!( "closure is `FnMut` because it mutates the \ variable `{}` here", name)); }, diff --git a/src/test/ui/closure_context/issue-26046-fn-mut.stderr b/src/test/ui/closure_context/issue-26046-fn-mut.stderr index 82c83da4dae..77ce1176b5c 100644 --- a/src/test/ui/closure_context/issue-26046-fn-mut.stderr +++ b/src/test/ui/closure_context/issue-26046-fn-mut.stderr @@ -1,20 +1,13 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut` --> $DIR/issue-26046-fn-mut.rs:14:19 | -14 | let closure = || { //~ ERROR expected a closure that - | ___________________^ -15 | | num += 1; -16 | | }; - | |_____^ -17 | -18 | Box::new(closure) - | ----------------- the requirement to implement `Fn` derives from here - | -note: closure is `FnMut` because it mutates the variable `num` here - --> $DIR/issue-26046-fn-mut.rs:15:9 - | +14 | let closure = || { //~ ERROR expected a closure that + | ^^ this closure implements `FnMut`, not `Fn` 15 | num += 1; - | ^^^ + | --- closure is `FnMut` because it mutates the variable `num` here +... +18 | Box::new(closure) + | ----------------- the requirement to implement `Fn` derives from here error: aborting due to previous error diff --git a/src/test/ui/closure_context/issue-26046-fn-once.stderr b/src/test/ui/closure_context/issue-26046-fn-once.stderr index 0bc84872dde..4eed4461eba 100644 --- a/src/test/ui/closure_context/issue-26046-fn-once.stderr +++ b/src/test/ui/closure_context/issue-26046-fn-once.stderr @@ -1,20 +1,13 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/issue-26046-fn-once.rs:14:19 | -14 | let closure = move || { //~ ERROR expected a closure - | ___________________^ -15 | | vec -16 | | }; - | |_____^ -17 | -18 | Box::new(closure) - | ----------------- the requirement to implement `Fn` derives from here - | -note: closure is `FnOnce` because it moves the variable `vec` out of its environment - --> $DIR/issue-26046-fn-once.rs:15:9 - | +14 | let closure = move || { //~ ERROR expected a closure + | ^^^^^^^ this closure implements `FnOnce`, not `Fn` 15 | vec - | ^^^ + | --- closure is `FnOnce` because it moves the variable `vec` out of its environment +... +18 | Box::new(closure) + | ----------------- the requirement to implement `Fn` derives from here error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr b/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr index d3d9ce2b34a..2c16c5b619a 100644 --- a/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr +++ b/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr @@ -2,15 +2,12 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closur --> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:24:13 | 24 | let c = || drop(y.0); //~ ERROR expected a closure that implements the `Fn` trait - | ^^^^^^^^^^^^ + | ^^^^^^^^-^^^ + | | | + | | closure is `FnOnce` because it moves the variable `y` out of its environment + | this closure implements `FnOnce`, not `Fn` 25 | foo(c); | --- the requirement to implement `Fn` derives from here - | -note: closure is `FnOnce` because it moves the variable `y` out of its environment - --> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:24:21 - | -24 | let c = || drop(y.0); //~ ERROR expected a closure that implements the `Fn` trait - | ^ error: aborting due to previous error From e1dc7ac33ce2934d6053aa0e23a1ad2c410391ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Dec 2017 23:48:59 -0800 Subject: [PATCH 10/12] Tweak "unecessary unsafe block" error spans --- src/librustc_mir/transform/check_unsafety.rs | 11 +-- ...45107-unnecessary-unsafe-in-closure.stderr | 67 ++++---------- src/test/ui/span/lint-unused-unsafe.stderr | 87 +++++-------------- 3 files changed, 43 insertions(+), 122 deletions(-) diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 7833f4bbac7..524fa5cd433 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -388,12 +388,13 @@ fn is_enclosed(tcx: TyCtxt, } fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet, id: ast::NodeId) { - let span = tcx.hir.span(id); - let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, "unnecessary `unsafe` block"); - db.span_label(span, "unnecessary `unsafe` block"); + let span = tcx.sess.codemap().def_span(tcx.hir.span(id)); + let msg = "unnecessary `unsafe` block"; + let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg); + db.span_label(span, msg); if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) { - db.span_note(tcx.hir.span(id), - &format!("because it's nested under this `unsafe` {}", kind)); + db.span_label(tcx.sess.codemap().def_span(tcx.hir.span(id)), + format!("because it's nested under this `unsafe` {}", kind)); } db.emit(); } diff --git a/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr b/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr index abd875c4808..8c34cc4b73c 100644 --- a/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr +++ b/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr @@ -1,72 +1,35 @@ error: unnecessary `unsafe` block --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:17:13 | -17 | / unsafe { //~ ERROR unnecessary `unsafe` -18 | | v.set_len(24); -19 | | |w: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` -20 | | w.set_len(32); -21 | | } }; -22 | | } - | |_____________^ unnecessary `unsafe` block +15 | unsafe { + | ------ because it's nested under this `unsafe` block +16 | let f = |v: &mut Vec<_>| { +17 | unsafe { //~ ERROR unnecessary `unsafe` + | ^^^^^^ unnecessary `unsafe` block | note: lint level defined here --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:11:8 | 11 | #[deny(unused_unsafe)] | ^^^^^^^^^^^^^ -note: because it's nested under this `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:15:5 - | -15 | / unsafe { -16 | | let f = |v: &mut Vec<_>| { -17 | | unsafe { //~ ERROR unnecessary `unsafe` -18 | | v.set_len(24); -... | -29 | | f(&mut v); -30 | | } - | |_____^ error: unnecessary `unsafe` block --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:19:38 | -19 | |w: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` - | ______________________________________^ -20 | | w.set_len(32); -21 | | } }; - | |_________________^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:15:5 - | -15 | / unsafe { -16 | | let f = |v: &mut Vec<_>| { -17 | | unsafe { //~ ERROR unnecessary `unsafe` -18 | | v.set_len(24); -... | -29 | | f(&mut v); -30 | | } - | |_____^ +15 | unsafe { + | ------ because it's nested under this `unsafe` block +... +19 | |w: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` + | ^^^^^^ unnecessary `unsafe` block error: unnecessary `unsafe` block --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:23:34 | -23 | |x: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` - | __________________________________^ -24 | | x.set_len(40); -25 | | } }; - | |_____________^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:15:5 - | -15 | / unsafe { -16 | | let f = |v: &mut Vec<_>| { -17 | | unsafe { //~ ERROR unnecessary `unsafe` -18 | | v.set_len(24); -... | -29 | | f(&mut v); -30 | | } - | |_____^ +15 | unsafe { + | ------ because it's nested under this `unsafe` block +... +23 | |x: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` + | ^^^^^^ unnecessary `unsafe` block error: aborting due to 3 previous errors diff --git a/src/test/ui/span/lint-unused-unsafe.stderr b/src/test/ui/span/lint-unused-unsafe.stderr index f4998e08907..8a8b104098e 100644 --- a/src/test/ui/span/lint-unused-unsafe.stderr +++ b/src/test/ui/span/lint-unused-unsafe.stderr @@ -2,7 +2,7 @@ error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:26:13 | 26 | fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^ unnecessary `unsafe` block + | ^^^^^^ unnecessary `unsafe` block | note: lint level defined here --> $DIR/lint-unused-unsafe.rs:14:9 @@ -14,97 +14,54 @@ error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:27:13 | 27 | fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^^^^^^^^^ unnecessary `unsafe` block + | ^^^^^^ unnecessary `unsafe` block error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:28:20 | 28 | unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` fn - --> $DIR/lint-unused-unsafe.rs:28:1 - | -28 | unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ---------------- ^^^^^^ unnecessary `unsafe` block + | | + | because it's nested under this `unsafe` fn error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:29:13 | 29 | fn bad4() { unsafe { callback(||{}) } } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unnecessary `unsafe` block + | ^^^^^^ unnecessary `unsafe` block error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:30:20 | 30 | unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^^^^^^^^^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` fn - --> $DIR/lint-unused-unsafe.rs:30:1 - | -30 | unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ---------------- ^^^^^^ unnecessary `unsafe` block + | | + | because it's nested under this `unsafe` fn error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:33:9 | -33 | / unsafe { //~ ERROR: unnecessary `unsafe` block -34 | | unsf() -35 | | } - | |_________^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` block - --> $DIR/lint-unused-unsafe.rs:32:5 - | -32 | / unsafe { // don't put the warning here -33 | | unsafe { //~ ERROR: unnecessary `unsafe` block -34 | | unsf() -35 | | } -36 | | } - | |_____^ +32 | unsafe { // don't put the warning here + | ------ because it's nested under this `unsafe` block +33 | unsafe { //~ ERROR: unnecessary `unsafe` block + | ^^^^^^ unnecessary `unsafe` block error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:39:5 | -39 | / unsafe { //~ ERROR: unnecessary `unsafe` block -40 | | unsafe { //~ ERROR: unnecessary `unsafe` block -41 | | unsf() -42 | | } -43 | | } - | |_____^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` fn - --> $DIR/lint-unused-unsafe.rs:38:1 - | -38 | / unsafe fn bad7() { -39 | | unsafe { //~ ERROR: unnecessary `unsafe` block -40 | | unsafe { //~ ERROR: unnecessary `unsafe` block -41 | | unsf() -42 | | } -43 | | } -44 | | } - | |_^ +38 | unsafe fn bad7() { + | ---------------- because it's nested under this `unsafe` fn +39 | unsafe { //~ ERROR: unnecessary `unsafe` block + | ^^^^^^ unnecessary `unsafe` block error: unnecessary `unsafe` block --> $DIR/lint-unused-unsafe.rs:40:9 | -40 | / unsafe { //~ ERROR: unnecessary `unsafe` block -41 | | unsf() -42 | | } - | |_________^ unnecessary `unsafe` block - | -note: because it's nested under this `unsafe` fn - --> $DIR/lint-unused-unsafe.rs:38:1 - | -38 | / unsafe fn bad7() { -39 | | unsafe { //~ ERROR: unnecessary `unsafe` block -40 | | unsafe { //~ ERROR: unnecessary `unsafe` block -41 | | unsf() -42 | | } -43 | | } -44 | | } - | |_^ +38 | unsafe fn bad7() { + | ---------------- because it's nested under this `unsafe` fn +39 | unsafe { //~ ERROR: unnecessary `unsafe` block +40 | unsafe { //~ ERROR: unnecessary `unsafe` block + | ^^^^^^ unnecessary `unsafe` block error: aborting due to 8 previous errors From cf18b1f22ae67b8029005f9fd15d7b19d485a767 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 18 Dec 2017 21:15:46 +0100 Subject: [PATCH 11/12] Fix dynamic crates listing in doc sidebar --- src/librustdoc/html/static/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 81971157b84..f6fc6e88c6b 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1447,7 +1447,7 @@ // Draw a convenient sidebar of known crates if we have a listing if (rootPath === '../') { - var sidebar = document.getElementsByClassName('sidebar')[0]; + var sidebar = document.getElementsByClassName('sidebar-elems')[0]; var div = document.createElement('div'); div.className = 'block crate'; div.innerHTML = '

Crates

'; From 3d4c5050781333ae3496194a92105921f7f567bd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 18 Dec 2017 21:27:19 +0100 Subject: [PATCH 12/12] Improve search display on mobile --- src/librustdoc/html/static/rustdoc.css | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 308182e6a0e..e620abea277 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1011,6 +1011,26 @@ h4 > .important-traits { left: -22px; top: 24px; } + + #titles > div > div.count { + float: left; + width: 100%; + } + + #titles { + height: 50px; + } +} + + +@media (max-width: 416px) { + #titles { + height: 73px; + } + + #titles > div { + height: 73px; + } } .modal {