Commit graph

289 commits

Author SHA1 Message Date
William Bain
b76c9be7f5 Handle desugaring in impl trait bound suggestion 2020-12-19 20:37:51 -05:00
bors
1b6b06a03a Auto merge of #80132 - matthewjasper:revert-eval-order, r=nikomatsakis
Revert change to trait evaluation order

This change breaks some code and doesn't appear to enable any new code.

closes #79902

r? `@nikomatsakis`
2020-12-19 16:20:22 +00:00
Jack Huey
5e7095850c More rebinds 2020-12-19 04:26:35 -05:00
Matthew Jasper
3e31ffda97 Revert change to evaluation order
This change breaks some code and doesn't appear to enable any new code.
2020-12-17 20:16:10 +00:00
bors
eb4fc71dc9 Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis
Move binder for dyn to each list item

This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`.

This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.`

r? `@nikomatsakis`
2020-12-17 18:21:20 +00:00
Matthias Krüger
5833f74a9c use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn) 2020-12-11 23:02:19 +01:00
Matthias Krüger
db6c50998c don't clone types that are copy (clippy::clone_on_copy) 2020-12-11 23:02:19 +01:00
Jack Huey
ed80815bf2 Move binder for dyn to each list item 2020-12-11 15:02:46 -05:00
Matthias Krüger
1734f9c291 remove redundant clones 2020-12-05 12:59:54 +01:00
bors
b4def89d76 Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum
Revert "Auto merge of #79209

r? `@nikomatsakis`

This has caused some issues (#79560) so better to revert and try to come up with a proper fix without rush.
2020-12-03 02:00:46 +00:00
Santiago Pastorino
37354ebc97
Revert "Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakis"
This reverts commit 349b3b324d, reversing
changes made to b776d1c3e3.
2020-12-02 12:19:38 -03:00
ThePuzzlemaker
3c4bc8c8ad
Ignore trait implementations with negative polarity when suggesting trait implementations in diagnostics 2020-12-01 13:30:08 -06:00
Aman Arora
5da2bf197d Remove extra call to upvar_tys
Fixes #78720
2020-11-29 19:11:20 -05:00
bors
349b3b324d Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakis
Allow Trait inheritance with cycles on associated types

Fixes #35237

r? `@nikomatsakis`

cc `@estebank`
2020-11-29 21:04:23 +00:00
Dylan DPC
47e74a9a51
Rollup merge of #79516 - jyn514:cleanup-trait-solver, r=Aaron1011
Remove unnecessary `mut` binding

Found while fiddling around with https://github.com/rust-lang/rust/issues/77459.
2020-11-29 03:14:27 +01:00
Joshua Nelson
870a041262 Remove unnecessary mut binding 2020-11-28 14:52:25 -05:00
Joshua Nelson
2d39c09cc2 Change comments on types to doc-comments 2020-11-27 14:17:25 -05:00
Santiago Pastorino
2ca4964db5
Allow to self reference associated types in where clauses 2020-11-27 11:23:47 -03:00
Jonas Schievink
b4db342f51
Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink
Reduce boilerplate with the `?` operator

`@rustbot` modify labels to +C-cleanup.
2020-11-23 15:25:47 +01:00
LingMan
e0871cc0be Reduce boilerplate with the ? operator 2020-11-23 00:58:53 +01:00
Jonas Schievink
71d350e33a winnow: drop non-const cand. in favor of const 2020-11-22 04:04:49 +01:00
Jonas Schievink
ee6f42ba94 Thread Constness through selection 2020-11-22 02:13:53 +01:00
LeSeulArtichaut
f59d03038c Move rustc_ty -> rustc_ty_utils 2020-11-19 21:57:29 +01:00
Dylan DPC
470f768c97
Rollup merge of #79110 - estebank:issue-58964, r=oli-obk
Remove redundant notes in E0275

Fix #58964.
2020-11-19 16:26:31 +01:00
Esteban Küber
c12e77badd review comment 2020-11-18 09:06:18 -08:00
Esteban Küber
352796402f Account for indirect cyclic requirements 2020-11-18 09:06:18 -08:00
Esteban Küber
2098ade771 Remove redundant notes in E0275
Fix #58964.
2020-11-18 09:05:48 -08:00
Mara Bos
43d13e2d58
Rollup merge of #79158 - lcnr:lazy-norm-coerce, r=oli-obk
type is too big -> values of the type are too big

strictly speaking, `[u8; usize::MAX]` or even `[[[u128; usize::MAX]; usize::MAX]; usize::MAX]` are absolutely fine types as long as you don't try to deal with any values of it.

This error message seems to cause some confusion imo, for example in https://github.com/rust-lang/rust/pull/79135#issuecomment-729361380 so I would prefer us to be more precise here.

See the added test case which uses one of these types without causing an error.

r? ``@oli-obk``
2020-11-18 15:46:40 +01:00
bors
e0ef0fc392 Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Introduce `TypeVisitor::BreakTy`

Implements MCP rust-lang/compiler-team#383.
r? `@ghost`
cc `@lcnr` `@oli-obk`

~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-17 12:24:34 +00:00
lcnr
a6cbd64dae words 2020-11-16 22:42:09 +01:00
Bastian Kauschke
2bf93bd852 compiler: fold by value 2020-11-16 22:34:57 +01:00
Bastian Kauschke
dcc194ce2f instrument QueryNormalizer::fold_ty 2020-11-16 10:48:31 +01: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
LeSeulArtichaut
65cdc21f06 Set the default BreakTy to ! 2020-11-14 21:46:39 +01:00
LeSeulArtichaut
17b395d296 Use TypeVisitor::BreakTy in structural_match::Search 2020-11-14 21:15:32 +01:00
LeSeulArtichaut
e0f3119103 Introduce TypeVisitor::BreakTy 2020-11-14 20:25:27 +01:00
Dániel Buga
f0d0d87a20 Push to result vector instead of allocating
Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
2020-11-13 11:19:25 +01:00
Jonas Schievink
2e0a0b42ad
Rollup merge of #78832 - lcnr:const-evaluatable-unevaluated, r=oli-obk
look at assoc ct, check the type of nodes

an example where types matter are function objects, see the added test which previously passed.

Now does a shallow comparison of unevaluated constants.

r? ```@oli-obk```
2020-11-11 20:59:02 +01:00
Nicholas-Baron
261ca04c92 Changed unwrap_or to unwrap_or_else in some places.
The discussion seems to have resolved that this lint is a bit "noisy" in
that applying it in all places would result in a reduction in
readability.

A few of the trivial functions (like `Path::new`) are fine to leave
outside of closures.

The general rule seems to be that anything that is obviously an
allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it
is a 0-sized allocation.
2020-11-10 20:07:47 -08:00
bors
87a0997ef9 Auto merge of #78410 - lcnr:revert75443, r=nikomatsakis
revert #75443, update mir validator

This PR reverts rust-lang#75443 to fix rust-lang#75992 and instead uses rust-lang#75419 to fix rust-lang#75313.

Adapts rust-lang#75419 to correctly deal with unevaluated constants as otherwise some `feature(const_evaluatable_checked)` tests would ICE.

Note that rust-lang#72793 was also fixed by rust-lang#75443, but as that issue only concerns `feature(type_alias_impl_trait)` I deleted that test case for now and would reopen that issue.

rust-lang#75443 may have also allowed some other code to now successfully compile which would make this revert a breaking change after 2 stable versions, but I hope that this is a purely theoretical concern.

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/generator.20upvars/near/214617274 for more reasoning about this.

r? `@nikomatsakis` `@eddyb` `@RalfJung`
2020-11-08 11:27:06 +00: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
Bastian Kauschke
439171e094 look at assoc ct, check the type of nodes 2020-11-07 12:39:52 +01:00
bors
f92b931045 Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27
Add non_autolinks lint

Part of #77501.

r? `@jyn514`
2020-11-06 04:17:41 +00:00
Guillaume Gomez
99200f760b Fix even more URLs 2020-11-05 20:11:29 +01:00
Matthias Krüger
bcd2f2df67 fix a couple of clippy warnings:
filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-04 13:48:50 +01:00
Bastian Kauschke
cc19df627e revert #75443 update mir validator 2020-11-02 23:57:03 +01:00
Yuki Okushi
8d651013e4 Fix format 2020-11-02 16:59:11 +09:00
Yuki Okushi
54d9ffc0b9 Only separate notes if span is multiline 2020-11-02 16:54:53 +09:00
Yuki Okushi
2da86a1bfd Add "this has type {} which {}" note 2020-11-02 15:53:59 +09:00
Yuki Okushi
66226ca157 Address some code reviews 2020-11-02 15:53:59 +09:00
Yuki Okushi
ad978e5572 Separate complex multispan into some notes 2020-11-02 15:53:59 +09:00
LeSeulArtichaut
9433eb83fe Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut
24e1a7e656 Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut
4fe735b320 TypeVisitor: use ControlFlow in rustc_{infer,lint,trait_selection} 2020-10-30 12:27:34 +01:00
Jonas Schievink
7fa9e39682
Rollup merge of #78422 - estebank:fix-78372, r=pnkfelix
Do not ICE on invalid input

Fix #78372.
2020-10-29 17:05:14 +01:00
Dylan DPC
1a64e570c6
Rollup merge of #78365 - lcnr:const-eval-obj-safety, r=oli-obk
check object safety of generic constants

As `Self` can only be effectively used in constants with `const_evaluatable_checked` this should not matter outside of it.

Implements the first item of #72219

> Object safety interactions with constants

r? @oli-obk for now cc @nikomatsakis
2020-10-28 01:21:21 +01:00
Santiago Pastorino
708fc3b1a2
Add unsized_fn_params feature 2020-10-27 14:45:02 -03:00
Esteban Küber
cd259dbd19 Do not ICE on invalid input 2020-10-26 17:42:46 -07:00
Bastian Kauschke
60bcc58dce debug log AbstractConst::new 2020-10-26 14:56:58 +01:00
Dylan DPC
083a5cd9a2
Rollup merge of #78214 - estebank:match-semicolon, r=oli-obk
Tweak match arm semicolon removal suggestion to account for futures

* Tweak and extend "use `.await`" suggestions
* Suggest removal of semicolon on prior match arm
* Account for `impl Future` when suggesting semicolon removal
* Silence some errors when encountering `await foo()?` as can't be certain what the intent was

*Thanks to https://twitter.com/a_hoverbear/status/1318960787105353728 for pointing this out!*
2020-10-26 03:09:06 +01:00
Bastian Kauschke
0e419efb1c check for object safety violations in constants 2020-10-25 18:33:45 +01:00
Jonas Schievink
5ed8ac45d4
Rollup merge of #78272 - lcnr:abstract-const-unused-node, r=oli-obk
const_evaluatable_checked: deal with unused nodes + div

r? @oli-obk
2020-10-24 22:39:57 +02:00
Esteban Küber
f71e9ed7f1 review comments 2020-10-23 12:51:06 -07:00
Esteban Küber
b334eef162 Do not ICE with TraitPredicates containing [type error]
Fix #77919.
2020-10-23 12:21:47 -07:00
Esteban Küber
86df9039b2 Tweak "use .await" suggestion 2020-10-23 08:02:57 -07:00
Bastian Kauschke
47cb871f14 review 2020-10-23 15:04:12 +02:00
Bastian Kauschke
6ad140ca19 const_eval_checked: deal with unused nodes + div 2020-10-23 12:16:58 +02:00
Matthew Jasper
50dde2e4d8 Normalize when finding trait object candidates 2020-10-22 08:18:29 +01:00
Matthew Jasper
6c43a64931 Fix ICE from projection cycle
Cycles in normalization can cause evaluations to change from Unknown to
Err. This means that some selection that were applicable no longer are.

To avoid this:
* Selection candidates that are known to be applicable are prefered
  over candidates that are not.
* We don't ICE if a candidate is no longer applicable.
2020-10-21 19:43:20 +01:00
Yuki Okushi
9583029a2d
Rollup merge of #78002 - estebank:issue-77598, r=oli-obk
Tweak "object unsafe" errors

CC #77598.
2020-10-21 13:59:35 +09:00
Guillaume Gomez
01e6019448
Rollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum
Move orphan module-name/mod.rs files into module-name.rs files
2020-10-20 21:46:35 +02:00
Esteban Küber
88f5e110db review comments 2020-10-20 09:26:15 -07:00
Esteban Küber
ae0e3d0511 Tweak "object unsafe" errors
Fix #77598.
2020-10-20 09:26:14 -07:00
Yuki Okushi
3f1c637db4
Rollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr
Trait predicate ambiguities are not always in `Self`

When reporting ambiguities in trait predicates, the compiler incorrectly assumed the ambiguity was always in the type the trait should be implemented on, and never the generic parameters of the trait. This caused silly suggestions for predicates like `<KnownType as Trait<_>>`, such as giving explicit types to completely unrelated variables that happened to be of type `KnownType`.

This also reverts #73027, which worked around this issue in some cases and does not appear to be necessary any more.

fixes #77982
fixes #78055
2020-10-20 12:11:11 +09:00
SNCPlay42
71ca239f80 don't assume trait ambiguity happens in Self 2020-10-19 21:11:40 +01:00
bors
f90e617305 Auto merge of #77908 - bugadani:obl-forest, r=nnethercote
Try to make ObligationForest more efficient

This PR tries to decrease the number of allocations in ObligationForest, as well as moves some cold path code to an uninlined function.
2020-10-19 15:14:15 +00:00
est31
66c1fc4c87 Move orphan module-name/mod.rs files into module-name.rs files 2020-10-18 20:56:15 +02:00
bors
4d247ad7d3 Auto merge of #77306 - lcnr:inline-ok, r=eddyb
normalize substs while inlining

fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly
and had an error with the current one.

I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed)

r? `@eddyb` cc `@bjorn3`
2020-10-18 16:10:00 +00:00
Jack Huey
f6a53b4c69 Review comments 2020-10-16 15:14:38 -04:00
Jack Huey
eba10270c6 map_bound_ref -> rebind 2020-10-16 14:29:21 -04:00
Jack Huey
dd5c9bf139 Use map_bound(_ref) instead of Binder::bind when possible 2020-10-16 12:58:50 -04:00
Dániel Buga
8c7a8a62dd Turn Outcome into an opaque type to remove some runtime checks 2020-10-15 08:32:41 +02:00
bors
93deabce03 Auto merge of #77873 - sexxi-goose:use_tuple_inference_for_closures, r=nikomatsakis
Replace tuple of infer vars for upvar_tys with single infer var

This commit allows us to decide the number of captures required after
completing capture ananysis, which is required as part of implementing
RFC-2229.

closes https://github.com/rust-lang/project-rfc-2229/issues/4
r? `@nikomatsakis`
2020-10-15 04:17:10 +00:00
Roxane
a64ad51ff7 Address comments 2020-10-14 00:17:42 -04:00
est31
215cd36e1c Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
est31
a0fc455d30 Replace absolute paths with relative ones
Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-13 14:16:45 +02:00
bors
abbdec3be6 Auto merge of #77792 - matthewjasper:instrument-trait-selection, r=oli-obk
Use tracing spans in rustc_trait_selection

Spans are very helpful when debugging this code. It's also hot enough to make a good benchmark.

r? `@oli-obk`
2020-10-12 23:04:55 +00:00
Yuki Okushi
687d7646de
Rollup merge of #77550 - lcnr:ty-dep-path-ct-cleanup, r=ecstatic-morse
add shims for WithOptConstParam query calls

r? @ecstatic-morse @eddyb
2020-10-13 04:07:50 +09:00
Matthew Jasper
b8d2560dca Use tracing spans in rustc_trait_selection 2020-10-11 16:08:23 +01:00
Aman Arora
3c46fd67f8 traits diagnostics: Don't print closure/generator upvar_tys tuple
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-10-11 03:33:27 -04:00
Aman Arora
08d1ab0bf1 Always return tupled_upvar_tys for Closure/Generator consituent tys
Depending on if upvar_tys inferred or not, we were returning either an
inference variable which later resolves to a tuple or else the upvar tys
themselves

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-10-11 03:32:35 -04:00
Roxane
dc183702da Replace tuple of infer vars for upvar_tys with single infer var
This commit allows us to decide the number of captures required after
completing capture ananysis, which is required as part of implementing
RFC-2229.

Co-authored-by: Aman Arora <me@aman-arora.com>
Co-authored-by: Jenny Wills <wills.jenniferg@gmail.com>
2020-10-11 03:32:35 -04:00
Dániel Buga
7993ddd89d Add find_map_relevant_impl 2020-10-09 16:22:49 +02:00
Bastian Kauschke
f0487cee74 normalize substs during inlining 2020-10-07 10:04:08 +02:00
Bastian Kauschke
9c302f55bd normalize in codegen_fulfill_obligations 2020-10-07 09:50:30 +02:00
Matthew Jasper
022c148fcd Fix tests from rebase 2020-10-06 11:19:33 +01:00
Matthew Jasper
27534b3932 Fix rebase 2020-10-06 11:19:33 +01:00
Matthew Jasper
852073a7d2 Deduplicate item bounds after normalization 2020-10-06 11:19:32 +01:00
Matthew Jasper
e42c97919c Don't require lifetime super-bounds on traits apply to trait objects of that trait 2020-10-06 11:19:32 +01:00
Matthew Jasper
e674cf0200 Normalize super trait bounds when confirming object candidates 2020-10-06 11:19:32 +01:00
Matthew Jasper
d08ab945de Fix rebase 2020-10-06 11:19:32 +01:00
Matthew Jasper
6c4feb681f Fix bootstrap 2020-10-06 11:19:32 +01:00
Matthew Jasper
ed32482534 Handle multiple trait-def projection candidates 2020-10-06 11:19:32 +01:00
Matthew Jasper
0dfa6ff3be Avoid cycles from projection bounds
Only check the own predicates of associated types when confirming
projection candidates.
Also consider implied bounds when comparing trait and impl methods.
2020-10-06 11:19:32 +01:00
Matthew Jasper
596d6c4b3b Avoid cycle with projections from object types
Normalizing `<dyn Iterator<Item = ()> as Iterator>::Item` no longer
requires selecting `dyn Iterator<Item = ()>: Iterator`. This was
previously worked around by using a special type-folder to normalize
things.
2020-10-06 11:19:31 +01:00
Matthew Jasper
34e5a4992c Normalize projection bounds when considering candidates
This unfortunately requires some winnowing hacks to avoid
now ambiguous candidates.
2020-10-06 11:19:31 +01:00
Matthew Jasper
cfee49593d Handle multiple applicable projection candidates 2020-10-06 11:19:31 +01:00
Matthew Jasper
bc08b791bc Fix bugs in evaluating WellFormed predicates
- List the nestsed obligations in an order that works with the
  single pass used by evaluation
- Propagate recursion depth correctly
2020-10-06 11:19:31 +01:00
Matthew Jasper
f52b2d8890 Avoid cycle in nested obligations for object candidate
Bounds of the form `type Future: Future<Result=Self::Result>` exist in
some ecosystem crates. To validate these bounds for trait objects we
need to normalize `Self::Result` in a way that doesn't cause a cycle.
2020-10-06 11:19:31 +01:00
Matthew Jasper
8787090964 Address review comments 2020-10-06 11:19:31 +01:00
Matthew Jasper
21eccbb587 Fix ICE 2020-10-06 11:19:30 +01:00
Matthew Jasper
042464f75a Fix tests and bootstrap 2020-10-06 11:19:30 +01:00
Matthew Jasper
2bdf723da7 Ensure that associated types for trait objects satisfy their bounds 2020-10-06 11:19:30 +01:00
Matthew Jasper
0a76584dcc Move some code from rustc_typeck to rustc_trait_selection 2020-10-06 11:19:30 +01:00
Matthew Jasper
d4d9e7f67f Remove unused part of return value from replace_bound_vars_with_placeholders 2020-10-06 11:19:30 +01:00
Matthew Jasper
1b07991574 Check associated type bounds for object safety violations 2020-10-06 11:19:30 +01:00
Matthew Jasper
5b279c8016 Check opaque types satisfy their bounds 2020-10-06 11:19:30 +01:00
Matthew Jasper
b3057f4d5f Check projections are well-formed when using projection candidates 2020-10-06 11:19:29 +01:00
Matthew Jasper
87f2f42dc2 Make projection wf check the predicates for the projection 2020-10-06 11:19:29 +01:00
Matthew Jasper
d297147e62 Split bounds from predicates 2020-10-06 11:19:22 +01:00
Matthew Jasper
0eb87ed55f Rename projection_predicates to item_bounds 2020-10-06 11:18:45 +01:00
Yuki Okushi
2970af8e28
Rollup merge of #77559 - camelid:fix-rustdoc-warnings-invalid-rust-syntax, r=lcnr
Fix rustdoc warnings about invalid Rust syntax
2020-10-06 16:26:09 +09:00
Camelid
c8d25af698 Fixup 2020-10-05 15:07:27 -07:00
bors
ea7e131435 Auto merge of #77171 - VFLashM:better_sso_structures, r=oli-obk
Better sso structures

This change greatly expands interface of MiniSet/MiniMap and renames them because they are no longer "Mini".
2020-10-05 17:18:01 +00:00
Bastian Kauschke
8160bfa39c query_name_of_opt_const_arg -> query_name_opt_const_arg 2020-10-05 08:49:21 +02:00
Camelid
c877ff3664 Fix rustdoc warnings about invalid Rust syntax 2020-10-04 19:35:44 -07:00
Dylan DPC
9dbc9ed870
Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebank
Replace some once(x).chain(once(y)) with [x, y] IntoIter

Now that we have by-value array iterators that are [already used](25c8c53dd9/compiler/rustc_hir/src/def.rs (L305-L307))...

For example,
```diff
-        once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it)
+        IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)
```
2020-10-05 02:29:42 +02:00
Dylan DPC
5fa978fa1b
Rollup merge of #75928 - JulianKnodt:non_utf8, r=estebank
Remove trait_selection error message in specific case

In the case that a trait is not implemented for an ADT with type errors, cancel the error.

Fixes #75627
2020-10-05 02:29:25 +02:00
Bastian Kauschke
536674fb69 cleanup WithOptConstParam queries 2020-10-04 23:22:08 +02:00
Scott McMurray
d74b8e0505 Replace some once(x).chain(once(y)) with [x, y] IntoIter
Now that we have by-value array iterators...
2020-10-03 16:51:43 -07:00
Dylan DPC
6d3cfd9d51
Rollup merge of #77305 - lcnr:candidate_from_obligation, r=davidtwco
move candidate_from_obligation_no_cache

It's only called from `candidate_from_obligation` which is already in this file.
2020-10-01 02:13:37 +02:00
Dylan DPC
f23559451b
Rollup merge of #77303 - lcnr:const-evaluatable-TooGeneric, r=oli-obk,varkor
const evaluatable: improve `TooGeneric` handling

Instead of emitting an error in `fulfill`, we now correctly stall on inference variables.

As `const_eval_resolve` returns `ErrorHandled::TooGeneric` when encountering generic parameters on which
we actually do want to error, we check for inference variables and eagerly emit an error if they don't exist, returning `ErrorHandled::Reported` instead.

Also contains a small bugfix for `ConstEquate` where we previously only stalled on type variables. This is probably a leftover from
when we did not yet support stalling on const inference variables.

r? @oli-obk cc @varkor @eddyb
2020-10-01 02:13:35 +02:00
Bastian Kauschke
db5b70f193 move candidate_from_obligation_no_cache 2020-09-28 20:21:44 +02:00
Bastian Kauschke
a4783debe0 const evaluatable: improve TooGeneric handling 2020-09-28 20:18:06 +02:00
Dylan MacKenzie
c4d8089f00 Revert "Add an unused field of type Option<DefId> to ParamEnv struct."
This reverts commit ab83d372ed.
2020-09-26 21:01:09 -07:00
Valerii Lashmanov
5c224a484d MiniSet/MiniMap moved and renamed into SsoHashSet/SsoHashMap
It is a more descriptive name and with upcoming changes
there will be nothing "mini" about them.
2020-09-26 14:30:05 -05:00
Ralf Jung
9e02642fb3
Rollup merge of #77211 - est31:remove_unused_allow, r=oli-obk
Remove unused #[allow(...)] statements from compiler/
2020-09-26 12:58:34 +02:00
Ralf Jung
ac8169dc10
Rollup merge of #77093 - lcnr:const-generics-infer-warning, r=varkor
merge `need_type_info_err(_const)`

I hoped that this would automatically solve #76737 but it doesn't quite seem like it

fixes #77092

r? @varkor
2020-09-26 12:58:17 +02:00
Bastian Kauschke
32195ac8f4 rename functions 2020-09-26 10:28:15 +02:00
est31
12187b7f86 Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
Jonas Schievink
e739468f97
Rollup merge of #77155 - lcnr:ImplSource, r=ecstatic-morse
remove enum name from ImplSource variants

This is quite a lot cleaner in my opinion.
2020-09-25 19:42:48 +02:00
bors
521d8d8a22 Auto merge of #77041 - lcnr:const-eval-perf, r=ecstatic-morse
perf: move cold path of `process_obligations` into a separate function

cc #76575

This probably won't matter too much in the long run once #69218 is merged so we may not want to merge this.

r? `@ecstatic-morse`
2020-09-25 10:14:47 +00:00
Jonas Schievink
6f3da3d53f
Rollup merge of #77121 - duckymirror:html-root-url, r=jyn514
Updated html_root_url for compiler crates

Closes #77103

r? @jyn514
2020-09-25 02:29:45 +02:00
Bastian Kauschke
06d2325a50 perf: split progress_obligations with inline(never) 2020-09-24 22:13:41 +02:00
Bastian Kauschke
1857184cd1 remove enum name from ImplSource variants 2020-09-24 19:22:36 +02:00
Bastian Kauschke
b8402d6a6e assign the correct DefId in nominal_obligations 2020-09-24 09:04:23 +02:00
Erik Hofmayer
138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer
dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
Dylan DPC
98e5ee7df0
Rollup merge of #76939 - lcnr:const-evaluatable-cont, r=oli-obk
emit errors during AbstractConst building

There changes are currently still untested, so I don't expect this to pass CI 😆

It seems to me like this is the direction we want to go in, though we didn't have too much of a discussion about this.

r? @oli-obk
2020-09-23 14:54:02 +02:00
Bastian Kauschke
45d92b43e3 merge need_type_info_err(_const) 2020-09-23 09:24:58 +02:00