`PointerKind` is included in `LoanPath` and hence forms part of the
equality check; this led to having two unequal paths that both
represent `*x`, depending on whether the `*` was inserted
automatically or explicitly. Bad mojo. The `note` field, in contrast,
is intended more-or-less primarily for this purpose of adding extra
data.
[MIR] Change "scopes" from "visibility scopes" to "source scopes".
These scopes are already used for source-oriented diagnostics, lint levels and unsafety checks.
This PR generalizes the naming around scopes, making the type `SourceScope`, and flips (across several commits) the relationship/priority between `LocalDecl`'s "visibility" and "syntactic" scopes.
r? @nikomatsakis
resolve: Make sure indeterminate and inconsistent macro resolutions always generate errors
Addresses the issue described in https://github.com/rust-lang/rust/pull/50911#issuecomment-392560525
I haven't come up with a minimized reproduction yet, but confirmed that `npbot` now generates the correct error with `![feature(use_extern_macros)]`.
reset anonymous-lifetime-mode as we enter `()` scopes
Background:
The anonymous lifetime mode is used to prohibit elided lifetimes where
they didn't used to be permitted, and instead require that `'_` be
used. For example:
```rust
impl Trait for Ref<T> { .. }
// ^^^^^^ ERROR: should be `Ref<'_, T>`
```
When we are parsing the parts of the impl header, we enter into an alternate mode called `CreateParameter`. In this mode, we give an error for things like `Ref<T>`, but for elided lifetimes in a reference type like `&T` we make the elided lifetime into an in-band lifetime:
4f99f37b7e/src/librustc/hir/lowering.rs (L4017-L4035)
This was not intended to change behavior because we only enter into that mode in contexts where elision was not historically permitted. However, the problem is that we fail to reset the mode when we enter into bounds like `Fn(&u32)`, where elision *was* allowed -- the same occurs for fn types like `fn(&u32`). This PR restores the original mode in those contexts.
Fixes#51008
r? @cramertj
rustc: don't visit lifetime parameters through visit_lifetime.
Ideally we'd also not use the `Lifetime` struct for parameters, but I'll leave that to @varkor (#48149).
Fixes#51185 (discovered while auditing all the `visit_lifetime` implementations).
r? @nikomatsakis
Background:
The anonymous lifetime mode is used to prohibit elided lifetimes where
they didn't used to be permitted, and instead require that `'_` be
used. For example:
```rust
impl Trait for Ref<T> { .. }
// ^^^^^^ ERROR: should be `Ref<'_, T>`
```
When we are parsing the parts of the impl header, we enter into an
alternate mode called `CreateParameter`. In this mode, we give an
error for things like `Ref<T>`, but for elided lifetimes in a
reference type like `&T` we make the elided lifetime into an in-band
lifetime:
4f99f37b7e/src/librustc/hir/lowering.rs (L4017-L4035)
This was not intended to change behavior because we only enter into
that mode in contexts where elision was not historically
permitted. However, the problem is that we fail to reset the mode when
we enter into bounds like `Fn(&u32)`, where elision *was* allowed --
the same occurs for fn types like `fn(&u32`). This PR restores the
original mode in those contexts.
Suggest using `as_ref` on some borrow errors [hack]
When encountering the following code:
```rust
struct Foo;
fn takes_ref(_: &Foo) {}
let ref opt = Some(Foo);
opt.map(|arg| takes_ref(arg));
```
Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead.
This is a stop gap solution until we expand typeck to deal with these
cases in a more graceful way.
#43861
When encountering the following code:
```rust
struct Foo;
fn takes_ref(_: &Foo) {}
let ref opt = Some(Foo);
opt.map(|arg| takes_ref(arg));
```
Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead.
This is a stop gap solution until we expand typeck to deal with these
cases in a more graceful way.
Update libbacktrace
We haven't updated libbacktrace in two years. This is just blindly updating to the latest HEAD; I'd like to see what travis says. It at least builds on my machine, running some tests...
This perpetuates the patches from https://github.com/rust-lang/rust/pull/30908
While we're at it update the `backtrace` crate from crates.io. It turns out that
the submodule's configure script has gotten a lot more finnicky as of late so
also switch over to using the `cc` crate manually which allows to avoid some
hacks around the configure script as well