Commit Graph

60 Commits

Author SHA1 Message Date
Mazdak Farrokhzad 8bd3d240e3 nix syntax::errors & prefer rustc_errors over errors 2020-01-10 07:41:30 +01:00
Mazdak Farrokhzad 2c3e5d3de0 - remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
2020-01-08 04:25:33 +01:00
Mazdak Farrokhzad ebfd8673a7 Remove rustc_hir reexports in rustc::hir. 2020-01-05 12:49:22 +01:00
Vadim Petrochenkov 70f1d57048 Rename `syntax_pos` to `rustc_span` in source code 2020-01-01 09:15:18 +03:00
Mark Rousskov a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Guillaume Gomez 798e389e57 Update to use new librustc_error_codes library 2019-11-14 13:05:42 +01:00
varkor e2e0f9af85 Rename `sty` to `kind` 2019-09-25 15:50:04 +01:00
Eduard-Mihai Burtescu b25b466a88 rustc: remove 'x: 'y bounds (except from comments/strings). 2019-06-18 18:10:21 +03:00
Eduard-Mihai Burtescu afc39bbf24 Run `rustfmt --file-lines ...` for changes from previous commits. 2019-06-14 18:58:32 +03:00
Eduard-Mihai Burtescu f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
Eduard-Mihai Burtescu fff08cb043 Run `rustfmt --file-lines ...` for changes from previous commits. 2019-06-12 13:38:28 +03:00
Eduard-Mihai Burtescu 17cdd356da rustc: replace `TyCtxt<'tcx, 'gcx, 'tcx>` with `TyCtxt<'gcx, 'tcx>`. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu 2441253508 Fix fallout from `deny(unused_lifetimes)`. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu 37799a5552 rustc: replace `TyCtxt<'a, 'gcx, 'tcx>` with `TyCtxt<'tcx, 'gcx, 'tcx>`. 2019-06-12 13:38:27 +03:00
varkor c94ba6382d Rename `OpportunisticTypeResolver` to `OpportunisticVarResolver` 2019-05-28 21:34:42 +01:00
ljedrz eac43ccda4 HirId-ify hir::BodyId 2019-02-13 09:54:58 +01:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Ariel Ben-Yehuda 12c17f9110 move overflow error reporting out of the query
that allows the error reporting to contain the span.
2018-12-15 00:41:28 +02:00
Ariel Ben-Yehuda be2bb4fa1d implement "isolated" autoderef using the Canonical mechanism 2018-12-15 00:41:28 +02:00
Ariel Ben-Yehuda 832ac110df remove the typeck::autoderef::Autoderef fcx field
This allows using it in an fcx-independent context
2018-12-14 18:18:51 +02:00
Ariel Ben-Yehuda 07201249f0 process nested obligations in autoderef
This is a hack-fix to #53843, but I am worried it might break things
because it makes the "inference pollution" problem worse.

Fixes #53843 (but introduces a bug that someone might notice).
2018-12-14 18:18:51 +02:00
Alexander Regueiro ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
varkor f039872766 Enclose type in backticks for "reached the recursion limit while auto-dereferencing" error 2018-11-21 16:06:24 +00:00
Shotaro Yamada 3878d24ef6 Remove redundant clone 2018-10-26 12:07:39 +09:00
varkor 6f637da50c Remove Ty prefix from Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error} 2018-08-22 16:07:44 +01:00
Vadim Petrochenkov 1fe9b4d763 Use `Ident`s for associated type bindings in HIR 2018-06-28 11:04:50 +03:00
Nicholas Nethercote 47bc774ab6 Avoid allocations in `opt_normalize_projection_type`.
This patch changes `opt_normalize_project_type` so it appends
obligations to a given obligations vector, instead of returning a new
obligations vector.

This change avoids lots of allocations. In the most extreme case, for a
clean "Check" build of serde it reduces the total number of allocations
by 20%.
2018-05-17 10:35:39 +10:00
John Kåre Alsaker c9d9c249ec Insert fields from TypeAndMut into TyRef to allow layout optimization 2018-05-08 16:21:58 +02:00
Aravind Gollakota bc16b8e92a Port existing callers of `evaluate_obligation` to the new canonical trait query
Except the one in coherence, which needs support for intercrate mode.
2018-04-26 20:28:30 -05:00
John Kåre Alsaker cf3b7909fa Make recursion_limit and type_length_limit thread-safe 2018-04-10 14:39:57 +02:00
Eduard-Mihai Burtescu 3f4a489f8f rustc_typeck: rename `LvalueOp` to `PlaceOp`. 2018-01-29 01:20:18 +02:00
Eduard-Mihai Burtescu 2c4a75bf09 rustc_typeck: rename `LvaluePreference::PreferMutLvalue` to `Needs::MutPlace`. 2018-01-29 00:59:25 +02:00
Eduard-Mihai Burtescu 800166cf96 rustc: remove `LvaluePreference` argument from `Ty::builtin_deref`. 2018-01-29 00:42:51 +02:00
Zack M. Davis aba56ddd05 type error method suggestions use whitelisted identity-like conversions
Previously, on a type mismatch (and if this wasn't preëmpted by a
higher-priority suggestion), we would look for argumentless methods
returning the expected type, and list them in a `help` note.

This had two major shortcomings. Firstly, a lot of the suggestions didn't
really make sense (if you used a &str where a String was expected,
`.to_ascii_uppercase()` is probably not the solution you were hoping
for). Secondly, we weren't generating suggestions from the most useful
traits!

We address the first problem with an internal
`#[rustc_conversion_suggestion]` attribute meant to mark methods that keep
the "same value" in the relevant sense, just converting the type. We
address the second problem by making `FnCtxt.probe_for_return_type` pass
the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe
because grep reveals no other callers of `probe_for_return_type`.

Also, structured suggestions are preferred (because they're pretty, but
also for RLS and friends).

Also also, we make the E0055 autoderef recursion limit error use the
one-time-diagnostics set, because we can potentially hit the limit a lot
during probing. (Without this,
test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to
51 errors").

Unfortunately, the trait probing is still not all one would hope for: at a
minimum, we don't know how to rule out `into()` in cases where it wouldn't
actually work, and we don't know how to rule in `.to_owned()` where it
would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME.

This is hoped to resolve #42929, #44672, and #45777.
2018-01-06 17:15:59 -08:00
Michael Hewson 361b3db886 implement raw-pointer `self`. Works for traits, including trait objects, but not structs 2017-12-17 10:13:09 +01:00
Matt Brubeck 3024c1434a Use Try syntax for Option in place of macros or match 2017-12-09 14:18:33 -08:00
Alex Crichton a2e2aba07d rustc: Migrate lang items to a query
This commit moves the calculation of the `LanguageItems` structure into a
query rather than being calculated before the `TyCtxt` exists, with the eventual
end goal of removing some `CrateStore` methods.
2017-09-05 07:37:57 -07:00
Zack M. Davis 1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Niko Matsakis 5fb0f0dc2e strip param-env from infcx 2017-06-01 13:31:09 -04:00
bors 4ed2edaafe Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakis
Decompose Adjustment into smaller steps and remove the method map.

The method map held method callee information for:
* actual method calls (`x.f(...)`)
* overloaded unary, binary, indexing and call operators
* *every overloaded deref adjustment* (many can exist for each expression)

That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with:
* a desire to compose adjustments more freely
* containing the autoderef logic better to avoid mutation within an inference snapshot
* not creating `TyFnDef` types which are incompatible with the original one
  * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs`
* to fix #3548 by explicitly writing autorefs for the RHS of comparison operators

Individual commits tell their own story, of "atomic" changes avoiding breaking semantics.

Future work based on this PR could include:
* removing the signature from `TyFnDef`, now that it's always "canonical"
  * some questions of variance remain, as subtyping *still* treats the signature differently
* moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits`
* allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments
* transitive coercions (e.g. reify or unsize after multiple steps of autoderef)

r? @nikomatsakis
2017-06-01 11:34:13 +00:00
Eduard-Mihai Burtescu 194fe695e3 rustc: decompose Adjustment into a vector of adjustment steps. 2017-06-01 08:59:47 +03:00
Eduard-Mihai Burtescu 4a754f224d rustc: replace autoderefs' use of MethodCallee with OverloadedDeref. 2017-06-01 08:59:47 +03:00
Eduard-Mihai Burtescu b4988f0792 rustc: keep overloaded autoderef MethodCallee's in Adjust. 2017-06-01 08:59:47 +03:00
Tobias Schottdorf e5e664fb07 Upgrade ProjectionTy's Name to a DefId
Part of #42171, in preparation for downgrading the contained `TraitRef` to
only its `substs`.
2017-05-31 12:35:13 -04:00
Oliver Schneider dd87eabd83 Remove need for &format!(...) or &&"" dances in `span_label` calls 2017-05-08 12:56:15 +02:00
Ariel Ben-Yehuda b7b3c232f7 refactor the handling of lvalue ops
Fixes #41604.
2017-04-30 15:49:04 +03:00
Eduard-Mihai Burtescu 3725cab5ac rustc_typeck: return InferOk from lookup_method_in_trait_adjusted. 2017-04-15 23:59:25 +03:00
Eduard-Mihai Burtescu 2ad196444b rustc_typeck: Autoderef::finalize is always called with one &hir::Expr. 2017-04-15 23:56:40 +03:00
Niko Matsakis bad79484fb avoid allocating a vector when the coercion sites are known upfront 2017-03-30 07:55:29 -04:00
Eduard-Mihai Burtescu 74bc7fda8c Overhaul coercion to use the lazy InferOk obligations passing. 2017-03-09 05:46:33 +02:00