Commit graph

352 commits

Author SHA1 Message Date
Oliver Scherer
26e9990198 Add a "diagnostic item" scheme
This allows lints and other diagnostics to refer to items
by a unique ID instead of relying on whacky path
resolution schemes that may break when items are
relocated.
2019-08-30 01:00:55 +02:00
Yuki Okushi
82f2b37635 Add Option<Span> to require_lang_item 2019-08-28 07:11:12 +09:00
Tyler Mandry
6fae7f8071 Wrap promoted generator fields in MaybeUninit
This prevents uninhabited fields from "infecting" the abi and
largest_niche of the generator layout.

This fixes a latent bug, where an uninhabited field could be promoted to
the generator prefix and cause the entire generator to become
uninhabited.
2019-07-29 12:17:49 -07:00
bjorn3
3427a14bdf Remove support for -Zlower-128bit-ops
It is broken and unused
2019-07-19 14:21:06 +02:00
bors
c6a9e766f9 Auto merge of #62339 - pnkfelix:issue-61188-use-visitor-for-structural-match-check, r=nikomatsakis
use visitor for #[structural_match] check

This changes the code so that we recur down the structure of a type of a const (rather than just inspecting at a shallow one or two levels) when we are looking to see if it has an ADT that did not derive `PartialEq` and `Eq`.

Fix #61188

Fix #62307

Cc #62336
2019-07-10 12:26:44 +00:00
Felix S. Klock II
507ee7242a Note that eq_trait denotes trait PartialEq, not Eq, so you don't have to go to trait def to double-check. 2019-07-08 11:50:52 +02:00
ljedrz
37d7e1f22a rename hir::map::local_def_id_from_hir_id to local_def_id 2019-07-04 12:53:12 +02:00
Nathan Corbyn
88194200e5 Add suggestion for missing .await keyword 2019-06-27 13:56:55 +01:00
Eduard-Mihai Burtescu
f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +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
Nicholas Nethercote
26451ef7b5 Avoid unnecessary internings.
Most involving `Symbol::intern` on string literals.
2019-05-27 13:58:38 +10:00
Nicholas Nethercote
fb084a48e2 Pass a Symbol to check_name, emit_feature_err, and related functions. 2019-05-13 09:29:22 +10:00
Mazdak Farrokhzad
47768b2613 Document + Cleanup lang_items.rs 2019-05-08 15:31:09 +02:00
John Kåre Alsaker
3936aff216 Use derive macro for HashStable 2019-03-13 00:03:13 +01:00
ljedrz
77fa041fc1 hir: remove NodeId from Item 2019-03-02 07:48:52 +01:00
Mark Mansi
e957ed9d10 move librustc to 2018 2019-02-05 12:45:47 -06:00
Wim Looman
be3989301a Update generator transform and generated function signature 2019-01-27 22:58:59 +01:00
Wim Looman
730b18b6e5 Mark static generators as !Unpin 2019-01-27 22:58:59 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Michael Hewson
153f5a7892 Stabilize Rc, Arc and Pin as method receivers
This lets you write methods using `self: Rc<Self>`, `self: Arc<Self>`, `self: Pin<&mut Self>`, `self: Pin<Box<Self>`, and other combinations involving `Pin` and another stdlib receiver type, without needing the `arbitrary_self_types`. Other user-created receiver types can be used, but they still require the feature flag to use.

This is implemented by introducing a new trait, `Receiver`, which the method receiver's type must implement if the `arbitrary_self_types` feature is not enabled. To keep composed receiver types such as `&Arc<Self>` unstable, the receiver type is also required to implement `Deref<Target=Self>` when the feature flag is not enabled.

This lets you use `self: Rc<Self>` and `self: Arc<Self>` in stable Rust, which was not allowed previously. It was agreed that they would be stabilized in #55786. `self: Pin<&Self>` and other pinned receiver types do not require the `arbitrary_self_types` feature, but they cannot be used on stable because `Pin` still requires the `pin` feature.
2018-12-20 01:14:01 -05:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
John Kåre Alsaker
a70babed03 Use a function to access the Hir map to be able to turn it into a query later 2018-12-06 17:24:36 +01:00
Dan Robertson
08140878fe
libcore: Add va_list lang item and intrinsics
- Add the llvm intrinsics used to manipulate a va_list.
 - Add the va_list lang item in order to allow implementing
   VaList in libcore.
2018-11-26 22:56:19 +00:00
kennytm
6091696cfd
Rollup merge of #55601 - petrochenkov:featissue, r=pnkfelix
Fix tracking issue numbers for some unstable features

And also remove deprecated unstable `#[panic_implementation]` attribute that was superseded by stable `#[panic_handler]` and doesn't have an open tracking issue.
2018-11-06 17:08:08 +08:00
Vadim Petrochenkov
29d2ceae7c Remove deprecated unstable #[panic_implementation]
It was superseded by `#[panic_handler]`
2018-11-02 02:22:30 +03:00
Michael Hewson
f12c250e40 Replace CoerceSized trait with DispatchFromDyn
Rename `CoerceSized` to `DispatchFromDyn`, and reverse the direction so that, for example, you write

```
impl<T: Unsize<U>, U> DispatchFromDyn<*const U> for *const T {}
```

instead of

```
impl<T: Unsize<U>, U> DispatchFromDyn<*const T> for *const U {}
```

this way the trait is really just a subset of `CoerceUnsized`.

The checks in object_safety.rs are updated for the new trait, and some documentation and method names in there are updated for the new trait name — e.g. `receiver_is_coercible` is now called `receiver_is_dispatchable`. Since the trait now works in the opposite direction, some code had to updated here for that too.

I did not update the error messages for invalid `CoerceSized` (now `DispatchFromDyn`) implementations, except to find/replace `CoerceSized` with `DispatchFromDyn`. Will ask for suggestions in the PR thread.
2018-11-01 18:16:59 -04:00
Michael Hewson
be80a79a1e Add CoerceSized trait and lang item
This trait is more-or-less the reverse of CoerceUnsized, and will be
used for object-safety checks. Receiver types like `Rc` will have to
implement `CoerceSized` so that methods that use `Rc<Self>` as the
receiver will be considered object-safe.
2018-11-01 18:15:19 -04:00
Oliver Scherer
ee81739dc1 Deprecate the FxHashMap() and FxHashSet() constructor function hack 2018-10-19 14:34:44 +02:00
David Wood
2ecce7ccc5
Extend lang items to assert correct target.
This commit extends the existing lang items functionality to assert
that the `#[lang_item]` attribute is only found on the appropriate item
for any given lang item. That is, language items representing traits
must only ever have their corresponding attribute placed on a trait, for
example.
2018-10-11 19:36:51 +02:00
ljedrz
786b86ef5d rustc/middle: whitespace & formatting fixes 2018-10-06 10:25:59 +02:00
ljedrz
c2b3aa9939 rustc/middle: improve some patterns 2018-10-06 10:24:52 +02:00
David Wood
da4a12038b
Introduce language items for Arc and Rc.
This commit introduces language items for `Arc` and `Rc` so that types
can later be checked to be `Arc` or `Rc` in the NLL borrow checker. The
`lang` attribute is currently limited to `stage1` as it requires a
compiler built with knowledge of the expected language items.
2018-10-01 13:50:21 +02:00
Oliver Schneider
d272e2f6e2 Get rid of the non_zero lang item in favour of arbitrary range specifications 2018-09-11 11:19:48 +02:00
Jorge Aparicio
a774c81f98 add #[panic_handler]; deprecate #[panic_implementation] 2018-08-23 20:58:55 +02:00
Oliver Schneider
bb78426ca8 Allow panicking with string literal messages inside constants 2018-08-22 18:28:57 +02:00
Eduard-Mihai Burtescu
591eeff22a Change ManuallyDrop from an union to a struct and make it a lang item. 2018-07-25 21:01:02 +03:00
Simon Sapin
239ec7d2dc Implement #[alloc_error_handler]
This to-be-stable attribute is equivalent to `#[lang = "oom"]`.
It is required when using the alloc crate without the std crate.
It is called by `handle_alloc_error`, which is in turned called
by "infallible" allocations APIs such as `Vec::push`.
2018-07-09 23:13:24 +02:00
Jorge Aparicio
e44ad61a2d implement #[panic_implementation] 2018-06-03 13:46:19 +02:00
Simonas Kazlauskas
d45378216b Change align_offset to support different strides
This is necessary if we want to implement `[T]::align_to` and is more
useful in general.

This implementation effort has begun during the All Hands and represents
a month of my futile efforts to do any sort of maths. Luckily, I
found the very very nice Chris McDonald (cjm) on IRC who figured out the
core formulas for me! All the thanks for existence of this PR go to
them!

Anyway… Those formulas were mangled by yours truly into the arcane forms
you see here to squeeze out the best assembly possible on most of the
modern architectures (x86 and ARM were evaluated in practice). I mean,
just look at it: *one actual* modulo operation and everything else is
just the cheap single cycle ops! Admitedly, the naive solution might be
faster in some common scenarios, but this code absolutely butchers the
naive solution on the worst case scenario.

Alas, the result of this arcane magic also means that the code pretty
heavily relies on the preconditions holding true and breaking those
preconditions will unleash the UB-est of all UBs! So don’t.
2018-05-17 22:46:02 +03:00
Steven Fackler
e513c1bd31 Replace GlobalAlloc::oom with a lang item 2018-04-22 10:08:17 -07:00
Simon Sapin
8a374f2827 Add some f32 and f64 inherent methods in libcore
… previously in the unstable core::num::Float trait.

Per https://github.com/rust-lang/rust/issues/32110#issuecomment-379503183,
the `abs`, `signum`, and `powi` methods are *not* included for now
since they rely on LLVM intrinsics and we haven’t determined yet whether
those instrinsics lower to calls to libm functions on any platform.
2018-04-21 09:47:37 +02:00
Simon Sapin
f0705bf033 Replace StrExt with inherent str methods in libcore 2018-04-21 09:47:37 +02:00
Simon Sapin
90f29fbdb1 Replace SliceExt with inherent [T] methods in libcore 2018-04-21 09:45:18 +02:00
Simon Sapin
de8ed6a1d6 Move non-allocating [u8] inherent methods to libcore
Fixes #45803
2018-04-21 09:45:18 +02:00
Oliver Schneider
918b6d7633
Produce instead of pointers 2018-03-08 08:08:14 +01:00
Esteban Küber
e6af9ebea2 Point at unknown lang item attribute 2018-01-23 21:36:40 -08:00
Bastian Köcher
d7918fb2e8 Implements RFC 1937: ? in main
This is the first part of the RFC 1937 that supports new
`Termination` trait in the rust `main` function.
2017-12-26 12:26:39 +01:00
kennytm
788fed8158 Rollup merge of #46259 - bjorn3:display_lang_item, r=nagisa
Derive Debug for LangItem
2017-11-26 15:01:38 +08:00