Commit Graph

203 Commits

Author SHA1 Message Date
Mark Rousskov d5b760ba62 Bump rustfmt version
Also switches on formatting of the mir build module
2021-02-02 09:09:52 -05:00
Danuel 8bbb2d057d Fixed #[inline] to be warned in fields, arms, macro defs
Add visitors for checking #[inline]

Add visitors for checking #[inline] with struct field

Fix test for #[inline]

Add visitors for checking #[inline] with #[macro_export] macro

Add visitors for checking #[inline] without #[macro_export] macro

Add use alias with Visitor

Fix lint error

Reduce unnecessary variable

Co-authored-by: LingMan <LingMan@users.noreply.github.com>

Change error to warning

Add warning for checking field, arm with #[allow_internal_unstable]

Add name resolver

Formatting

Formatting

Fix error fixture

Add checking field, arm, macro def
2021-02-01 23:36:19 +09:00
Oli Scherer 85ad773049
Add missing brace 2021-01-28 17:49:40 +01:00
Seo Sanghyeon 899aae465e
Simplify base_expr
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2021-01-29 01:44:15 +09:00
Seo Sanghyeon d3c69a4c0d Warn write-only fields 2021-01-28 23:56:13 +09:00
Yuki Okushi 446edd1e1a
Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakis
Refractor a few more types to `rustc_type_ir`

In the continuation of #79169, ~~blocked on that PR~~.

This PR:
 - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance`
 - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler.

~~I will split up that commit to make this easier to review and to have a better commit history.~~
EDIT: done, I split the PR in commits of 200-ish lines each

r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-28 15:09:02 +09:00
Felix S. Klock II 4c5ede7c6a This should address issue 81294.
(No test added. The relevant test *is* ui/panic-handler/weak-lang-item.rs, and this change should make it less flaky.)
2021-01-25 14:37:27 -05:00
Jonas Schievink 04ddf42218
Rollup merge of #81310 - tmiasko:in-pattern, r=petrochenkov
Do not mark unit variants as used when in path pattern

Record that we are processing a pattern so that code responsible for
handling path resolution can correctly decide whether to mark it as
used or not.

Closes #76788.
2021-01-24 22:10:06 +01:00
bors 85e355ea9b Auto merge of #80919 - cjgillot:defkey-span, r=oli-obk
Generate metadata by iterating on DefId instead of traversing the HIR tree 1/N

Sample from #80347.
2021-01-24 06:51:17 +00:00
Camille GILLOT 97ee7c7e5a Allow to query the HIR crate node. 2021-01-23 13:58:09 +01:00
Tomasz Miąsko 99a1dea1b7 Do not mark unit variants as used when in path pattern
Record that we are processing a pattern so that code responsible for
handling path resolution can correctly decide whether to mark it as
used or not.
2021-01-23 00:00:00 +00:00
Esteban Küber 9e82329c8f Do not suggest using a break label when one is already present 2021-01-21 21:43:29 -08:00
Esteban Küber 8a13abba1d Tweak error for invalid `break expr`
Point at loop head on invalid `break expr`.
Suggest removing `expr` or using label if available.
2021-01-21 21:41:46 -08:00
Esteban Küber 060dba67b7 Add loop head span to hir 2021-01-21 21:41:46 -08:00
LeSeulArtichaut 50e1ae15e9 Use ty::{IntTy,UintTy,FloatTy} in rustc 2021-01-18 21:09:30 +01:00
oli 5bac1c9229 Only inherit const stability for methods of `impl const Trait` blocks 2021-01-18 11:07:35 +00:00
bors d03fe84169 Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
Reintroduce hir::ExprKind::If

Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.

The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.

- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051)
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d)
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5)
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691)
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95)
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-14 14:41:58 +00:00
bors 150d1fee04 Auto merge of #79322 - jyn514:refactor-impl, r=estebank
Separate out a `hir::Impl` struct

This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.

See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with.

r? `@petrochenkov` maybe?
2021-01-13 01:40:41 +00:00
Joshua Nelson a8ff647deb Separate out a `hir::Impl` struct
This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.
2021-01-12 20:32:33 -05:00
Camelid e2d3a25161 Fix small typo
transmutting -> transmuting
2021-01-10 21:24:32 -08:00
Caio f85fc264fe Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
Guillaume Gomez 7bc22e96d3 Don't use to_string on Symbol 2021-01-06 10:59:50 +01:00
Guillaume Gomez c4c010f534 Add an error in case the doc alias is the same as the item it's aliasing 2021-01-04 15:05:36 +01:00
Matthias Krüger 8a90626a46 reduce borrowing and (de)referencing around match patterns (clippy::match_ref_pats) 2021-01-02 20:09:17 +01:00
Rémy Rakic 1fc3c4c16d adjust const generics defaults FIXMEs to the new feature gate 2021-01-01 11:01:01 +01:00
Mara Bos 9e8edc8c22
Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkov
Rename kw::Invalid -> kw::Empty

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.

r? `@petrochenkov`
2020-12-30 20:56:58 +00:00
Joshua Nelson edeac1778c Rename kw::Invalid -> kw::Empty
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.
2020-12-30 09:50:02 -05:00
Matthias Krüger d12a358673 use matches!() macro in more places 2020-12-24 13:35:12 +01:00
bors 3d9ada686f Auto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnr
passes: prohibit invalid attrs on generic params

Fixes #78957.

This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity.

r? `@lcnr`
2020-12-19 04:32:50 +00:00
Yuki Okushi 3d42c00f0b
Rollup merge of #79877 - bstrie:depinfut, r=oli-obk
Allow `since="TBD"` for rustc_deprecated

Closes #78381.

This PR only affects `#[rustc_deprecated]`, not `#[deprecated]`, so there is no effect on any stable language feature.

Likewise this PR only implements `since="TBD"`, it does not actually tag any library functions with it, so there is no effect on any stable API.

Overview of changes:

* `rustc_middle/stability.rs`:
    * change `deprecation_in_effect` function to return `false` when `since="TBD"`
    * tidy up the compiler output when a deprecated item has `since="TBD"`
* `rustc_passes/stability.rs`:
    * allow `since="TBD"` to pass the sanity check for stable_version < deprecated_version
    * refactor the "invalid stability version" and "invalid deprecation version" error into separate errors
* rustdoc: make `since="TBD"` message on a deprecated item's page match the command-line deprecation output
* tests:
    * test rustdoc output
    * test that the `deprecated_in_future` lint fires when `since="TBD"`
    * test the new "invalid deprecation version" error message
2020-12-17 11:43:57 +09:00
Yuki Okushi 1e1ba7c936
Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasper
Implement if-let match guards

Implements rust-lang/rfcs#2294 (tracking issue: #51114).

I probably should do a few more things before this can be merged:
- [x] Add tests (added basic tests, more advanced tests could be done in the future?)
- [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements)
- [x] Fix clippy

However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs.

Thanks a lot `@matthewjasper` ❤️ for helping me with lowering to MIR! Would you be interested in reviewing this?
r? `@ghost` for now
2020-12-17 11:43:55 +09:00
bstrie 1e1ca28f39 Allow `since="TBD"` for rustc_deprecated 2020-12-16 13:21:24 -05:00
Tyler Mandry b867d13d34
Rollup merge of #79844 - tmiasko:rwu-table-mod, r=lcnr
Move RWUTable to a separate module
2020-12-09 13:38:34 -08:00
Tyler Mandry 9ced8dc0f5
Rollup merge of #79826 - LingMan:match_if, r=lcnr
Simplify visit_{foreign,trait}_item

Using an `if` seems like a better semantic fit and saves a few lines.

Noticed while looking at https://github.com/rust-lang/rust/pull/79752, but that's already merged.
r? `@lcnr,` cc `@cjgillot`

`@rustbot` modify labels +C-cleanup +T-compiler
2020-12-09 13:38:33 -08:00
Tyler Mandry 2cca5e11e0
Rollup merge of #79777 - tmiasko:remove-first-merge, r=lcnr
Remove `first_merge` from liveness debug logs
2020-12-09 13:38:20 -08:00
bors db85512bd8 Auto merge of #79767 - tmiasko:malformed-required-const, r=matthewjasper
Don't ICE on malformed `rustc_args_required_const` attribute
2020-12-09 06:31:49 +00:00
Tomasz Miąsko c7d7bc917d Move RWUTable to a separate module 2020-12-09 00:00:00 +00:00
Tomasz Miąsko d711c3006b Remove `first_merge` from liveness debug logs 2020-12-09 00:00:00 +00:00
bors 1700ca07c6 Auto merge of #79727 - tmiasko:8bit-rwu, r=lcnr
Compress RWU from at least 32 bits to 4 bits

The liveness uses a mixed representation of RWUs based on the
observation that most of them have invalid reader and invalid
writer. The packed variant uses 32 bits and unpacked 96 bits.
Unpacked data contains reader live node and writer live node.

Since live nodes are used only to determine their validity,
RWUs can always be stored in a packed form with four bits for
each: reader bit, writer bit, used bit, and one extra padding
bit to simplify packing and unpacking operations.
2020-12-08 20:58:20 +00:00
LingMan 7654b12112 Simplify visit_{foreign,trait}_item
Using an `if` seems like a better semantic fit and saves a few lines.
2020-12-08 15:56:15 +01:00
bors 5019791e2d Auto merge of #79752 - cjgillot:dead-alien, r=lcnr
Visit ForeignItems when marking dead code

Follow-up to #79318

r? `@lcnr`
2020-12-08 11:16:19 +00:00
Camille GILLOT 37853f925f Visit ForeignItems when marking dead code. 2020-12-08 08:07:55 +01:00
Tomasz Miąsko 8065dabd17 Validate naked functions definitions 2020-12-07 00:00:00 +00:00
Tomasz Miąsko 91fe548825 Retain assembly operands span when lowering AST to HIR 2020-12-06 20:48:08 +01:00
LeSeulArtichaut f3d4aa6afb Implement lowering of if-let guards to MIR 2020-12-06 13:42:24 +01:00
LeSeulArtichaut cfaaa21e2a Implement liveness passes for if-let guards 2020-12-06 11:48:08 +01:00
Tomasz Miąsko 50c6fd6dd5 Don't ICE on malformed `rustc_args_required_const` attribute 2020-12-06 00:00:00 +00:00
Tomasz Miąsko bc8317a12a Compress RWU from at least 32 bits to 4 bits
The liveness uses a mixed representation of RWUs based on the
observation that most of them have invalid reader and invalid
writer. The packed variant uses 32 bits and unpacked 96 bits.
Unpacked data contains reader live node and writer live node.

Since live nodes are used only to determine their validity,
RWUs can always be stored in a packed form with four bits for
each: reader bit, writer bit, used bit, and one extra padding
bit to simplify packing and unpacking operations.
2020-12-06 00:00:00 +00:00
Guillaume Gomez dc10ccfe89 Add checks for #[doc(keyword = "...")] and move them into rustc_passes 2020-12-02 10:42:50 +01:00
Guillaume Gomez 5a228263b8 Clean up doc attributes check before adding more 2020-12-02 10:42:50 +01:00
Guillaume Gomez 63816da5ed Improve some attributes error spans 2020-12-01 16:26:51 +01:00
David Wood 75eb72cc9c
passes: prohibit attrs on generic params
This commit modifies the `check_attr` pass so that attribute placement
on generic parameters is checked for validity.

Signed-off-by: David Wood <david@davidtw.co>
2020-11-29 14:05:19 +00:00
Camille GILLOT 5bd197921a Do not visit ForeignItemRef for HIR indexing and validation.
Similarly to what is done for ImplItemRef and TraitItemRef.

Fixes #79487
2020-11-28 18:08:17 +01:00
Camille GILLOT 12a3024c57 Use visitor for its very purpose. 2020-11-26 21:32:29 +01:00
Camille GILLOT 60c3bbd844 Formatting. 2020-11-26 21:32:29 +01:00
Camille GILLOT 032f68d625 Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
Camille GILLOT 419a9186a4 Store ForeignItem in a side table. 2020-11-26 21:29:27 +01:00
Tomasz Miąsko 22d3431221 Validate use of parameters in naked functions
* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
  of parameters a signature declaration (mirroring existing behaviour
  for function declarations) and avoid generating code introducing
  specified bindings.
2020-11-25 00:00:00 +00:00
Tomasz Miąsko 75e00e8cf4 Validate that `#[naked]` is applied to a function definition 2020-11-24 00:00:00 +00:00
Tomasz Miąsko bdc1d9774b Don't mark #[naked] as used when checking #[track_caller] 2020-11-24 20:45:09 +01:00
Mara Bos 5b3b80a710 Allow #[rustc_diagnostic_item] on macros. 2020-10-18 22:19:13 +02:00
bors b5c37e86ff Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis
RFC-2229: Implement Precise Capture Analysis

### This PR introduces
- Feature gate for RFC-2229 (incomplete) `capture_disjoint_field`
- Rustc Attribute to print out the capture analysis `rustc_capture_analysis`
- Precise capture analysis

### Description of the analysis
1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat)
2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout.
3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list.  Check rust-lang/project-rfc-2229#9 for more detailed examples.
4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing.

### Known issues
- Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression.

### Testing
We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762

### Thanks
This has been slowly in the works for a while now.
I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us.

Closes rust-lang/project-rfc-2229#7
Closes rust-lang/project-rfc-2229#9
Closes rust-lang/project-rfc-2229#6
Closes rust-lang/project-rfc-2229#19

r? `@nikomatsakis`
2020-11-17 03:56:03 +00:00
Jonas Schievink 8825942e86
Rollup merge of #77802 - jyn514:bootstrap-specific, r=nikomatsakis
Allow making `RUSTC_BOOTSTRAP` conditional on the crate name

Motivation: This came up in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Require.20users.20to.20confirm.20they.20know.20RUSTC_.E2.80.A6.20compiler-team.23350/near/208403962) for https://github.com/rust-lang/compiler-team/issues/350.
See also https://github.com/rust-lang/cargo/pull/6608#issuecomment-458546258; this implements https://github.com/rust-lang/cargo/issues/6627.
The goal is for this to eventually allow prohibiting setting `RUSTC_BOOTSTRAP` in build.rs (https://github.com/rust-lang/cargo/issues/7088).

## User-facing changes

- `RUSTC_BOOTSTRAP=1` still works; there is no current plan to remove this.
- Things like `RUSTC_BOOTSTRAP=0` no longer activate nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway.
- `RUSTC_BOOTSTRAP=x` will enable nightly features only for crate `x`.
- `RUSTC_BOOTSTRAP=x,y` will enable nightly features only for crates `x` and `y`.

## Implementation changes

The main change is that `UnstableOptions::from_environment` now requires
an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how.

Other major changes:

- Added `Session::is_nightly_build()`, which uses the `crate_name` of
the session
- Added `nightly_options::match_is_nightly_build`, a convenience method
for looking up `--crate-name` from CLI arguments.
`Session::is_nightly_build()`should be preferred where possible, since
it will take into account `#![crate_name]` (I think).
- Added `unstable_features` to `rustdoc::RenderOptions`

I'm not sure whether this counts as T-compiler or T-lang; _technically_ RUSTC_BOOTSTRAP is an implementation detail, but it's been used so much it seems like this counts as a language change too.

r? `@joshtriplett`
cc `@Mark-Simulacrum` `@hsivonen`
2020-11-15 13:39:43 +01:00
Aman Arora fa381600dc Handle `let _ = x` patterns in closure liveness analysis 2020-11-10 20:58:56 -05:00
Jonas Schievink 105f4b8792
Rollup merge of #78875 - petrochenkov:cleantarg, r=Mark-Simulacrum
rustc_target: Further cleanup use of target options

Follow up to https://github.com/rust-lang/rust/pull/77729.

Implements items 2 and 4 from the list in https://github.com/rust-lang/rust/pull/77729#issue-500228243.

The first commit collapses uses of `target.options.foo` into `target.foo`.

The second commit renames some target options to avoid tautology:
`target.target_endian` -> `target.endian`
`target.target_c_int_width` -> `target.c_int_width`
`target.target_os` -> `target.os`
`target.target_env` -> `target.env`
`target.target_vendor` -> `target.vendor`
`target.target_family` -> `target.os_family`
`target.target_mcount` -> `target.mcount`

r? `@Mark-Simulacrum`
2020-11-10 14:45:21 +01:00
Dylan DPC 8ebca242bc
Rollup merge of #78710 - petrochenkov:macvisit, r=davidtwco
rustc_ast: Do not panic by default when visiting macro calls

Panicking by default made sense when we didn't have HIR or MIR and everything worked on AST, but now all AST visitors run early and majority of them have to deal with macro calls, often by ignoring them.

The second commit renames `visit_mac` to `visit_mac_call`, the corresponding structures were renamed earlier in https://github.com/rust-lang/rust/pull/69589.
2020-11-09 19:06:55 +01:00
Vadim Petrochenkov bf66988aa1 Collapse all uses of `target.options.foo` into `target.foo`
with an eye on merging `TargetOptions` into `Target`.

`TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-08 17:29:13 +03:00
Joshua Nelson 622c48e4f1 Allow making `RUSTC_BOOTSTRAP` conditional on the crate name
The main change is that `UnstableOptions::from_environment` now requires
an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how.

Other major changes:

- Added `Session::is_nightly_build()`, which uses the `crate_name` of
the session
- Added `nightly_options::match_is_nightly_build`, a convenience method
for looking up `--crate-name` from CLI arguments.
`Session::is_nightly_build()`should be preferred where possible, since
it will take into account `#![crate_name]` (I think).
- Added `unstable_features` to `rustdoc::RenderOptions`

  There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no
  longer active nightly features. In practice this shouldn't be a big
  deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone
  uses `RUSTC_BOOTSTRAP=1` anyway.

- Add tests

  Check against `Cheat`, not whether nightly features are allowed.
  Nightly features are always allowed on the nightly channel.

- Only call `is_nightly_build()` once within a function

- Use booleans consistently for rustc_incremental

  Sessions can't be passed through threads, so `read_file` couldn't take a
  session. To be consistent, also take a boolean in `write_file_header`.
2020-11-07 13:45:11 -05:00
Vadim Petrochenkov 90fafc8c8f rustc_ast: `visit_mac` -> `visit_mac_call` 2020-11-03 23:39:51 +03:00
Mara Bos f0112928cb
Rollup merge of #78626 - fusion-engineering-forks:deprecated-trait-impl, r=estebank
Improve errors about #[deprecated] attribute

This change:

1. Turns `#[deprecated]` on a trait impl block into an error, which fixes #78625;
2. Changes these and other errors about `#[deprecated]` to use the span of the attribute instead of the item; and
3. Turns this error into a lint, to make sure it can be capped with `--cap-lints` and doesn't break any existing dependencies.

Can be reviewed per commit.

---
Example:
```rust
struct X;

#[deprecated = "a"]
impl Default for X {
    #[deprecated = "b"]
    fn default() -> Self {
        X
    }
}
```

Before:
```
error: This deprecation annotation is useless
 --> src/main.rs:6:5
  |
6 | /     fn default() -> Self {
7 | |         X
8 | |     }
  | |_____^
```

After:
```
error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:3:1
  |
3 | #[deprecated = "a"]
  | ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
  |
  = note: `#[deny(useless_deprecated)]` on by default

error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:5:5
  |
5 |     #[deprecated = "b"]
  |     ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
```
2020-11-03 19:32:36 +01:00
Vadim Petrochenkov 3237b3886c rustc_ast: Do not panic by default when visiting macro calls 2020-11-03 20:38:20 +03:00
Mara Bos 9c647d1021 Improve deprecation attribute diagnostic messages.
(From the PR feedback.)

Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-11-02 13:21:18 +01:00
Mara Bos 6f1992a7d6 Turn 'useless #[deprecated]' error into a lint. 2020-11-01 20:48:58 +01:00
Mara Bos 706bc33651 Use the right span for errors about #[deprecated] attributes. 2020-11-01 20:48:58 +01:00
Mara Bos 0e2337a5d6 Deny #[deprecated] on trait impl blocks.
They have no effect there, but were silently accepted.
2020-11-01 20:48:58 +01:00
Ryan Levick 69dc98161a Cache foreign_modules query 2020-10-27 16:21:55 +01:00
Yuki Okushi 72e02b015e
Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk
replace `#[allow_internal_unstable]` with `#[rustc_allow_const_fn_unstable]` for `const fn`s

`#[allow_internal_unstable]` is currently used to side-step feature gate and stability checks.
While it was originally only meant to be used only on macros, its use was expanded to `const fn`s.

This pr adds stricter checks for the usage of `#[allow_internal_unstable]` (only on macros) and introduces the `#[rustc_allow_const_fn_unstable]` attribute for usage on `const fn`s.

This pr does not change any of the functionality associated with the use of `#[allow_internal_unstable]` on macros or the usage of `#[rustc_allow_const_fn_unstable]` (instead of `#[allow_internal_unstable]`) on `const fn`s (see https://github.com/rust-lang/rust/issues/69399#issuecomment-712911540).

Note: The check for `#[rustc_allow_const_fn_unstable]` currently only validates that the attribute is used on a function, because I don't know how I would check if the function is a `const fn` at the place of the check. I therefore openend this as a 'draft pull request'.

Closes rust-lang/rust#69399

r? @oli-obk
2020-10-25 18:43:40 +09:00
bors 3e0dd24a6c Auto merge of #77546 - lcnr:impl-trait-closure, r=eddyb
fix def collector for impl trait

fixes #77329

We now consistently make `impl Trait` a hir owner, requiring some special casing for synthetic generic params.

r? `@eddyb`
2020-10-25 07:03:58 +00:00
bors 7bade6ef73 Auto merge of #77015 - davidtwco:check-attr-variant-closure-expr, r=lcnr
passes: `check_attr` on more targets

This PR modifies `check_attr` so that:

- Enum variants are now checked (some attributes would not have been prohibited on variants previously).
- `check_expr_attributes` and `check_stmt_attributes` are removed as `check_attributes` can perform the same checks. This means that codegen attribute errors aren't shown if there are other errors first (e.g. from other attributes, as shown in `src/test/ui/macros/issue-68060.rs` changes below).
2020-10-23 17:32:04 +00:00
Florian Warzecha ac2c599f23
fix validation for rustc_allow_const_fn_unstable targets
The validation was introduced in 3a63bf0299
without strict validation of functions, e. g. all function types were
allowed.
Now the validation only allows `const fn`s.
2020-10-23 17:54:48 +02:00
Yuki Okushi ae95005ecc
Rollup merge of #77976 - oliviacrain:issue-77915-fix, r=matthewjasper
Mark inout asm! operands as used in liveness pass

Variables used in `inout` operands in inline assembly (that is, they're used as both input and output to some arbitrary assembly instruction) are being marked as read and written, but are not marked as being used in the RWU table during the liveness pass. This can result in such expressions triggering an unused variable lint warning. This is incorrect behavior- reads without uses are currently only used for compound assignments. We conservatively assume that an `inout` operand is being read and used in the context of the assembly instruction.

Closes #77915
2020-10-22 09:45:33 +09:00
Florian Warzecha 3a63bf0299
validate rustc_allow_const_fn_unstable targets
Adds a check to make sure `#[rustc_allow_const_fn_unstable]`
can be applied only to functions.
2020-10-22 00:02:26 +02:00
Florian Warzecha 7258740509
validate allow_internal_unstable target
Adds a check to make sure `#[allow_internal_unstable]`
can be applied only to macro definitions.
2020-10-21 22:49:08 +02:00
Florian Warzecha 05f4a9a42a
switch allow_internal_unstable const fns to rustc_allow_const_fn_unstable 2020-10-21 20:54:20 +02:00
Olivia Crain 17c6c5932c Mark InOut operands as used in RWU table with write_place 2020-10-18 23:51:10 -05:00
bors 834821e3b6 Auto merge of #78066 - bugadani:wat, r=jonas-schievink
Clean up small, surprising bits of code

This PR clean up a small number of unrelated, small things I found while browsing the code base.
2020-10-18 13:50:31 +00:00
Dániel Buga 8e548bf8d6 Remove weird slice conversion 2020-10-18 10:31:58 +02:00
Dániel Buga 6f43af26e9 Clean up surprising borrow 2020-10-18 10:31:57 +02:00
Olivia Crain fd193f2d7f Treat InOut variables like other input variables 2020-10-17 16:37:46 -05:00
Olivia Crain cc0b718aaa Mark inout asm! operands as used in liveness pass 2020-10-17 16:37:45 -05:00
bors 6af9846fcc Auto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obk
Implement const expressions and patterns (RFC 2920)

cc `@ecstatic-morse` `@lcnr` `@oli-obk` `@petrochenkov`
2020-10-17 14:44:51 +00:00
Santiago Pastorino fe922e567f
Lower inline const down to MIR 2020-10-16 15:21:18 -03:00
Ralf Jung 6a32e794c2 stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union' 2020-10-16 11:33:33 +02:00
est31 4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
Bastian Kauschke 604bc876e0 implement nits 2020-10-07 10:19:04 +02:00
Bastian Kauschke f865e3d22f bodge 2020-10-07 10:19:04 +02:00
Guillaume Gomez 11f3476c59 Enforce whitespace ascii character check for doc alias 2020-10-06 14:29:42 +02:00
Guillaume Gomez a215151cd3 Allow ascii whitespace char for doc aliases 2020-10-05 16:37:13 +02:00
Dylan DPC e6e7ccc28d
Rollup merge of #76329 - GuillaumeGomez:doc-alias-crate-level, r=matthewjasper
Add check for doc alias attribute at crate level

Fixes #76298, #64734, #69365.

r? @ollie27
2020-10-05 02:29:27 +02:00
Guillaume Gomez 3641a37455 Enforce crate level attributes checks 2020-10-04 13:36:47 +02:00