Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor fmt::Display and fmt::Debug impls in ppaux #44888

Merged
merged 3 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,757 changes: 989 additions & 768 deletions src/librustc/util/ppaux.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/test/compile-fail/hygiene/impl_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod foo {
}

pub macro m() {
let _: () = S.f(); //~ ERROR type `fn(&foo::S) {foo::S::f}` is private
let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-12997-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#[bench]
fn bar(x: isize) { }
//~^ ERROR mismatched types
//~| expected type `fn(&mut __test::test::Bencher)`
//~| expected type `for<'r> fn(&'r mut __test::test::Bencher)`
//~| found type `fn(isize) {bar}`
//~| expected mutable reference, found isize
2 changes: 1 addition & 1 deletion src/test/compile-fail/private-inferred-type-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// error-pattern:type `fn() {<u8 as ext::PrivTrait>::method}` is private
// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is pr
// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv
// error-pattern:type `fn(&ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private
// error-pattern:type `for<'r> fn(&'r ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private

#![feature(decl_macro)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/private-inferred-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod m {
PubTupleStruct;
//~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is privat
Pub(0u8).priv_method();
//~^ ERROR type `fn(&m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private
//~^ ERROR type `for<'r> fn(&'r m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private
}

trait Trait {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/regions-fn-subtyping-return-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ fn supply_G() {
want_G(bar);
want_G(baz);
//~^ ERROR mismatched types
//~| expected type `fn(&'cx S) -> &'static S`
//~| found type `fn(&S) -> &S {baz}`
//~| expected type `for<'cx> fn(&'cx S) -> &'static S`
//~| found type `for<'r> fn(&'r S) -> &'r S {baz}`
//~| expected concrete lifetime, found bound lifetime parameter 'cx
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/validate_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn main() {
// START rustc.node50.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3);
// _3 = _2;
// StorageLive(_4);
Expand Down
8 changes: 4 additions & 4 deletions src/test/mir-opt/validate_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ fn main() {
// START rustc.node22.EraseRegions.after.mir
// fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]);
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]);
// StorageLive(_3);
// _3 = _2;
// (*_3) = const 23i32;
Expand All @@ -74,8 +74,8 @@ fn main() {
// START rustc.node60.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3);
// _0 = const write_42(_4) -> bb1;
// }
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/validate_5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() {
// START rustc.node46.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3);
// _3 = _2;
// StorageLive(_4);
Expand Down
50 changes: 25 additions & 25 deletions src/test/pretty/issue-4264.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@


((::fmt::format as
fn(std::fmt::Arguments<'_>) -> std::string::String {std::fmt::format})(((<::std::fmt::Arguments>::new_v1
as
fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments<'_>::new_v1})((&([("test"
as
&'static str)]
as
[&str; 1])
as
&[&str; 1]),
(&(match (()
as
())
{
()
=>
([]
as
[std::fmt::ArgumentV1<'_>; 0]),
}
as
[std::fmt::ArgumentV1<'_>; 0])
as
&[std::fmt::ArgumentV1<'_>; 0]))
as
std::fmt::Arguments<'_>))
for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<::std::fmt::Arguments>::new_v1
as
fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments<'_>::new_v1})((&([("test"
as
&'static str)]
as
[&str; 1])
as
&[&str; 1]),
(&(match (()
as
())
{
()
=>
([]
as
[std::fmt::ArgumentV1<'_>; 0]),
}
as
[std::fmt::ArgumentV1<'_>; 0])
as
&[std::fmt::ArgumentV1<'_>; 0]))
as
std::fmt::Arguments<'_>))
as std::string::String);
} as ())
pub type Foo = [i32; (3 as usize)];
Expand Down
40 changes: 40 additions & 0 deletions src/test/ui/anonymous-higher-ranked-lifetime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main() {
f1(|_: (), _: ()| {});
f2(|_: (), _: ()| {});
f3(|_: (), _: ()| {});
f4(|_: (), _: ()| {});
f5(|_: (), _: ()| {});
g1(|_: (), _: ()| {});
g2(|_: (), _: ()| {});
g3(|_: (), _: ()| {});
g4(|_: (), _: ()| {});
h1(|_: (), _: (), _: (), _: ()| {});
h2(|_: (), _: (), _: (), _: ()| {});
}

// Basic
fn f1<F>(_: F) where F: Fn(&(), &()) {}
fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}

// Nested
fn g1<F>(_: F) where F: Fn(&(), Box<Fn(&())>) {}
fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<Fn(&())>) {}
fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}

// Mixed
fn h1<F>(_: F) where F: Fn(&(), Box<Fn(&())>, &(), fn(&(), &())) {}
fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &())) {}
Loading