Commit Graph

253 Commits

Author SHA1 Message Date
bors 9863bf51a5 Auto merge of #87875 - asquared31415:generic-lang-items, r=cjgillot
Improve detection of generics on lang items

Adds detection for the required generics for all lang items.  Many lang items require an exact or minimum amount of generic arguments and if they don't exist, the compiler will ICE.  This does not add any additional validation about bounds on generics or any other lang item restrictions.

Fixes one of the ICEs in #87573

cc `@FabianWolff`
2021-08-25 08:12:16 +00:00
asquared31415 385a233f18 Detect incorrect number of lang item generics 2021-08-23 10:15:25 -04:00
Frank Steffahn 2f9ddf3bc7 Fix typos “an”→“a” and a few different ones that appeared in the same search 2021-08-22 18:15:49 +02:00
Frank Steffahn bf88b113ea Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
Caio 6aa9937a76 Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
Deadbeef 1fa712d0ba Make assoc types work with ?const opt=out 2021-08-13 09:28:52 +00:00
Deadbeef 6b6ad781f8 Fix call-generic-method-nonconst test 2021-08-13 09:28:51 +00:00
Deadbeef 32390a0df6 move Constness into TraitPredicate 2021-08-13 09:26:33 +00:00
bors 7129033b42 Auto merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment, r=Mark-Simulacrum
Ignore comments in tidy-filelength

Ref https://github.com/rust-lang/rust/issues/60302#issuecomment-652402127
2021-08-06 02:07:01 +00:00
bors b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
bors aadd6189ad Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
more clippy::complexity fixes

(also a couple of clippy::perf fixes)
2021-08-01 09:15:15 +00:00
Esteban Küber 15a40c7ee8 Do not discard ?Sized type params and suggest their removal 2021-07-30 08:44:31 -07:00
Jade 3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Mara Bos f827d3e285 Make const panic!("..") work in Rust 2021.
During const eval, this replaces calls to core::panicking::panic_fmt and
std::panicking::being_panic_fmt with a call to a new const fn:
core::panicking::const_panic_fmt. That function uses
fmt::Arguments::as_str() to get the str and calls panic_str with that
instead.

panic!() invocations with formatting arguments are still not accepted,
as the creation of such a fmt::Arguments cannot be done in constant
functions right now.
2021-07-28 16:10:41 +02:00
bors fd853c00e2 Auto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnr
Add hir::GenericArg::Infer

In order to extend inference to consts, make an Infer type on hir::GenericArg.
2021-07-27 16:24:45 +00:00
kadmin 8759f00c73 Actually infer args in visitors 2021-07-26 21:15:18 +00:00
ibraheemdev 3171bd5bf5 ignore comments in tidy-filelength 2021-07-25 17:10:51 -04:00
bors 6489ee1041 Auto merge of #83723 - cjgillot:ownernode, r=petrochenkov
Store all HIR owners in the same container

This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem.
This should allow for a more compact storage.

Based on https://github.com/rust-lang/rust/pull/83114
2021-07-25 11:11:02 +00:00
Matthias Krüger 053aedce2c clippy::filter_map_identity 2021-07-25 12:26:03 +02:00
Camille GILLOT fee421685d Introduce OwnerNode::Crate. 2021-07-25 12:22:47 +02:00
Camille GILLOT 36a28060f1 Merge the BTreeMap in hir::Crate. 2021-07-25 12:18:56 +02:00
kadmin 3605675bb1 Add inferred args to typeck 2021-07-25 07:28:51 +00:00
kadmin 417b098cfc Add generic arg infer 2021-07-25 07:28:51 +00:00
bors d9aa287672 Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakis
dont provide fwd declared params to cg defaults

Fixes #83938

```rust
#![feature(const_evaluatable_checked, const_generics, const_generics_defaults)]
#![allow(incomplete_features)]

pub struct Bar<const N: usize, const M: usize = { N + 1 }>;
pub fn foo<const N1: usize>() -> Bar<N1> { loop {} }

fn main() {}
```
This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for `Bar<N1>` we would subst the anon ct: `ConstKind::Unevaluated({N + 1}, substs: [N, M])` with substs of `[N1]`. the anon const has forward declared params supplied though so we end up trying to substitute the provided `M` param which causes the ICE.

This PR doesn't handle the predicates of the const so
```rust
trait Foo<const N: usize> { const Assoc: usize; }
pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>;
```
Resolves to `<() as Foo<N>>::Assoc` which can allow for using fwd declared params indirectly.

```rust
trait Foo<const N: usize> {}
struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>;
```
This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params

PR was briefly discussed [in this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/evil.20preds.20in.20param.20env.20.2386580)
2021-07-24 20:01:51 +00:00
Ellen d1e5e72f7d change doc comment 2021-07-24 17:32:11 +01:00
Guillaume Gomez 1008ace95c Rollup merge of #87273 - fee1-dead:impl-const-impl-bounds, r=oli-obk
Recognize bounds on impls as const bounds

r? ```@oli-obk```
2021-07-21 15:52:47 +02:00
Deadbeef 4b82bbeac0 Recognize bounds on impls as const bounds 2021-07-19 19:51:44 +08:00
Santiago Pastorino 5cefdbdab5 Use == to compare OpaqueTyOrigin values 2021-07-18 09:30:10 -03:00
Santiago Pastorino 000b945cea Remove OpaqueTyOrigin::Misc, use TyAlias instead 2021-07-18 09:30:10 -03:00
Santiago Pastorino 66c9cd9e66 Remove OpaqueTyOrigin::Binding 2021-07-17 23:14:22 -03:00
Cameron Steffen 1537cd4fb1 Remove refs from pat slices 2021-07-15 16:09:57 -05:00
Ellen 8c40360ed4 Put checking if anonct is a default into a method on hir map 2021-07-13 17:23:51 +01: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
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
Camille GILLOT 071a047dc7 Make resolutions a query. 2021-07-06 19:22:27 +02:00
bors d04ec47358 Auto merge of #86143 - bjorn3:revert_revert_merge_crate_disambiguator, r=michaelwoerister
Reland "Merge CrateDisambiguator into StableCrateId"

Reverts https://github.com/rust-lang/rust/pull/85891 as this revert of #85804 made perf even worse.

r? `@Mark-Simulacrum`
2021-07-06 11:31:59 +00:00
bjorn3 96d3bd467d Revert "Revert "Fix test""
This reverts commit 6c5b6985fd.
2021-07-06 11:28:06 +02:00
bjorn3 489ad8b8b5 Revert "Revert "Merge CrateDisambiguator into StableCrateId""
This reverts commit 8176ab8bc1.
2021-07-06 11:28:04 +02:00
Camille GILLOT 3162c37b59 Store macro parent module in ExpnData. 2021-07-06 08:07:06 +02:00
Roxane Fruytier 3e569dd2df Remove lang items Send, UnwindSafe and RefUnwindSafe 2021-06-29 17:47:57 -04:00
Mark Rousskov 06661ba759 Update to new bootstrap compiler 2021-06-28 11:30:49 -04:00
Dylan DPC af9e5d1a14 Rollup merge of #86223 - fee1-dead:better-E0121, r=petrochenkov
Specify the kind of the item for E0121

Fixes #86005
2021-06-23 00:20:18 +02:00
bors 4573a4a879 Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3
Add MIR pass to lower call to `core::slice::len` into `Len` operand

During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator.

It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how.

Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
2021-06-21 22:24:13 +00:00
Deadbeef 200fdaac77 Specify the kind of the item for E0121 2021-06-22 00:40:47 +08:00
Alex Vlasov aa53928ed7 Squashed implementation of the pass 2021-06-20 16:09:42 +02:00
bors 312b894cc1 Auto merge of #85421 - Smittyvb:rm_pushpop_unsafe, r=matthewjasper
Remove some last remants of {push,pop}_unsafe!

These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-18 14:17:53 +00:00
Camille GILLOT a7a50b0c0a Hash DefId in rustc_span. 2021-06-11 12:25:02 +02:00
Camille GILLOT aeb050da9f Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
bjorn3 8176ab8bc1 Revert "Merge CrateDisambiguator into StableCrateId"
This reverts commit d0ec85d3fb.
2021-06-07 10:37:45 +02:00
bjorn3 6c5b6985fd Revert "Fix test"
This reverts commit 3abdebe79d.
2021-06-07 10:25:32 +02:00