| Age | Commit message (Collapse) | Author | Lines |
|
The duplicate error message is later removed by error message
deduplication, but it still appears on beta and is still a bug
|
|
fixes to MIR effectck
r? @eddyb
beta-nominating because regression (MIR effectck is new)
|
|
Fix some E-needstest issues.
Also ignore `attr-on-trait` test on stage-1 to keep `./x.py test --stage 1` successful.
Fixes #30355.
Fixes #33241.
Fixes #36400.
Fixes #37887.
Fixes #44578.
|
|
See the [RFC] and [tracking issue].
[tracking issue]: https://github.com/rust-lang/rust/issues/42640
[RFC]: https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md
|
|
Also ignore `attr-on-trait` test on stage-1 to keep `./x.py test --stage 1` successful.
Fixes #30355.
Fixes #33241.
Fixes #36400.
Fixes #37887.
Fixes #44578.
|
|
handle nested generics in Generics::type_param/region_param
Fixes #44952.
r? @eddyb
|
|
|
|
code suggestions for unused-mut, while-true, deprecated-attribute, and unused-parens lints

r? @estebank
|
|
|
|
Fixes #44952.
|
|
|
|
adding E0623 for return types - both parameters are anonymous
This is a fix for #44018
```
error[E0621]: explicit lifetime required in the type of `self`
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:17:5
|
16 | fn foo<'a>(&self, x: &i32) -> &i32 {
| ---- ----
| |
| this parameter and the return type are
declared with different lifetimes...
17 | x
| ^ ...but data from `x` is returned here
error: aborting due to previous error
```
It also works for the below case where we have self as anonymous
```
error[E0623]: lifetime mismatch
--> src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs:17:19
|
16 | fn foo<'a>(&self, x: &Foo) -> &Foo {
| ---- ----
| |
| this parameter and the return type are
declared with different lifetimes...
17 | if true { x } else { self }
| ^ ...but data from `x` is returned here
error: aborting due to previous error
```
r? @nikomatsakis
Currently, I have enabled E0621 where return type and self are anonymous, hence WIP.
|
|
Impl Try for Option
This is part of #31436.
|
|
Point at signature on unused lint
```
warning: struct is never used: `Struct`
--> $DIR/unused-warning-point-at-signature.rs:22:1
|
22 | struct Struct {
| ^^^^^^^^^^^^^
```
Fix #33961.
|
|
Point at parameter type on E0301
On "the parameter type `T` may not live long enough" error, point to the
parameter type suggesting lifetime bindings:
```
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
|
27 | struct Foo<T> {
| - help: consider adding an explicit lifetime bound `T: 'static`...
28 | foo: &'static T
| ^^^^^^^^^^^^^^^
|
note: ...so that the reference type `&'static T` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
|
28 | foo: &'static T
| ^^^^^^^^^^^^^^^
```
Fix #36700.
|
|
|
|
|
|
That kind of formatting seems like the job of other code.
|
|
|
|
|
|
|
|
Friendlier error message for closure argument type mismatch
Rebased #42270.
Fixes #42143.
---
`test.rs`:
```rust
fn main() {
foo(|_: i32, _: usize| ());
}
fn foo<F>(_: F) where F: Fn(&str, usize) {}
```
Before:
```
error[E0281]: type mismatch: `[closure@test.rs:2:9: 2:30]` implements the trait `std::ops::Fn<(i32, usize)>`, but the trait `for<'r> std::ops::Fn<(&'r str, usize)>` is required
--> test.rs:2:5
|
2 | foo(|_: i32, _: usize| ());
| ^^^ --------------------- implements `std::ops::Fn<(i32, usize)>`
| |
| expected &str, found i32
| requires `for<'r> std::ops::Fn<(&'r str, usize)>`
|
= note: required by `foo`
```
After (early):
```
error[E0631]: type mismatch in closure arguments
--> test.rs:2:5
|
2 | foo(|_: i32, _: usize| ());
| ^^^ --------------------- takes arguments of type `i32` and `usize`
| |
| expected arguments of type `&str` and `usize`
|
= note: required by `foo`
```
After (current):
```
error[E0631]: type mismatch in closure arguments
--> test.rs:2:5
|
2 | foo(|_: i32, _: usize| ());
| ^^^ --------------------- found signature of `fn(i32, usize) -> _`
| |
| expected signature of `for<'r> fn(&'r str, usize) -> _`
|
= note: required by `foo`
```
~~Compiler output has been changed, and a few tests are failing. Help me writing/fixing tests!~~
r? @nikomatsakis
|
|
Add suggestions for misspelled method names
Use the syntax::util::lev_distance module to provide suggestions when a
named method cannot be found.
Part of #30197
|
|
|
|
On "the parameter type `T` may not live long enough" error, point to the
parameter type suggesting lifetime bindings:
```
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
|
27 | struct Foo<T> {
| - help: consider adding an explicit lifetime bound `T: 'static`...
28 | foo: &'static T
| ^^^^^^^^^^^^^^^
|
note: ...so that the reference type `&'static T` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
|
28 | foo: &'static T
| ^^^^^^^^^^^^^^^
```
|
|
The convention for suggesting close matches is to provide at most one match (the
closest one). Change the suggestions for misspelt method names to obey that.
|
|
add comparison operators to must-use lint (under `fn_must_use` feature)
Although RFC 1940 is about annotating functions with `#[must_use]`, a
key part of the motivation was linting unused equality operators.
(See
https://github.com/rust-lang/rfcs/pull/1812#issuecomment-265695898—it
seems to have not been clear to discussants at the time that marking the
comparison methods as `must_use` would not give us the lints on
comparison operators, at least in (what the present author understood
as) the most straightforward implementation, as landed in #43728
(3645b062).)
To rectify the situation, we here lint unused comparison operators as
part of the unused-must-use lint (feature gated by the `fn_must_use`
feature flag, which now arguably becomes a slight (tolerable in the
opinion of the present author) misnomer).
This is in the matter of #43302.
cc @crumblingstatue
|
|
Improve diagnostics when attempting to match tuple enum variant with struct pattern
Adds an extra note as below to explain that a tuple pattern was probably intended.
```
error[E0026]: variant `X::Y` does not have a field named `data`
--> src/main.rs:18:16
|
18 | X::Y { data } => println!("The data is {}", data)
| ^^^^ variant `X::Y` does not have field `data`
error[E0027]: pattern does not mention field `0`
--> src/main.rs:18:9
|
18 | X::Y { data } => println!("The data is {}", data)
| ^^^^^^^^^^^^^ missing field `0`
|
= note: trying to match a tuple variant with a struct variant pattern
```
Fixes #41314.
|
|
|
|
Add deref suggestion
Fixes #34562.
|
|
|
|
Fixes #42143.
E0281 is totally replaced by E0631. UI tests are updated accordingly.
|
|
Although RFC 1940 is about annotating functions with `#[must_use]`, a
key part of the motivation was linting unused equality operators.
(See
https://github.com/rust-lang/rfcs/pull/1812#issuecomment-265695898—it
seems to have not been clear to discussants at the time that marking the
comparison methods as `must_use` would not give us the lints on
comparison operators, at least in (what the present author understood
as) the most straightforward implementation, as landed in #43728
(3645b062).)
To rectify the situation, we here lint unused comparison operators as
part of the unused-must-use lint (feature gated by the `fn_must_use`
feature flag, which now arguably becomes a slight (tolerable in the
opinion of the present author) misnomer).
This is in the matter of #43302.
|
|
|
|
A slight eccentricity of this change is that now non-ADT-derive errors prevent
derive-macro-not-found errors from surfacing (see changes to the
gating-of-derive compile-fail tests).
Resolves #43927.
|
|
|
|
don't suggest placing `use` statements into expanded code
r? @nrc
fixes #44210
```rust
#[derive(Debug)]
struct Foo;
type X = Path;
```
will try to place `use std::path::Path;` between `#[derive(Debug)]` and `struct Foo;`
I am not sure how to obtain a span before the first attribute, because derive attributes are removed during expansion.
It would be trivial to detect this case and place the `use` after the item, but that would be somewhat weird I think.
|
|
Use the syntax::util::lev_distance module to provide suggestions when a
named method cannot be found.
Part of #30197
|
|
I don't think the "quasi-postorder" travesal could cause any issues, but
there's no reason for it to stay broken.
|
|
interiors
|
|
RFC 1940 housekeeping
* move test to own directory, as requested in https://github.com/rust-lang/rust/issues/43302#issuecomment-329579185
* exercise trait methods in test
* unstable book section
r? @nikomatsakis
|
|
extend E0623 for earlybound and latebound for structs
This fixes #44508
r? @nikomatsakis
|
|
Fix "new trace_macros doesn't work if there's an error during expansion"
Fixes #43493
|
|
Individualize feature gates for const fn invocation
This PR changes the meaning of `#![feature(const_fn)]` so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward.
This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review.
- `std::cell`
- `Cell::new`
- `RefCell::new`
- `UnsafeCell::new`
- `std::mem`
- `size_of`
- `align_of`
- `std::ptr`
- `null`
- `null_mut`
- `std::sync`
- `atomic`
- `Atomic{Bool,Ptr,Isize,Usize}::new`
- `once`
- `Once::new`
- primitives
- `{integer}::min_value`
- `{integer}::max_value`
Some other functions are const but they are also unstable or hidden, e.g. `Unique::new` so they don't have to be considered at this time.
After this stabilization, the following `*_INIT` constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR.
- `std::sync`
- `atomic`
- `ATOMIC_{BOOL,ISIZE,USIZE}_INIT`
- `once`
- `ONCE_INIT`
|
|
|
|
(It was put forward that all tests related to a feature being in their own
directory makes stabilization decisionmaking more convenient.)
|
|
"avoid" is a better word here than "disable"
You don't "disable" the warning really, you just avoid it (as a conscious action).
|
|
|
|
|
|
|