Commit graph

390 commits

Author SHA1 Message Date
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
Aman Arora
8ef5212eff Make type_implements_trait not a query 2021-07-06 14:38:10 -04:00
bors
969a6c2481 Auto merge of #86674 - Aaron1011:new-querify-limits, r=michaelwoerister
Query-ify global limit attribute handling

Currently, we read various 'global limits' from inner attributes the crate root (`recursion_limit`, `move_size_limit`, `type_length_limit`, `const_eval_limit`). These limits are then stored in `Sessions`, allowing them to be access from a `TyCtxt` without registering a dependency on the crate root attributes.

This PR moves the calculation of these global limits behind queries, so that we properly track dependencies on crate root attributes. During the setup of macro expansion (before we've created a `TyCtxt`), we need to access the recursion limit, which is now done by directly calling into the code shared by the normal query implementations.
2021-07-05 16:30:53 +00:00
Aaron Hill
7e5a88a56c
Combine individual limit queries into single limits query 2021-07-04 13:02:51 -05:00
bors
23c652dfe3 Auto merge of #86866 - nikomatsakis:issue-84841, r=oli-obk
Hack: Ignore inference variables in certain queries

Fixes #84841
Fixes #86753

Some queries are not built to accept types with inference variables, which can lead to ICEs. These queries probably ought to be converted to canonical form, but as a quick workaround, we can return conservative results in the case that inference variables are found.

We should file a follow-up issue (and update the FIXMEs...) to do the proper refactoring.

cc `@arora-aman`

r? `@oli-obk`
2021-07-04 17:39:37 +00:00
Aaron Hill
ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Niko Matsakis
63fbefd359 tag issues with FIXME 2021-07-04 12:50:28 -04:00
Niko Matsakis
40ee019c17 allow inference vars in type_implements_trait 2021-07-04 11:28:20 -04:00
bors
d34a3a401b Auto merge of #85090 - Aaron1011:type-outlives-global, r=matthewjasper,jackh726
Return `EvaluatedToOk` when type in outlives predicate is global

A global type doesn't reference any local regions or types, so it's
guaranteed to outlive any region.
2021-07-03 22:42:58 +00:00
Yuki Okushi
884053a4b4
Remove ty::Binder::bind()
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2021-07-03 01:12:32 +09:00
Roxane
cc3af7091c Rename variable 2021-06-29 20:26:37 -04:00
Aaron Hill
1f7cb16fce
Return EvaluatedToOk when type in outlives predicate is global
A global type doesn't reference any local regions or types, so it's
guaranteed to outlive any region.
2021-06-29 19:21:13 -05:00
Roxane Fruytier
06afafd492 Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traits 2021-06-29 17:47:57 -04:00
bors
8cb207ae69 Auto merge of #86386 - inquisitivecrystal:better-errors-for-display-traits-v3, r=estebank
Better errors for Debug and Display traits

Currently, if someone tries to pass value that does not implement `Debug` or `Display` to a formatting macro, they get a very verbose and confusing error message. This PR changes the error messages for missing `Debug` and `Display` impls to be less overwhelming in this case, as suggested by #85844. I was a little less aggressive in changing the error message than that issue proposed. Still, this implementation would be enough to reduce the number of messages to be much more manageable.

After this PR, information on the cause of an error involving a `Debug` or `Display` implementation would suppressed if the requirement originated within a standard library macro. My reasoning was that errors originating from within a macro are confusing when they mention details that the programmer can't see, and this is particularly problematic for `Debug` and `Display`, which are most often used via macros. It is possible that either a broader or a narrower criterion would be better. I'm quite open to any feedback.

Fixes #85844.
2021-06-23 03:16:04 +00:00
Niko Matsakis
f6adaedd9b add various coments to explain how the code works 2021-06-18 11:44:56 -04:00
Aris Merchant
f1f1c9b25b Improve errors for missing Debug and Display impls 2021-06-16 01:13:28 -07:00
Charles Lew
a86d3a7e45 Refactor to make interpreter and codegen backend neutral to vtable internal representation. 2021-06-15 01:59:00 +08:00
bors
d59b80d588 Auto merge of #86130 - BoxyUwU:abstract_const_as_cast, r=oli-obk
const_eval_checked: Support as casts in abstract consts
2021-06-12 08:50:22 +00:00
Ellen
17cd79090e support as _ and add tests 2021-06-10 14:53:44 +01:00
Ellen
c318364d48 Add more tests + visit_ty in some places 2021-06-09 19:28:41 +01:00
Ellen
8e7299dfcd Support as casts in abstract consts 2021-06-08 08:02:16 +01:00
Santiago Pastorino
9e547b4464
Differentiate different defining uses of taits when they reference distinct generic parameters 2021-06-07 19:10:12 -03:00
Santiago Pastorino
e386373514
Remove substs from OpaqueTypeDecl, use the one in OpaqueTypeKey 2021-06-07 19:09:32 -03:00
Santiago Pastorino
5dabd55d7d
Use substs from opaque type key instead of using it from opaque_decl 2021-06-07 19:08:43 -03:00
Santiago Pastorino
37ab718350
Make opaque type map key be of type OpaqueTypeKey 2021-06-07 19:07:24 -03:00
Santiago Pastorino
7f8cad2019
Make OpaqueTypeKey the key of opaque types map 2021-06-07 19:04:52 -03:00
Santiago Pastorino
2bc723fbca
Change opaque type map to be a VecMap 2021-06-07 19:03:57 -03:00
Taylor Yu
e848be06e1 don't suggest unsized indirection in where-clauses
Skip where-clauses when suggesting using indirection in combination with
`?Sized` bounds on type parameters.
2021-06-03 17:19:57 -05:00
Camille GILLOT
0e71283495 Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
2021-06-02 18:35:32 +02:00
Camille Gillot
0f0f3138cb
Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
Camille GILLOT
10fb4b2fe5 Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
2021-05-30 19:54:04 +02:00
Niko Matsakis
128d385e56 stabilize member constraints 2021-05-26 06:01:53 -04:00
bors
ff2c947c00 Auto merge of #85481 - lcnr:const-equate, r=matthewjasper
deal with `const_evaluatable_checked` in `ConstEquate`

Failing to evaluate two constants which do not contain inference variables should not result in ambiguity.
2021-05-25 13:53:48 +00:00
bors
a7890c7952 Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrum
Bump bootstrap compiler to beta 1.53.0

This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected).

The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html).

r? `@Mark-Simulacrum`
2021-05-25 05:48:00 +00:00
bors
ef0ec303fa Auto merge of #85596 - scottmcm:more-on-unimplemented, r=estebank
Extend `rustc_on_implemented` to improve more `?` error messages

`_Self` could match the generic definition; this adds that functionality for matching the generic definition of type parameters too.

Your advice welcome on the wording of all these messages, and which things belong in the message/label/note.

r? `@estebank`
2021-05-24 15:24:38 +00:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Scott McMurray
8be67998a1 Extend rustc_on_implemented to improve a ?-on-ControlFlow error message 2021-05-23 07:18:02 -07:00
bors
6f5a198ffc Auto merge of #85382 - Aaron1011:project-eval, r=nikomatsakis
Always produce sub-obligations when using cached projection result

See https://github.com/rust-lang/rust/issues/85360

When we skip adding the sub-obligations to the `obligation` list, we can affect whether or not the final result is `EvaluatedToOk` or `EvaluatedToOkModuloObligations`. This creates problems for incremental compilation, since the projection cache is untracked shared state.

To solve this issue, we unconditionally process the sub-obligations. Surprisingly, this is a slight performance *win* in many cases.
2021-05-21 02:39:39 +00:00
lcnr
412e0404c0 deal with const_evaluatable_checked in ConstEquate 2021-05-19 21:27:51 +02:00
Guillaume Gomez
fad04ff60e
Rollup merge of #85369 - FabianWolff:issue-84973, r=jackh726
Suggest borrowing if a trait implementation is found for &/&mut <type>

This pull request fixes #84973 by suggesting to borrow if a trait is not implemented for some type `T`, but it is for `&T` or `&mut T`. For instance:
```rust
trait Ti {}
impl<T> Ti for &T {}
fn foo<T: Ti>(_: T) {}

trait Tm {}
impl<T> Tm for &mut T {}
fn bar<T: Tm>(_: T) {}

fn main() {
    let a: i32 = 5;
    foo(a);

    let b: Box<i32> = Box::new(42);
    bar(b);
}
```
gives, on current nightly:
```
error[E0277]: the trait bound `i32: Ti` is not satisfied
  --> t2.rs:11:9
   |
3  | fn foo<T: Ti>(_: T) {}
   |           -- required by this bound in `foo`
...
11 |     foo(a);
   |         ^ the trait `Ti` is not implemented for `i32`

error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied
  --> t2.rs:14:9
   |
7  | fn bar<T: Tm>(_: T) {}
   |           -- required by this bound in `bar`
...
14 |     bar(b);
   |         ^ the trait `Tm` is not implemented for `Box<i32>`

error: aborting due to 2 previous errors
```
whereas with my changes, I get:
```
error[E0277]: the trait bound `i32: Ti` is not satisfied
  --> t2.rs:11:9
   |
3  | fn foo<T: Ti>(_: T) {}
   |           -- required by this bound in `foo`
...
11 |     foo(a);
   |         ^
   |         |
   |         expected an implementor of trait `Ti`
   |         help: consider borrowing here: `&a`

error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied
  --> t2.rs:14:9
   |
7  | fn bar<T: Tm>(_: T) {}
   |           -- required by this bound in `bar`
...
14 |     bar(b);
   |         ^
   |         |
   |         expected an implementor of trait `Tm`
   |         help: consider borrowing mutably here: `&mut b`

error: aborting due to 2 previous errors
```
In my implementation, I have added a "blacklist" to make these suggestions flexible. In particular, suggesting to borrow can interfere with other suggestions, such as to add another trait bound to a generic argument. I have tried to configure this blacklist to cause the least amount of test case failures, i.e. to model the current behavior as closely as possible (I only had to change one existing test case, and this change was quite clearly an improvement).
2021-05-18 14:08:55 +02:00
Alexis Bourget
b574c67b93 New rustdoc lint to respect -Dwarnings correctly
This adds a new lint to `rustc` that is used in rustdoc when a code
block is empty or cannot be parsed as valid Rust code.

Previously this was unconditionally a warning. As such some
documentation comments were (unknowingly) abusing this to pass despite
the `-Dwarnings` used when compiling `rustc`, this should not be the
case anymore.
2021-05-17 21:31:01 -04:00
Fabian Wolff
572bb13ae5 Implement jackh726's suggestions 2021-05-17 23:13:04 +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
Aaron Hill
8657bb251c
Always produce sub-obligations when using cached projection result 2021-05-16 17:18:17 -04:00
Fabian Wolff
48d07d1326 Suggest borrowing if a trait implementation is found for &/&mut <type> 2021-05-16 16:20:35 +02:00
Niko Matsakis
89c58eac68 have on_completion record subcycles
Rework `on_completion` method so that it removes all
provisional cache entries that are "below" a completed
node (while leaving those entries that are not below
the node).

This corrects an imprecise result that could in turn lead
to an incremental compilation failure. Under the old
scheme, if you had:

* A depends on...
     * B depends on A
     * C depends on...
         * D depends on C
     * T: 'static

then the provisional results for A, B, C, and D would all
be entangled. Thus, if A was `EvaluatedToOkModuloRegions`
(because of that final condition), then the result for C and
D would also be demoted to "ok modulo regions".

In reality, though, the result for C depends only on C and itself,
and is not dependent on regions. If we happen to evaluate the
cycle starting from C, we would never reach A, and hence the
result would be "ok".

Under the new scheme, the provisional results for C and D
are moved to the permanent cache immediately and are not affected
by the result of A.
2021-05-13 05:58:21 -04:00
Camille GILLOT
4e8d4bdf4b Use () for all_traits. 2021-05-12 13:58:46 +02:00
Dylan DPC
01e9d09d3b
Rollup merge of #84987 - lcnr:nits, r=Mark-Simulacrum
small nits
2021-05-07 00:38:45 +02:00
bors
377d1a984c Auto merge of #84559 - jackh726:issue-84398, r=nikomatsakis
Deduplicate ParamCandidates with the same value except for bound vars

Fixes #84398

This is kind of a hack. I wonder if we can get other types of candidates that are the same except for bound vars. This won't be a problem with Chalk, since we don't really need to know that there are two different "candidates" if they both give the same final substitution.

r? `@nikomatsakis`
2021-05-06 17:42:32 +00:00
lcnr
b9811418dd outdated comment 2021-05-06 16:27:59 +02:00