Commit graph

328 commits

Author SHA1 Message Date
Temirkhan Myrzamadi ea7cf61068 Don't suggest macros that out of scope 2020-09-30 12:00:59 +06:00
Temirkhan Myrzamadi 13dfbb64d3 Suggest imports of unresolved macros 2020-09-30 12:00:59 +06:00
David Wood 9ef68f53e1
resolve: improve "try using the enum's variant"
This commit improves the "try using the enum's variant" suggestion:

- Variants in suggestions would not result in more errors (e.g. use
  of a struct variant is only suggested if the suggestion can
  trivially construct that variant). Therefore, suggestions are only
  emitted for variants that have no fields (since the suggestion
  can't know what value fields would have).
- Suggestions include the syntax for constructing the variant. If a
  struct or tuple variant is suggested, then it is constructed in the
  suggestion - unless in pattern-matching or when arguments are already
  provided.
- A help message is added which mentions the variants which are no
  longer suggested.

Signed-off-by: David Wood <david@davidtw.co>
2020-09-29 16:52:43 +01:00
Erik Hofmayer 138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
ecstatic-morse dcf4d1f2be
Rollup merge of #76888 - matthiaskrgr:clippy_single_match_2, r=Dylan-DPC
use if let instead of single match arm expressions

use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match)
2020-09-21 20:40:55 -07:00
Ralf Jung 8405d50e12
Rollup merge of #76890 - matthiaskrgr:matches_simpl, r=lcnr
use matches!() macro for simple if let conditions
2020-09-20 15:52:01 +02:00
Matthias Krüger c690c82ad4 use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match) 2020-09-20 11:42:52 +02:00
Matthias Krüger 40dddd3305 use matches!() macro for simple if let conditions 2020-09-18 20:28:35 +02:00
Matthias Krüger 012974da7a use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip) 2020-09-17 10:13:16 +02:00
Tyler Mandry a6c4d30c7b
Rollup merge of #76756 - matthiaskrgr:cl123ppy, r=Dylan-DPC
fix a couple of stylistic clippy warnings

namely:

clippy::redundant_pattern_matching
clippy::redundant_pattern
clippy::search_is_some
clippy::filter_next
clippy::into_iter_on_ref
clippy::clone_on_copy
clippy::needless_return
2020-09-16 12:24:17 -07:00
Matthias Krüger 73d4171ea6 fix a couple of stylistic clippy warnings
namely:

clippy::redundant_pattern_matching
clippy::redundant_pattern
clippy::search_is_some
clippy::filter_next
clippy::into_iter_on_ref
clippy::clone_on_copy
clippy::needless_return
2020-09-15 22:44:54 +02:00
Hameer Abbasi 5f0b775390
Remove redundant &format!.
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
2020-09-15 11:11:18 +02:00
Hameer Abbasi 7d5db239e7 This commit introduces the following changes:
* Change error message for type param in a const expression when using
min_const_generics
* Change ParamInNonTrivialAnonConst to contain an extra bool used for
distinguishing whether the passed-in symbol is a type or a value.
2020-09-15 10:27:19 +02:00
Bastian Kauschke c552717e9d review, improve note span 2020-09-13 22:53:51 +02:00
Bastian Kauschke e5b82a56c5 allow concrete self types in consts 2020-09-13 22:53:51 +02:00
bors bc57bd8c7e Auto merge of #76499 - guswynn:priv_des, r=petrochenkov
Give better diagnostic when using a private tuple struct constructor

Fixes #75907

Some notes:
1. This required some deep changes, including removing a Copy impl for PatKind. If some tests fail, I would still appreciate review on the overall approach
2. this only works with basic patterns (no wildcards for example), and fails if there is any problems getting the visibility of the fields (i am not sure what the failure that can happen in resolve_visibility_speculative, but we check the length of our fields in both cases against each other, so if anything goes wrong, we fall back to the worse error. This could be extended to more patterns
3. this does not yet deal with #75906, but I believe it will be similar
4. let me know if you want more tests
5. doesn't yet at the suggestion that `@yoshuawuyts` suggested at the end of their issue, but that could be added relatively easily (i believe)
2020-09-11 20:01:31 +00:00
Gus Wynn c63f634a4b Give better diagnostic when using a private tuple struct constructor 2020-09-11 11:36:42 -07:00
Aaron Hill c1011165e6
Attach TokenStream to ast::Visibility
A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill 55082ce413
Attach TokenStream to ast::Path 2020-09-10 17:33:06 -04:00
Tyler Mandry 09c614948f
Rollup merge of #76522 - matthiaskrgr:redundant_clone, r=jonas-schievink
remove redundant clones

(clippy::redundant_clone)
2020-09-09 15:06:05 -07:00
Tyler Mandry 5ea55518bc
Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasper
Improve unresolved use error message

"use of undeclared type or module `foo`" doesn't mention that it could be a crate.

This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate.

I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-09 15:05:45 -07:00
Matthias Krüger be28b6235e remove redundant clones
(clippy::redundant_clone)
2020-09-09 16:32:55 +02:00
Tyler Mandry b01d0b1414
Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov
Give a better error message for duplicate built-in macros

Minor follow-up to https://github.com/rust-lang/rust/pull/75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug.

r? @petrochenkov
2020-09-01 18:24:35 -07:00
Kornel 7ec1de062a Clarify message about unresolved use 2020-09-01 18:38:14 +01:00
Joshua Nelson be2947d0b7 Give a better error message for duplicate built-in macros
Previously, this would say no such macro existed, but this was
misleading, since the macro _did_ exist, it was just already seen.

- Say where the macro was previously defined
- Add long-form error message
2020-09-01 08:34:17 -04:00
Esteban Küber 07112ca62d Suggest if let x = y when encountering if x = y
Detect potential cases where `if let` was meant but `let` was left out.

Fix #44990.
2020-08-30 15:01:06 -07:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00