Commit graph

260 commits

Author SHA1 Message Date
Joshua Nelson
2bc5a0a600 Make Clean take &mut DocContext
- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics`
- Take `&mut DocContext` in most of `clean`
- Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad.
- Changes `fn sess` to properly return a borrow with the lifetime of `'tcx`, not the mutable borrow.
2021-02-16 21:25:14 -05:00
Jonas Schievink
f02f7b05b2
Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank
Suggest to create a new `const` item if the `fn` in the array is a `const fn`

Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary.

Example:

```rust
fn main() {
    // Should not compile but hint to create a new const item (stable) or an inline const block (nightly)
    let strings: [String; 5] = [String::new(); 5];
    println!("{:?}", strings);
}

```

Gives this error:

```
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
 --> $DIR/const-fn-in-vec.rs:3:32
  |
2 |     let strings: [String; 5] = [String::new(); 5];
  |                             ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String`
  |
  = note: the `Copy` trait is required because the repeated element will be copied
```

With this change, this is the error message:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:3:32
   |
LL |     let strings: [String; 5] = [String::new(); 5];
   |                                ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
   = help: moving the function call to a new `const` item will resolve the error
```
2021-02-15 16:06:47 +01:00
Dylan DPC
c8dacf95ae
Rollup merge of #82029 - tmiasko:debug, r=matthewjasper
Use debug log level for developer oriented logs

The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-14 16:54:52 +01:00
klensy
93c8ebe022 bumped smallvec deps 2021-02-14 18:03:11 +03:00
Henry Boisdequin
64fe2c183d update message 2021-02-14 10:08:37 +05:30
Tomasz Miąsko
361dcd5ca7 Use debug log level for developer oriented logs
The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-13 00:00:00 +00:00
bors
3f5aee2d52 Auto merge of #81744 - rylev:overlapping-early-exit2, r=lcnr
Try fast_reject::simplify_type in coherence before doing full check

This is a reattempt at landing #69010 (by `@jonas-schievink).` The change adds a fast path for coherence checking to see if there's no way for types to unify since full coherence checking can be somewhat expensive.

This has big effects on code generated by the [`windows`](https://github.com/microsoft/windows-rs) which in some cases spends as much as 20% of compilation time in the `specialization_graph_of` query. In local benchmarks this took a compilation that previously took ~500 seconds down to ~380 seconds.

This is surely not going to make a difference on much smaller crates, so the question is whether it will have a negative impact. #69010 was closed because some of the perf suite crates did show small regressions.

Additional discussion of this issue is happening [here](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/windows-rs.20perf).
2021-02-12 17:38:15 +00:00
Ryan Levick
0cc35f54e8 Don't check self type twice 2021-02-12 17:37:32 +01:00
Ryan Levick
bc5f4c4860 Switch boolean checks 2021-02-12 17:22:19 +01:00
Ryan Levick
8ea0973725 Short circuit full corherence check when dealing with types with different reference mutability 2021-02-12 14:04:09 +01:00
Yuki Okushi
46aef0e375
Rollup merge of #81990 - matsujika:suggest-mut-reference, r=estebank
Make suggestion of changing mutability of arguments broader

Fix #81421

Previously rustc tries to emit the suggestion of changing mutablity unless `!trait_ref.has_infer_types_or_consts() && self.predicate_can_apply(obligation.param_env, trait_ref)` and this led to some false negatives to occur.
2021-02-12 19:32:14 +09:00
bors
26e5bcd220 Auto merge of #81350 - tmiasko:instrument-debug, r=lcnr
Reduce log level used by tracing instrumentation from info to debug

Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`;  one use was novel).
2021-02-11 13:44:00 +00:00
Hirochika Matsumoto
e03f09730f Make suggestion of changing mutability of arguments broader 2021-02-11 17:03:03 +09:00
Dylan DPC
44e526b2c3
Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis
Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of #79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in #80648 and #79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of #79209 which was already approved.

This also could be considered part or the actual fix of #79560 but I guess for that to be closed and fixed completely we would need to land #80648 and #79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`
2021-02-09 02:39:50 +01:00
Jonas Schievink
96e843ce6a
Rollup merge of #81738 - camelid:misc-small-diag-cleanup, r=lcnr
Miscellaneous small diagnostics cleanup
2021-02-06 17:01:49 +01:00
Santiago Pastorino
7aa602b84c
Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum"
This reverts commit b4def89d76, reversing
changes made to 7dc1e852d4.
2021-02-05 18:56:56 -03:00
Mara Bos
676ff77fb7
Rollup merge of #80726 - lcnr:unsize-query, r=oli-obk
relax adt unsizing requirements

Changes unsizing of structs in case the last struct field shares generic params with other adt fields which do not change.
This change is currently insta stable and changes the language, so it at least requires a lang fcp. I feel like the current state is fairly unintuitive.

An example for what's now allowed would be https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6dd331d23f5c9ffc8c978175aae2e967
```rust
struct A<T, U: ?Sized>(T, B<T, U>); // previously ERR
// struct A<T, U: ?Sized>(T, B<[u32; 1], U>); // ok
struct B<T, U: ?Sized>(T, U);

fn main() {
    let x = A([0; 1], B([0; 1], [0; 1]));
    let y: &A<[u32; 1], [u32]> = &x;
    assert_eq!(y.1.1.len(), 1);
}
```
2021-02-05 12:25:52 +01:00
b-naber
9e920151a3 remove subst_supertrait call 2021-02-04 21:37:23 +01:00
Ryan Levick
cdfc52fbd6 Try fast_reject::simplify_type in coherence before doing full check
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Ryan Levick <me@ryanlevick.com>
2021-02-04 10:45:17 +01:00
Camelid
253a970c3d Miscellaneous small diagnostics cleanup 2021-02-03 22:09:37 -08:00
Bastian Kauschke
031cce8cfc add relaxed_struct_unsize feature gate 2021-02-04 00:00:41 +01:00
Bastian Kauschke
50e394a05e relax adt unsizing requirements 2021-02-04 00:00:28 +01:00
Henry Boisdequin
c2e849c022 added a suggestion to create a const item if the fn in the array repeat expression is a const fn 2021-02-03 10:18:08 +05:30
Jack Huey
3aed8b17a8
Rollup merge of #81544 - JulianKnodt:sat_where, r=lcnr
Add better diagnostic for unbounded Abst. Const

~~In the case where a generic abst. const requires a trivial where bound: `where TypeWithConst<const_fn(N)>: ,`,
instead of requiring a where bound, just check that only consts are being substituted in to skip over where check.~~

~~This is pretty sketchy, but I think it works. Presumably, if there is checking for type bounds added later, it can first check nested requirements, and see if they're satisfied by the current `ParamEnv`.~~

Changed the diagnostic to add a better example, which is more practical than what was previously proposed.

r? ```@lcnr```
2021-02-02 16:01:39 -05:00
kadmin
65256717f2 Add better diagnostic for missing where clause
Previously, it's not clear what exactly should be added in the suggested where clause,
so this adds an example to demonstrate.
2021-02-02 17:01:53 +00:00
bors
b81f5811f9 Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
Bump rustfmt version
2021-02-02 14:52:53 +00:00
Mark Rousskov
d5b760ba62 Bump rustfmt version
Also switches on formatting of the mir build module
2021-02-02 09:09:52 -05:00
Ellen
7f8530f16b more things are const evaluatable *sparkles* 2021-02-01 20:05:50 +00:00
Jonas Schievink
21d0e9b8dc
Rollup merge of #79291 - JulianKnodt:ce_priv, r=petrochenkov
Add error message for private fn

Attempts to add a more detailed error when a `const_evaluatable` fn from another scope is used inside of a scope which cannot access it.

r? ````@lcnr````
2021-02-01 14:29:29 +01:00
kadmin
6a03f0350d Add error message for private fn
Bless tests

Update with changes from comments
2021-01-31 20:45:13 +00:00
Jonas Schievink
99f2f5a830
Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obk
Remove const_in_array_repeat

Fixes #80371. Fixes #81315. Fixes #80767. Fixes #75682.

I thought there might be some issue with `Repeats(_, 0)`, but if you increase the items in the array it still ICEs. I'm not sure if this is the best fix but it does fix the given issue.
2021-01-31 16:36:42 +01:00
Jonas Schievink
1e99f26894
Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se
Stabilize by-value `[T; N]` iterator `core::array::IntoIter`

Tracking issue: https://github.com/rust-lang/rust/issues/65798

This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135.

This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2021-01-31 01:47:25 +01:00
kadmin
6946534d84 Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
bors
c0b64d97be Auto merge of #81055 - matthewjasper:non-fatal-overflow, r=nikomatsakis
Make hitting the recursion limit in projection non-fatal

This change was originally made in #80246 to avoid future (effectively) infinite loop bugs in projections,
but wundergraph relies on rustc recovering here.

cc #80953

r? `@nikomatsakis`
2021-01-28 18:57:10 +00:00
Yuki Okushi
f183e5f04c
Rollup merge of #81426 - BoxyUwU:boxychangesv2, r=oli-obk
const_evaluatable: expand abstract consts in try_unify

See this [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/combining.20const.20bounds) for more info

cc ```@lcnr```
r? ```@oli-obk```
2021-01-28 15:09:15 +09:00
Ellen
f4261772d8 comments 2021-01-27 14:46:43 +00:00
Ellen
b0625eb712 boop, ur abstract consts are now expanded 2021-01-27 02:46:19 +00:00
Yuki Okushi
d68570c78f
Rollup merge of #81407 - osa1:issue81098, r=estebank
Refine "remove semicolon" suggestion in trait selection

Don't suggest it if the last statement doesn't have a semicolon

Fixes #81098

See also #54771 for why this suggestion was added
2021-01-27 04:43:35 +09:00
Ömer Sinan Ağacan
8ddc1c83f2 Refine "remove semicolon" suggestion in trait selection
Don't suggest it if the last statement doesn't have a semicolon

Fixes #81098

See also #54771 for why this suggestion was added
2021-01-26 13:23:30 +03:00
Esteban Küber
088c89d9ff Account for generics when suggesting bound
Fix #81175.
2021-01-24 23:16:50 -08:00
Tomasz Miąsko
59457ab86e Reduce log level used by tracing instrumentation from info to debug 2021-01-24 00:00:00 +00:00
Daiki Ihara
db95b5ca9b Add suggestion for impl_candidates with E0283
Update compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-01-18 21:57:15 +09:00
bors
4253153db2 Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`
2021-01-17 20:49:11 +00:00
Mara Bos
19f97802ca
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```
2021-01-17 12:24:44 +00:00
Jack Huey
3dea68de1d Review changes 2021-01-16 18:56:37 -05:00
Jack Huey
e76476afe4 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey
4cd6f85a07 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey
4cb3d6f983 Intermediate formatting and such 2021-01-16 18:40:47 -05:00
Jack Huey
8278314a8b Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
Matthew Jasper
5db5d8f87e Make hitting the recursion limit in projection non-fatal
This is relied on by wundergraph.
2021-01-15 20:45:38 +00:00