From 3a800bf5c75fc9889178e401b0ab5fab87deb00d Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 2 May 2022 23:25:08 -0500 Subject: [bootstrap] Give a better error when trying to run a path with no registered step Before: ``` thread 'main' panicked at 'error: no rules matched invalid', src/bootstrap/builder.rs:287:17 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` After: ``` error: no `check` rules matched 'invalid' help: run `x.py check --help --verbose` to show a list of available paths note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!` ``` --- src/bootstrap/builder.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index edfe31319e8..c399b004ead 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -284,7 +284,19 @@ impl StepDescription { } if !attempted_run { - panic!("error: no rules matched {}", path.display()); + eprintln!( + "error: no `{}` rules matched '{}'", + builder.kind.as_str(), + path.display() + ); + eprintln!( + "help: run `x.py {} --help --verbose` to show a list of available paths", + builder.kind.as_str() + ); + eprintln!( + "note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`" + ); + std::process::exit(1); } } } -- cgit 1.4.1-3-g733a5 From 436c0e129ca535d249fbf8d61d3b9334e5cd6767 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 6 May 2022 07:15:35 +0900 Subject: Fix an ICE on #96738 --- compiler/rustc_typeck/src/check/method/suggest.rs | 3 +-- src/test/ui/typeck/issue-96738.rs | 3 +++ src/test/ui/typeck/issue-96738.stderr | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/typeck/issue-96738.rs create mode 100644 src/test/ui/typeck/issue-96738.stderr (limited to 'src') diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 634ba2baf96..f36d2496673 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -367,8 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.is_fn_ty(rcvr_ty, span) { if let SelfSource::MethodCall(expr) = source { - let suggest = if let ty::FnDef(def_id, _) = rcvr_ty.kind() { - let local_id = def_id.expect_local(); + let suggest = if let ty::FnDef(def_id, _) = rcvr_ty.kind() && let Some(local_id) = def_id.as_local() { let hir_id = tcx.hir().local_def_id_to_hir_id(local_id); let node = tcx.hir().get(hir_id); let fields = node.tuple_fields(); diff --git a/src/test/ui/typeck/issue-96738.rs b/src/test/ui/typeck/issue-96738.rs new file mode 100644 index 00000000000..7f1d1428eb9 --- /dev/null +++ b/src/test/ui/typeck/issue-96738.rs @@ -0,0 +1,3 @@ +fn main() { + Some.nonexistent_method(); //~ ERROR: no method named `nonexistent_method` found +} diff --git a/src/test/ui/typeck/issue-96738.stderr b/src/test/ui/typeck/issue-96738.stderr new file mode 100644 index 00000000000..6f9bffbb790 --- /dev/null +++ b/src/test/ui/typeck/issue-96738.stderr @@ -0,0 +1,11 @@ +error[E0599]: no method named `nonexistent_method` found for fn item `fn(_) -> Option<_> {Option::<_>::Some}` in the current scope + --> $DIR/issue-96738.rs:2:10 + | +LL | Some.nonexistent_method(); + | ---- ^^^^^^^^^^^^^^^^^^ method not found in `fn(_) -> Option<_> {Option::<_>::Some}` + | | + | this is a function, perhaps you wish to call it + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. -- cgit 1.4.1-3-g733a5 From 80087b98ccea66b0734c514b97014399b5100255 Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 6 May 2022 03:00:39 +0100 Subject: bootstrap: bsd platform flags for split debuginfo Bootstrap currently provides `-Zunstable-options` for OpenBSD when using split debuginfo - this commit provides it for all BSD targets. Signed-off-by: David Wood --- src/bootstrap/builder.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 2224bf5f66e..e91a9991806 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1405,8 +1405,12 @@ impl<'a> Builder<'a> { // FIXME(davidtwco): #[cfg(not(bootstrap))] - #95612 needs to be in the bootstrap compiler // for this conditional to be removed. if !target.contains("windows") || compiler.stage >= 1 { - if target.contains("linux") || target.contains("windows") || target.contains("openbsd") - { + let needs_unstable_opts = target.contains("linux") + || target.contains("windows") + || target.contains("bsd") + || target.contains("dragonfly"); + + if needs_unstable_opts { rustflags.arg("-Zunstable-options"); } match self.config.rust_split_debuginfo { -- cgit 1.4.1-3-g733a5 From 35d77c17101852d17ebd27434c09b3652689e5c6 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 7 May 2022 00:43:50 +0900 Subject: Also suggest calling constructors for external DefIds --- compiler/rustc_typeck/src/check/method/suggest.rs | 30 +++++++++++++++-------- src/test/ui/typeck/issue-96738.stderr | 7 +++++- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index f36d2496673..294a42a1148 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -367,16 +367,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.is_fn_ty(rcvr_ty, span) { if let SelfSource::MethodCall(expr) = source { - let suggest = if let ty::FnDef(def_id, _) = rcvr_ty.kind() && let Some(local_id) = def_id.as_local() { - let hir_id = tcx.hir().local_def_id_to_hir_id(local_id); - let node = tcx.hir().get(hir_id); - let fields = node.tuple_fields(); - - if let Some(fields) = fields - && let Some(DefKind::Ctor(of, _)) = self.tcx.opt_def_kind(local_id) { - Some((fields, of)) + let suggest = if let ty::FnDef(def_id, _) = rcvr_ty.kind() { + if let Some(local_id) = def_id.as_local() { + let hir_id = tcx.hir().local_def_id_to_hir_id(local_id); + let node = tcx.hir().get(hir_id); + let fields = node.tuple_fields(); + if let Some(fields) = fields + && let Some(DefKind::Ctor(of, _)) = self.tcx.opt_def_kind(local_id) { + Some((fields.len(), of)) + } else { + None + } } else { - None + // The logic here isn't smart but `associated_item_def_ids` + // doesn't work nicely on local. + if let DefKind::Ctor(of, _) = tcx.def_kind(def_id) { + let parent_def_id = tcx.parent(*def_id); + Some((tcx.associated_item_def_ids(parent_def_id).len(), of)) + } else { + None + } } } else { None @@ -384,7 +394,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If the function is a tuple constructor, we recommend that they call it if let Some((fields, kind)) = suggest { - suggest_call_constructor(expr.span, kind, fields.len(), &mut err); + suggest_call_constructor(expr.span, kind, fields, &mut err); } else { // General case err.span_label( diff --git a/src/test/ui/typeck/issue-96738.stderr b/src/test/ui/typeck/issue-96738.stderr index 6f9bffbb790..58c83a36a3b 100644 --- a/src/test/ui/typeck/issue-96738.stderr +++ b/src/test/ui/typeck/issue-96738.stderr @@ -4,7 +4,12 @@ error[E0599]: no method named `nonexistent_method` found for fn item `fn(_) -> O LL | Some.nonexistent_method(); | ---- ^^^^^^^^^^^^^^^^^^ method not found in `fn(_) -> Option<_> {Option::<_>::Some}` | | - | this is a function, perhaps you wish to call it + | this is the constructor of an enum variant + | +help: call the constructor + | +LL | (Some)(_).nonexistent_method(); + | + ++++ error: aborting due to previous error -- cgit 1.4.1-3-g733a5 From d6c64f4368c2b34c0a7accf601114eb46636c1b2 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 7 May 2022 01:21:40 +0900 Subject: Fix an incorrect link in The Unstable Book https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs returns page not found. The following is the background of the move. First https://github.com/rust-lang/rust/pull/74862 moves from src/librustc_session/lint/builtin.rs to compiler/rustc_session/src/lint/builtin.rs Then https://github.com/rust-lang/rust/commit/23018a5 moves from compiler/rustc_session/src/lint/builtin.rs to compiler/rustc_lint_defs/src/builtin.rs So, the current correct link is https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint_defs/src/builtin.rs This PR fixes a broken link on the following page: https://doc.rust-lang.org/beta/unstable-book/language-features/plugin.html --- src/doc/unstable-book/src/language-features/plugin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index 040f46f8b7c..56fe9a31bfe 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -102,7 +102,7 @@ The components of a lint plugin are: Lint passes are syntax traversals, but they run at a late stage of compilation where type information is available. `rustc`'s [built-in -lints](https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs) +lints](https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint_defs/src/builtin.rs) mostly use the same infrastructure as lint plugins, and provide examples of how to access type information. -- cgit 1.4.1-3-g733a5 From d7d928e9672761ecabccc320dcd8ae5060560237 Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Fri, 6 May 2022 20:35:06 +0300 Subject: Link to correct issue in issue-95034 test --- src/test/ui/hrtb/issue-94034.rs | 96 ------------------------------------ src/test/ui/hrtb/issue-94034.stderr | 1 - src/test/ui/hrtb/issue-95034.rs | 98 +++++++++++++++++++++++++++++++++++++ src/test/ui/hrtb/issue-95034.stderr | 1 + 4 files changed, 99 insertions(+), 97 deletions(-) delete mode 100644 src/test/ui/hrtb/issue-94034.rs delete mode 100644 src/test/ui/hrtb/issue-94034.stderr create mode 100644 src/test/ui/hrtb/issue-95034.rs create mode 100644 src/test/ui/hrtb/issue-95034.stderr (limited to 'src') diff --git a/src/test/ui/hrtb/issue-94034.rs b/src/test/ui/hrtb/issue-94034.rs deleted file mode 100644 index 5239e5db11c..00000000000 --- a/src/test/ui/hrtb/issue-94034.rs +++ /dev/null @@ -1,96 +0,0 @@ -// known-bug -// failure-status: 101 -// compile-flags: --edition=2021 --crate-type=lib -// rustc-env:RUST_BACKTRACE=0 - -// normalize-stderr-test "thread 'rustc' panicked.*" -> "thread 'rustc' panicked" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" -// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" -// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" -// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" -// normalize-stderr-test "note: compiler flags.*\n\n" -> "" -// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "query stack during panic:\n" -> "" -// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" -// normalize-stderr-test "end of query stack\n" -> "" -// normalize-stderr-test "#.*\n" -> "" - -// This should not ICE. - -use std::{ - future::Future, - marker::PhantomData, - pin::Pin, - task::{Context, Poll}, -}; - -mod object { - use super::*; - - pub trait Object<'a> { - type Error; - type Future: Future; - fn create() -> Self::Future; - } - - impl<'a> Object<'a> for u8 { - type Error = (); - type Future = Pin>>; - fn create() -> Self::Future { - unimplemented!() - } - } - - impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) { - type Error = (); - type Future = CustomFut<'a, E, A>; - fn create() -> Self::Future { - unimplemented!() - } - } - - pub struct CustomFut<'f, E, A: Object<'f, Error = E>> { - ph: PhantomData<(A::Future,)>, - } - - impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> { - type Output = (A,); - fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { - unimplemented!() - } - } -} - -mod async_fn { - use super::*; - - pub trait AsyncFn { - type Future: Future; - fn call(&self) -> Self::Future; - } - - impl AsyncFn for F - where - F: Fn() -> Fut, - Fut: Future, - { - type Future = Fut; - fn call(&self) -> Self::Future { - (self)() - } - } -} - -pub async fn test() { - use self::{async_fn::AsyncFn, object::Object}; - - async fn create>() { - T::create().await; - } - - async fn call_async_fn(inner: impl AsyncFn) { - inner.call().await; - } - - call_async_fn(create::<(u8,)>).await; -} diff --git a/src/test/ui/hrtb/issue-94034.stderr b/src/test/ui/hrtb/issue-94034.stderr deleted file mode 100644 index 1d8329142fc..00000000000 --- a/src/test/ui/hrtb/issue-94034.stderr +++ /dev/null @@ -1 +0,0 @@ -thread 'rustc' panicked diff --git a/src/test/ui/hrtb/issue-95034.rs b/src/test/ui/hrtb/issue-95034.rs new file mode 100644 index 00000000000..aee6fe61ba8 --- /dev/null +++ b/src/test/ui/hrtb/issue-95034.rs @@ -0,0 +1,98 @@ +// known-bug +// failure-status: 101 +// compile-flags: --edition=2021 --crate-type=lib +// rustc-env:RUST_BACKTRACE=0 + +// normalize-stderr-test "thread 'rustc' panicked.*" -> "thread 'rustc' panicked" +// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" +// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" +// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" +// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" +// normalize-stderr-test "#.*\n" -> "" + +// This should not ICE. + +// Refer to the issue for more minimized versions. + +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, + task::{Context, Poll}, +}; + +mod object { + use super::*; + + pub trait Object<'a> { + type Error; + type Future: Future; + fn create() -> Self::Future; + } + + impl<'a> Object<'a> for u8 { + type Error = (); + type Future = Pin>>; + fn create() -> Self::Future { + unimplemented!() + } + } + + impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) { + type Error = (); + type Future = CustomFut<'a, E, A>; + fn create() -> Self::Future { + unimplemented!() + } + } + + pub struct CustomFut<'f, E, A: Object<'f, Error = E>> { + ph: PhantomData<(A::Future,)>, + } + + impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> { + type Output = (A,); + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { + unimplemented!() + } + } +} + +mod async_fn { + use super::*; + + pub trait AsyncFn { + type Future: Future; + fn call(&self) -> Self::Future; + } + + impl AsyncFn for F + where + F: Fn() -> Fut, + Fut: Future, + { + type Future = Fut; + fn call(&self) -> Self::Future { + (self)() + } + } +} + +pub async fn test() { + use self::{async_fn::AsyncFn, object::Object}; + + async fn create>() { + T::create().await; + } + + async fn call_async_fn(inner: impl AsyncFn) { + inner.call().await; + } + + call_async_fn(create::<(u8,)>).await; +} diff --git a/src/test/ui/hrtb/issue-95034.stderr b/src/test/ui/hrtb/issue-95034.stderr new file mode 100644 index 00000000000..1d8329142fc --- /dev/null +++ b/src/test/ui/hrtb/issue-95034.stderr @@ -0,0 +1 @@ +thread 'rustc' panicked -- cgit 1.4.1-3-g733a5 From 848028c0a7bfc5e8d507e927b8114313037931a7 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 6 May 2022 22:28:22 -0400 Subject: Add regression test for #96319 --- .../incremental/issue-96319-coinductive-cycle.rs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/incremental/issue-96319-coinductive-cycle.rs (limited to 'src') diff --git a/src/test/incremental/issue-96319-coinductive-cycle.rs b/src/test/incremental/issue-96319-coinductive-cycle.rs new file mode 100644 index 00000000000..b5ff9112a20 --- /dev/null +++ b/src/test/incremental/issue-96319-coinductive-cycle.rs @@ -0,0 +1,34 @@ +// edition:2018 +// revisions: rpass1 rpass2 + +pub struct Stmt { + pub stmt_type: StmtKind, + #[cfg(rpass1)] pub stmt_tag: Option, + #[cfg(rpass2)] pub renamed_tag: Option, +} +pub struct LintTag; +pub enum StmtKind { + If(If), + Block(&'static str), + Return(Return), +} +pub struct If { + pub condition: Function, +} +pub struct Return { + pub value: Function, +} +pub struct Function { + pub parameters: Box, +} +pub fn start_late_pass(stmt_receiver: Box) { + spawn(async { stmt_receiver }); +} + +pub fn spawn(_: T) +where + T: Send, +{ +} + +fn main() {} -- cgit 1.4.1-3-g733a5