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

Implement RFC 2302: tuple_struct_self_ctor #53751

Merged
merged 2 commits into from
Sep 14, 2018

Conversation

F001
Copy link
Contributor

@F001 F001 commented Aug 28, 2018

Tracking issue: #51994

@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 28, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this! More tests would be nice :)

let Self(v) = self;
println!("{}", v);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include tests for:

  • Self as a function passed somewhere
  • Self as a unit struct value wrt. pattern matching and construction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases added.

println!("{}", v);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include a test where all of the above works through type aliases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type alias is not working. At present, even this case can not work:

struct S(i32);
type T = S;

fn main() {
    let x = T(1);
}

I think type alias is unrelated to this feature. We should solve this in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test would rather be (and is part of the RFC):

struct S(i32);

type T = S;

impl T {
    fn stuff() {
        let Self(x) = match Self(0) { Self(x) => Self(x) };
        let opt: Option<Self> = Some(0).map(Self);
    }
}

For named field structs, this already works today:

pub struct S { f: i32 }

pub type T = S;

impl T {
    pub fn stuff() {
        let Self { f: _x } = match (Self { f: 0 }) { Self { f } => Self { f } };
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, test case is added.

} else {
Def::StructCtor(variant_id, CtorKind::Const)
};
self.tuple_structs.insert(def_id, variant_def);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructors are already to this table in build_reduced_graph.rs, so this seems to be duplicate work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -1434,6 +1434,9 @@ pub struct Resolver<'a, 'b: 'a> {
/// it's not used during normal resolution, only for better error reporting.
struct_constructors: DefIdMap<(Def, ty::Visibility)>,

/// Map from tuple struct's DefId to VariantData's Def
tuple_structs: DefIdMap<Def>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With https://github.com/rust-lang/rust/pull/53751/files?w=1#r214416891 in mind, this field looks like an exact copy of struct_constructors field above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It is removed.

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs tests that it works through type aliases such as with:

struct S(i32);

type T = S;

impl T {
    fn stuff() {
        let Self(x) = match Self(0) { Self(x) => Self(x) };
        let opt: Option<Self> = Some(0).map(Self);
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Test case is added, see ST6.

@@ -1755,6 +1758,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ExprKind::Async(..) => {
gate_feature_post!(&self, async_await, e.span, "async blocks are unstable");
}
ast::ExprKind::Call(ref callee, _) => {
if let ast::ExprKind::Path(_, ref p) = callee.node {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit struct constructors are not feature gated.

A better place to place the feature gate is probably lowering.rs.
Every time we construct hir::Path { with a single Self segment and Def::StructCtor definition we can report a feature error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

fn with_tuple_struct_self_ctor_rib<F>(&mut self, self_ty: &Ty, f: F)
where F: FnOnce(&mut Resolver)
{
let variant_def = if self.session.features_untracked().tuple_struct_self_ctor {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature gates very rarely enable features, they usually report an error when some feature is already used, so this condition is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

{
let variant_def = if self.session.features_untracked().tuple_struct_self_ctor {
let base_def = self.def_map.get(&self_ty.id).map(|r| r.base_def());
if let Some(Def::Struct(ref def_id)) = base_def {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work for type aliases in impl.

struct S(u8);
type Alias = S;
impl Alias { ... Self(10) ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Test case is added.

@@ -2521,8 +2570,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
ValueNS,
impl_item.span,
|n, s| MethodNotMemberOfTrait(n, s));

visit::walk_impl_item(this, impl_item);
this.with_tuple_struct_self_ctor_rib(self_type, |this| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, Self value "rib" should be added in all cases when Self type rib is added, and not only for methods in impls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@petrochenkov
Copy link
Contributor

I'm pretty sure this implementation also loses generic arguments from impl.

impl S<u8, u16> {
    ...
    Self(x) // Will probably start inferring `T` and `U` for `S<T, U>` instead of using `u8` and `u16`
    ...
}

@petrochenkov
Copy link
Contributor

Implementation strategy that supports type aliases and works correctly with generic parameters should likely mirror what is currently done with Self types, i.e. introduce Def::SelfVal, store it in HIR and resolve it later during type checking.

I'd recommend to search for Def::SelfTy in code and look how it's treated in various parts of the compiler, especially librustc_typeck (and librustc_resolve of course).

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 31, 2018
@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@F001
Copy link
Contributor Author

F001 commented Sep 7, 2018

@petrochenkov A new variant SelfCtor is introduced in enum Def. I tried to make all the tests passed, but I don't fully understand how it works. This is my first time to read the code in librustc_typeck. Thanks for your helps.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:47:18] ....................................................................................................
[00:47:21] ....................................................................................................
[00:47:24] ....................................................................................................
[00:47:27] ....................................................................................................
[00:47:30] ..............................................................F.....................................
[00:47:36] .......................................................................i............................
[00:47:39] ....................................................................................................
[00:47:42] .....................i.i..ii........................................................................
[00:47:46] ....................................................................................................
[00:47:46] ....................................................................................................
[00:47:49] .............................i......................................................................
[00:47:52] ....................................................................................................
[00:47:55] ....................................................................................................
[00:47:57] ....................................................................................................
[00:48:00] .............................................................i......................................
[00:48:04] ......................................................F.............................................
[00:48:11] ...............................................................................................i....
[00:48:14] ....................................................................................................
[00:48:17] ....................................................................................................
[00:48:20] ....................................................................................................
[00:48:20] ....................................................................................................
[00:48:22] 6 
[00:48:22] - error: aborting due to previous error
[00:48:22] + error[E0658]: tuple struct Self constructors are unstable (see issue #51994)
[00:48:22] +   --> $DIR/keyword-self-as-identifier.rs:12:9
[00:48:22] +    |
[00:48:22] + LL |     let Self = 22; //~ ERROR cannot find unit struct/variant or constant `Self` in this scope
[00:48:22] +    |
[00:48:22] +    |
[00:48:22] +    = help: add #![feature(tuple_struct_self_ctor)] to the crate attributes to enable
[00:48:22] - For more information about this error, try `rustc --explain E0531`.
[00:48:22] + error: aborting due to 2 previous errors
[00:48:22] + 
[00:48:22] + Some errors occurred: E0531, E0658.
[00:48:22] + Some errors occurred: E0531, E0658.
[00:48:22] + For more information about an error, try `rustc --explain E0531`.
[00:48:22] 10 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/keyword/keyword-self-as-identifier/keyword-self-as-identifier.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args keyword/keyword-self-as-identifier.rs`
[00:48:22] error: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/keyword/keyword-self-as-identifier.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/kt":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0432]: unresolved import `self::Self`\n  --> /checkout/src/test/ui/self/self_type_keyword-2.rs:11:5\n   |\nLL | use self::Self as Foo; //~ ERROR unresolved import `self::Self`\n   |     ^^^^^^^^^^^^^^^^^ no `Self` in the root\n\n"}
[00:48:22] {"message":"cannot find unit struct/variant or constant `Self` in this scope","code":{"code":"E0531","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":556,"byte_end":560,"line_start":14,"line_end":14,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"    let Self = 5;","highlight_start":9,"highlight_end":13}],"label":"not found in this scope","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0531]: cannot find unit struct/variant or constant `Self` in this scope\n  --> /checkout/src/test/ui/self/self_type_keyword-2.rs:14:9\n   |\nLL |     let Self = 5;\n   |         ^^^^ not found in this scope\n\n"}
[00:48:22] {"message":"cannot find unit struct/variant or constant `Self` in this scope","code":{"code":"E0531","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":670,"byte_end":674,"line_start":18,"line_end":18,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"        Self => (),","highlight_start":9,"highlight_end":13}],"label":"not found in this scope","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"e/stage1-rustc/x86_64-unknown-linux-gnu
129884 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu
129880 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release
127388 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps
122724 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps
---
36984 ./obj/build/x86_64-unknown-linux-gnu/stage0-std/release
36960 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/release
36308 ./.git/modules/src/libcompiler_builtins
35640 ./src/tools/clang/lib
35508 ./!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:009bb90b
travis_time:start:009bb90b
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:08c6b878
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

new_def = Def::StructCtor(variant.did, variant.ctor_kind);
variant.did
} else {
span_bug!(span, "SelfCtor is not refer to adt type")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:47:09] ....................................................................................................
[00:47:11] ....................................................................................................
[00:47:14] ....................................................................................................
[00:47:17] .............................................................i......................................
[00:47:21] ......................................................F.............................................
[00:47:29] ...............................................................................................i....
[00:47:32] ....................................................................................................
[00:47:35] ....................................................................................................
[00:47:38] ....................................................................................................
---
[00:47:41] 13 error[E0531]: cannot find unit struct/variant or constant `Self` in this scope
[00:47:41] -   --> $DIR/self_type_keyword-2.rs:18:9
[00:47:41] +   --> $DIR/self_type_keyword-2.rs:19:9
[00:47:41] 15    |
[00:47:41] 16 LL |         Self => (),
[00:47:41] 
[00:47:41] 18 
[00:47:41] 19 error[E0531]: cannot find unit struct/variant or constant `Self` in this scope
[00:47:41] -   --> $DIR/self_type_keyword-2.rs:20:18
[00:47:41] -   --> $DIR/self_type_keyword-2.rs:20:18
[00:47:41] +   --> $DIR/self_type_keyword-2.rs:22:18
[00:47:41] 21    |
[00:47:41] 22 LL |         Foo { x: Self } => (),
[00:47:41] 
[00:47:41] 
[00:47:41] 31    = help: add #![feature(tuple_struct_self_ctor)] to the crate attributes to enable
[00:47:41] 32 
[00:47:41] 33 error[E0658]: tuple struct Self constructors are unstable (see issue #51994)
[00:47:41] +   --> $DIR/self_type_keyword-2.rs:19:9
[00:47:41] 35    |
[00:47:41] 35    |
[00:47:41] 36 LL |         Self => (),
[00:47:41] 
[00:47:41] 
[00:47:41] 39    = help: add #![feature(tuple_struct_self_ctor)] to the crate attributes to enable
[00:47:41] 40 
[00:47:41] 41 error[E0658]: tuple struct Self constructors are unstable (see issue #51994)
[00:47:41] +   --> $DIR/self_type_keyword-2.rs:22:18
[00:47:41] 43    |
[00:47:41] 43    |
[00:47:41] 44 LL |         Foo { x: Self } => (),
[00:47:41] 
[00:47:41] 
[00:47:41] The actual stderr differed from the expected stderr.
[00:47:41] The actual stderr differed from the expected stderr.
[00:47:41] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/self/self_type_keyword-2/self_type_keyword-2.stderr
[00:47:41] To update references, rerun the tests and pass the `--bless` flag
[00:47:41] To only update this specific test, also pass `--test-args self/self_type_keyword-2.rs`
[00:47:41] error: 1 errors occurred comparing output.
[00:47:41] status: exit code: 1
[00:47:41] status: exit code: 1
[00:47:41] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/self/self_type_keyword-2.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/self/self_type_keyword-2/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/self/self_type_keyword-2/auxiliary" "-A" "unused"
[00:47:41] ------------------------------------------
[00:47:41] 
[00:47:41] ------------------------------------------
[00:47:41] stderr:
[00:47:41] stderr:
[00:47:41] ------------------------------------------
[00:47:41] {"message":"unresolved import `self::Self`","code":{"code":"E0432","explanation":"\nAn import was unresolved.\n\nErroneous code example:\n\n```compile_fail,E0432\nuse something::Foo; // error: unresolved import `something::Foo`.\n```\n\nPaths in `use` statements are relative to the crate root. To import items\nrelative to the current and parent modules, use the `self::` and `super::`\nprefixes, respectively. Also verify that you didn't misspell the import\nname and that the import exists in the module from where you tried to\nimport it. Example:\n\n```\nuse self::something::Foo; // ok!\n\nmod something {\n    pub struct Foo;\n}\n# fn main() {}\n```\n\nOr, if you tried to use a module from an external crate, you may have missed\nthe `extern crate` declaration (which is usually placed in the crate root):\n\n```\nextern crate core; // Required to use the `core` crate\n\nuse core::any;\n# fn main() {}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":471,"byte_end":488,"line_start":11,"line_end":11,"column_start":5,"column_end":22,"is_primary":true,"text":[{"text":"use self::Self as Foo; //~ ERROR unresolved import `self::Self`","highlight_start":5,"highlight_end":22}],"label":"no `Self` in the root","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0432]: unresolved import `self::Self`\n  --> /checkout/src/test/ui/self/self_type_keyword-2.rs:11:5\n   |\nLL | use self::Self as Foo; //~ ERROR unresolved import `self::Self`\n   |     ^^^^^^^^^^^^^^^^^ no `Self` in the root\n\n"}
[00:47:41] {"message":"cannot find unit struct/variant or constant `Self` in this scope","code":{"code":"E0531","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":556,"byte_end":560,"line_start":14,"line_end":14,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"    let Self = 5;","highlight_start":9,"highlight_end":13}],"label":"not found in this scope","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0531]: cannot find unit struct/variant or constant `Self` in this scope\n  --> /checkout/src/test/ui/self/self_type_keyword-2.rs:14:9\n   |\nLL |     let Self = 5;\n   |         ^^^^ not found in this scope\n\n"}
[00:47:41] {"message":"cannot find unit struct/variant or constant `Self` in this scope","code":{"code":"E0531","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":749,"byte_end":753,"line_start":19,"line_end":19,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"        Self => (),","highlight_start":9,"highlight_end":13}],"label":"not found in this scope","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0531]: cannot find unit struct/variant or constant `Self` in this scope\n  --> /checkout/src/test/ui/self/self_type_keyword-2.rs:19:9\n   |\nLL |         Self => (),\n   |         ^^^^ not found in this scope\n\n"}
[00:47:41] {"message":"cannot find unit struct/variant or constant `Self` in this scope","code":{"code":"E0531","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":945,"byte_end":949,"line_start":22,"struct_self_ctor)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: tuple struct Self constructors are unstable (see issue #51994)\n  --> /checkout/src/test/ui/self/self_type_keyword-2.rs:14:9\n   |\nLL |     let Self = 5;\n   |         ^^^^\n   |\n   = help: add #![feature(tuple_struct_self_ctor)] to the crate attributes to enable\n\n"}
[00:47:41] {"message":"tuple struct Self constructors are unstable (see issue #51994)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/self/self_type_keyword-2.rs","byte_start":749,"byte_end":753,"line_start":19,"line_end":19,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"        Self => (),","highlight_start":9,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(tuple_struct_self_ctor)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered --> /checkout/src/test/ui/self/self_type_keyword-2.rs:22:18\n   |\nLL |         Foo { x: Self } => (),\n   |                  ^^^^\n   |\n   = help: add #![feature(tuple_struct_self_ctor)] to the crate attributes to enable\n\n"}
[00:47:41] {"message":"aborting due to 7 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 7 previous errors\n\n"}
[00:47:41] {"message":"Some errors occurred: E0432, E0531, E0658.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0432, E0531, E0658.\n"}
[00:47:41] {"message":"For more information about an error, try `rustc --explain E0432`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0432`.\n"}
[00:47:41] ------------------------------------------
[00:47:41] 
[00:47:41] thread '[ui] ui/self/self_type_keyword-2.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3196:9
[00:47:41] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:47:41] 
[00:47:41] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:497:22
[00:47:41] 
[00:47:41] 
[00:47:41] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:47:41] 
[00:47:41] 
[00:47:41] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:47:41] Build completed unsuccessfully in 0:03:11
[00:47:41] Build completed unsuccessfully in 0:03:11
[00:47:41] Makefile:58: recipe for target 'check' failed
[00:47:41] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0339cbcc
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:04ef5ee6:start=1536309039199330616,finish=1536309039218963448,duration=19632832
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:07e00ab8
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:12e93ce5
travis_time:start:12e93ce5
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:071faeb2
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

!self.sess.features_untracked().tuple_struct_self_ctor {
emit_feature_err(&self.sess.parse_sess, "tuple_struct_self_ctor",
p.span, GateIssue::Language,
"tuple struct Self constructors are unstable");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this is not about tuple structs, unit structs have Self constructors too, so the wording could be tweaked to "Self struct constructors are unstable" without mentioning tuples.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature name tuple_struct_self_ctor contains "tuple" too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original feature name came from the RFC. Now it is renamed to self_struct_ctor. And related test files are renamed.

@bors
Copy link
Contributor

bors commented Sep 13, 2018

🌲 The tree is currently closed for pull requests below priority 1, this pull request will be tested once the tree is reopened

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 13, 2018
@bors
Copy link
Contributor

bors commented Sep 13, 2018

⌛ Testing commit 2157958 with merge a294236...

bors added a commit that referenced this pull request Sep 13, 2018
…rkor

Implement RFC 2302: tuple_struct_self_ctor

Tracking issue: #51994
@bors
Copy link
Contributor

bors commented Sep 13, 2018

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 13, 2018
@kennytm
Copy link
Member

kennytm commented Sep 14, 2018

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2018
@bors
Copy link
Contributor

bors commented Sep 14, 2018

⌛ Testing commit 2157958 with merge 6ff0b2e...

bors added a commit that referenced this pull request Sep 14, 2018
…rkor

Implement RFC 2302: tuple_struct_self_ctor

Tracking issue: #51994
@bors
Copy link
Contributor

bors commented Sep 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov,varkor
Pushing 6ff0b2e to master...

@bors bors merged commit 2157958 into rust-lang:master Sep 14, 2018
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #53751!

Tested on commit 6ff0b2e.
Direct link to PR: #53751

💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 rls on windows: test-pass → build-fail (cc @nrc, @rust-lang/infra).
💔 rls on linux: test-pass → build-fail (cc @nrc, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Sep 14, 2018
Tested on commit rust-lang/rust@6ff0b2e.
Direct link to PR: <rust-lang/rust#53751>

💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 rls on windows: test-pass → build-fail (cc @nrc, @rust-lang/infra).
💔 rls on linux: test-pass → build-fail (cc @nrc, @rust-lang/infra).
@kennytm
Copy link
Member

kennytm commented Sep 14, 2018

[01:09:43] error[E0004]: non-exhaustive patterns: `SelfCtor(_)` not covered
[01:09:43]    --> tools/clippy/clippy_lints/src/utils/mod.rs:846:11
[01:09:43]     |
[01:09:43] 846 |     match def {
[01:09:43]     |           ^^^ pattern `SelfCtor(_)` not covered

And clippy caused RLS to fail as usual.

@flip1995 flip1995 mentioned this pull request Sep 14, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Nov 9, 2018
Avoid panic when matching function call

Fix rust-lang#55718

This bug is introduced by rust-lang#53751. The original code checked `Def::AssociatedConst(..) | Def::Method(..)` before `pat_ty.no_bound_vars().expect("expected fn type")`. But somehow I exchanged the sequence carelessly. Sorry about that.

r? @petrochenkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants