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

Rollup of 8 pull requests #96804

Merged
merged 17 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3a800bf
[bootstrap] Give a better error when trying to run a path with no reg…
jyn514 May 3, 2022
519aa6e
update `jemallocator` example to use 2018 edition import syntax
kraktus May 4, 2022
436c0e1
Fix an ICE on #96738
JohnTitor May 5, 2022
80087b9
bootstrap: bsd platform flags for split debuginfo
davidtwco May 6, 2022
35d77c1
Also suggest calling constructors for external DefIds
JohnTitor May 6, 2022
7b773e8
Remove closures on `expect_local` to apply `#[track_caller]`
JohnTitor May 6, 2022
d6c64f4
Fix an incorrect link in The Unstable Book
koic May 6, 2022
d7d928e
Link to correct issue in issue-95034 test
aliemjay May 6, 2022
848028c
Add regression test for #96319
Aaron1011 May 7, 2022
6226d10
Rollup merge of #96660 - jyn514:better-missing-path-error, r=Mark-Sim…
compiler-errors May 7, 2022
102bbc9
Rollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-S…
compiler-errors May 7, 2022
825dc80
Rollup merge of #96746 - JohnTitor:issue-96738, r=petrochenkov
compiler-errors May 7, 2022
0f1c067
Rollup merge of #96758 - davidtwco:split-debuginfo-bootstrap-bsd, r=M…
compiler-errors May 7, 2022
f799c5d
Rollup merge of #96778 - JohnTitor:expect-local-track-caller-take-2, …
compiler-errors May 7, 2022
738d58b
Rollup merge of #96781 - koic:fix_an_incorrect_link_in_the_unstable_b…
compiler-errors May 7, 2022
24d1304
Rollup merge of #96783 - aliemjay:typo-issue-95034, r=compiler-errors
compiler-errors May 7, 2022
fe52669
Rollup merge of #96801 - Aaron1011:coinductive-cycle-test, r=compiler…
compiler-errors May 7, 2022
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
7 changes: 6 additions & 1 deletion compiler/rustc_span/src/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,12 @@ impl DefId {
#[inline]
#[track_caller]
pub fn expect_local(self) -> LocalDefId {
self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self))
// NOTE: `match` below is required to apply `#[track_caller]`,
// i.e. don't use closures.
match self.as_local() {
Some(local_def_id) => local_def_id,
None => panic!("DefId::expect_local: `{:?}` isn't local", self),
}
}

#[inline]
Expand Down
29 changes: 19 additions & 10 deletions compiler/rustc_typeck/src/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,24 +368,33 @@ 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 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))
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
};

// 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(
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
//! [`GlobalAlloc`] trait. This type can be provided by an external library:
//!
//! ```rust,ignore (demonstrates crates.io usage)
//! extern crate jemallocator;
//!
//! use jemallocator::Jemalloc;
//!
//! #[global_allocator]
Expand Down
22 changes: 19 additions & 3 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -1405,8 +1417,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 {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/language-features/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
34 changes: 34 additions & 0 deletions src/test/incremental/issue-96319-coinductive-cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// edition:2018
// revisions: rpass1 rpass2

pub struct Stmt {
pub stmt_type: StmtKind,
#[cfg(rpass1)] pub stmt_tag: Option<LintTag>,
#[cfg(rpass2)] pub renamed_tag: Option<LintTag>,
}
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<Stmt>,
}
pub fn start_late_pass(stmt_receiver: Box<Stmt>) {
spawn(async { stmt_receiver });
}

pub fn spawn<T>(_: T)
where
T: Send,
{
}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

// This should not ICE.

// Refer to the issue for more minimized versions.

use std::{
future::Future,
marker::PhantomData,
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/typeck/issue-96738.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
Some.nonexistent_method(); //~ ERROR: no method named `nonexistent_method` found
}
16 changes: 16 additions & 0 deletions src/test/ui/typeck/issue-96738.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 the constructor of an enum variant
|
help: call the constructor
|
LL | (Some)(_).nonexistent_method();
| + ++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.