Commit Graph

307 Commits

Author SHA1 Message Date
bors
394804bb23 Auto merge of #86857 - fee1-dead:add-attr, r=oli-obk
Add #[default_method_body_is_const]

`@rustbot` label F-const_trait_impl
2021-07-13 06:59:34 +00:00
bors
955b9c0d4c Auto merge of #86320 - hi-rustin:rustin-patch-fix-span, r=estebank
shrinking the deprecated span

ref: https://github.com/rust-lang/rust/pull/85617#issuecomment-854947988

part of #85403

r? `@estebank`

The reason is that if we use method_span directly, it will cause the in_derive_expansion judgment to fail.
2021-07-12 20:43:28 +00:00
bors
72568552fd Auto merge of #85941 - cjgillot:qresolve, r=Aaron1011
Reduce the amount of untracked state in TyCtxt -- Take 2

Main part of #85153

The offending line (https://github.com/rust-lang/rust/pull/85153#discussion_r642866298) is replaced by a FIXME until the possible bug and the perf concern are both resolved.

r? `@Aaron1011`
2021-07-11 16:09:17 +00:00
Deadbeef
032cbe4cce
Check if the attribute is applied correctly 2021-07-10 20:54:48 +08:00
Deadbeef
3660a4e972
Applied suggestions 2021-07-10 20:54:47 +08:00
Deadbeef
2db927d8d8
Add #[default_method_body_is_const] 2021-07-10 20:54:44 +08:00
Guillaume Gomez
d85718ad01
Rollup merge of #86838 - lambinoo:I-69630-rust_const_unstable_check_const, r=oli-obk
Checking that function is const if marked with rustc_const_unstable

Fixes #69630

This one is still missing tests to check the behavior but I checked by hand and it seemed to work.
I would not mind some direction for writing those unit tests!
2021-07-08 18:30:34 +02:00
Guillaume Gomez
d12b16887b
Rollup merge of #86726 - sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis
Use diagnostic items instead of lang items for rfc2229 migrations

This PR removes the `Send`, `UnwindSafe` and `RefUnwindSafe` lang items introduced in https://github.com/rust-lang/rust/pull/84730, and uses diagnostic items instead to check for `Send`, `UnwindSafe` and `RefUnwindSafe` traits for RFC2229 migrations.

r? ```@nikomatsakis```
2021-07-08 18:30:33 +02:00
Lamb
07f903e0e0 fn must be const if marked with stability attribut
remove trailing newline

fix: test with attribute but missing const

Update compiler/rustc_passes/src/stability.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>

Add test for extern functions

fix: using span_help instead of span_suggestion

add test for some ABIs + fmt fix

Update compiler/rustc_passes/src/stability.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>

Refractor and add test for `impl const`

Add test to make sure no output + cleanup condition

-----------------------------

remove stdcall test, failing CI test

C abi is already tested in this, so it is not that useful to test another one.
The tested code is blind to which specific ABI for now, as long as it's not an intrinsic one
2021-07-08 07:52:05 +02:00
Camille GILLOT
071a047dc7 Make resolutions a query. 2021-07-06 19:22:27 +02:00
bors
701496384f Auto merge of #86571 - fee1-dead:const-trait-impl-fix, r=jackh726
deny using default function in impl const Trait

Fixes #79450.

I don't know if my implementation is correct:

 - The check is in `rustc_passes::check_const`, should I put it somewhere else instead?
 - Is my approach (to checking the impl) optimal? It works for the current tests, but it might have some issues or there might be a better way of doing this.
2021-07-03 07:24:24 +00:00
bors
7100b311df Auto merge of #86749 - bjorn3:link_info_refactor_part1, r=petrochenkov
Rename all_crate_nums query to crates and remove useless wrapper

Split out of https://github.com/rust-lang/rust/pull/86105

r? `@petrochenkov`
2021-07-01 19:00:08 +00:00
bjorn3
c7d2099de0 Rename all_crate_nums query to crates and remove useless wrapper 2021-07-01 16:51:11 +02:00
bors
f8ac8fdacf Auto merge of #86190 - asquared31415:extern-main-86110-fix, r=varkor
Fix ICE when `main` is declared in an `extern` block

Changes in #84401 to implement `imported_main` changed how the crate entry point is found, and a declared `main` in an `extern` block was detected erroneously.  This was causing the ICE described in #86110.

This PR adds a check for this case and emits an error instead.  Previously a `main` declaration in an `extern` block was not detected as an entry point at all, so emitting an error shouldn't break anything that worked previously.  In 1.52.1 stable this is demonstrated, with a `` `main` function not found`` error.

Fixes #86110
2021-07-01 06:39:37 +00:00
bors
1034282bca Auto merge of #86617 - joshtriplett:prune-dependencies, r=Mark-Simulacrum
Remove unused dependencies from compiler crates

Various compiler crates have dependencies that they don't appear to use. I used some scripting to detect such dependencies, filtered them based on some manual review, and removed those that do indeed appear to be entirely unused.
2021-07-01 03:49:47 +00:00
Deadbeef
5e178b29b4
Do the check even when the feature is not enabled 2021-07-01 11:29:49 +08:00
Roxane Fruytier
3e569dd2df Remove lang items Send, UnwindSafe and RefUnwindSafe 2021-06-29 17:47:57 -04:00
Fabian Wolff
499afcdfcf Check that #[cmse_nonsecure_entry] is applied to a function definition 2021-06-25 17:49:41 +02:00
Josh Triplett
f7460121dc rustc_passes: Remove unused dependency rustc_trait_selection
Unused since commit 6a32e794c2
("stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union'").
2021-06-25 01:12:59 -07:00
Deadbeef
22a8d46ed3
deny using default function in impl const Trait 2021-06-23 19:21:57 +08:00
Fabian Wolff
2cedd86b1c Fix ICE when using #[doc(keyword = "...")] on non-items 2021-06-17 16:45:26 +02:00
Ryan Levick
5f74ba50bc Fix ICE when doc aliases were put on function params 2021-06-15 19:01:11 +02:00
hi-rustin
8c5938d049 Use last segment 2021-06-15 19:35:03 +08:00
hi-rustin
636d872452 shrinking the deprecated method span 2021-06-15 16:21:58 +08:00
LeSeulArtichaut
e3ca81fd5a Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
asquared31415
9b2ba6d1a1 Fix ICE when main is declared in an extern block 2021-06-09 23:14:02 -04:00
Yuki Okushi
19433c44bd
Rollup merge of #86047 - jyn514:doc-attrs, r=petrochenkov
Don't fire `invalid_doc_attributes` on `extern crate` items

Fixes https://github.com/rust-lang/rust/issues/86046.
2021-06-06 19:11:24 +09:00
Joshua Nelson
b8ebf4431e Don't fire invalid_doc_attributes on extern crate items 2021-06-05 21:18:20 -04:00
bors
5ea19239d9 Auto merge of #86001 - richkadel:revert-85617-rustin-patch-fix, r=Mark-Simulacrum
Revert "shrinking the deprecated method span"

Reverts rust-lang/rust#85617

Fixes: #86000

r? `@Mark-Simulacrum`
2021-06-05 11:12:57 +00:00
Rich Kadel
2a6dd25265
Revert "shrinking the deprecated method span" 2021-06-04 12:26:36 -07:00
Joshua Nelson
15fec1fb80 Remove doc(include) 2021-06-04 08:05:54 -04:00
Yuki Okushi
36f1ed6de2
Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514
Remove unused feature gates

The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`)

The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though.

The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-04 13:42:54 +09:00
bors
cc77ba46fc Auto merge of #85617 - hi-rustin:rustin-patch-fix, r=estebank
shrinking the deprecated method span

part of https://github.com/rust-lang/rust/issues/85403

r? `@estebank`
2021-06-03 20:06:35 +00:00
hi-rustin
957e2effc3 Address comment 2021-06-02 23:10:55 +08:00
Camille Gillot
0f0f3138cb
Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
bjorn3
312f964478 Remove unused feature gates 2021-05-31 13:55:43 +02:00
Camille GILLOT
5d9f96ab27 Make resolutions a query. 2021-05-30 19:47:00 +02:00
Jacob Pratt
bc2f0fb5a9
Specialize implementations
Implementations in stdlib are now optimized as they were before.
2021-05-26 18:07:09 -04:00
hi-rustin
c180af8e30 Address comment 2021-05-25 00:33:41 +08:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
hi-rustin
3efe0174a2 shrinking the deprecated method span 2021-05-24 11:41:39 +08:00
Guillaume Gomez
1bfd987f69
Rollup merge of #85339 - FabianWolff:issue-83893, r=varkor
Report an error if a lang item has the wrong number of generic arguments

This pull request fixes #83893. The issue is that the lang item code currently checks whether the lang item has the correct item kind (e.g. a `#[lang="add"]` has to be a trait), but not whether the item has the correct number of generic arguments.

This can lead to an "index out of bounds" ICE when the compiler tries to create more substitutions than there are suitable types available (if the lang item was declared with too many generic arguments).

For instance, here is a reduced ("reduced" in the sense that it does not trigger additional errors) version of the example given in #83893:
```rust
#![feature(lang_items,no_core)]
#![no_core]
#![crate_type="lib"]

#[lang = "sized"]
trait MySized {}

#[lang = "add"]
trait MyAdd<'a, T> {}

fn ice() {
    let r = 5;
    let a = 6;
    r + a
}
```
On current nightly, this immediately causes an ICE without any warnings or errors emitted. With the changes in this PR, however, I get no ICE and two errors:
```
error[E0718]: `add` language item must be applied to a trait with 1 generic argument
 --> pr-ex.rs:8:1
  |
8 | #[lang = "add"]
  | ^^^^^^^^^^^^^^^
9 | trait MyAdd<'a, T> {}
  |            ------- this trait has 2 generic arguments, not 1

error[E0369]: cannot add `{integer}` to `{integer}`
  --> pr-ex.rs:14:7
   |
14 |     r + a
   |     - ^ - {integer}
   |     |
   |     {integer}

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0369, E0718.
For more information about an error, try `rustc --explain E0369`.
```
2021-05-18 14:08:51 +02:00
Fabian Wolff
7b301985fa Two minor changes for readability and efficiency 2021-05-17 13:58:14 +02:00
bors
3396a383bb Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate

The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea.

Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-17 01:42:03 +00:00
bors
7dc9ff5c62 Auto merge of #85290 - Amanieu:asm_const_int, r=nagisa
Remove support for floating-point constants in asm!

Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.

cc `@rust-lang/wg-inline-asm`

r? `@nagisa`
2021-05-16 17:52:52 +00:00
Fabian Wolff
4efa4a5273 Implement changes suggested by varkor 2021-05-16 18:22:34 +02:00
bors
f8e1e92380 Auto merge of #84549 - tmiasko:static-initializer, r=varkor
Reachable statics have reachable initializers

Static initializer can read other statics. Initializers are evaluated at
compile time, and so their content could become inlined into another
crate. Ensure that initializers of reachable statics are also reachable.

Previously, when an item incorrectly considered to be unreachable was
reached from another crate an attempt would be made to codegen it. The
attempt could fail with an ICE (in the case MIR wasn't available to do
so) in some circumstances the attempt could also succeed resulting in
a local codegen of non-local items, including static ones.

Fixes #84455.
2021-05-16 15:11:48 +00:00
Fabian Wolff
7217d767b2 Report an error if a lang item has the wrong number of generic arguments 2021-05-15 19:53:16 +02:00
Fabian Wolff
46d55d6549 Warn about unused pub fields in non-pub structs 2021-05-15 13:06:17 +02:00
Amanieu d'Antras
f1b11939e2 Remove support for floating-point constants in asm!
Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.
2021-05-14 14:58:21 +01:00