| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
allow eq constraints on associated constants
Updates #70256
(cc `@varkor,` `@Centril)`
|
|
Add some more attribute validation
This adds some more validation for the position of attributes:
* `link` is only valid on an `extern` block
* `windows_subsystem` and `no_builtins` are only valid at the crate level
|
|
Also prevent ICE when adding a const in associated const equality.
|
|
r=Aaron1011
Implement `#[rustc_must_implement_one_of]` attribute
This PR adds a new attribute — `#[rustc_must_implement_one_of]` that allows changing the "minimal complete definition" of a trait. It's similar to GHC's minimal `{-# MINIMAL #-}` pragma, though `#[rustc_must_implement_one_of]` is weaker atm.
Such attribute was long wanted. It can be, for example, used in `Read` trait to make transitions to recently added `read_buf` easier:
```rust
#[rustc_must_implement_one_of(read, read_buf)]
pub trait Read {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
let mut buf = ReadBuf::new(buf);
self.read_buf(&mut buf)?;
Ok(buf.filled_len())
}
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> {
default_read_buf(|b| self.read(b), buf)
}
}
impl Read for Ty0 {}
//^ This will fail to compile even though all `Read` methods have default implementations
// Both of these will compile just fine
impl Read for Ty1 {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> { /* ... */ }
}
impl Read for Ty2 {
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { /* ... */ }
}
```
For now, this is implemented as an internal attribute to start experimenting on the design of this feature. In the future we may want to extend it:
- Allow arbitrary requirements like `a | (b & c)`
- Allow multiple requirements like
- ```rust
#[rustc_must_implement_one_of(a, b)]
#[rustc_must_implement_one_of(c, d)]
```
- Make it appear in rustdoc documentation
- Change the syntax?
- Etc
Eventually, we should make an RFC and make this (or rather similar) attribute public.
---
I'm fairly new to compiler development and not at all sure if the implementation makes sense, but at least it passes tests :)
|
|
includes minor refactorings
|
|
These attributes are only checked at the crate root, so they should
have a warning if they are used anywhere else.
|
|
Useful for thin wrapper attributes that are best passed as value instead
of reference.
|
|
Use "(associated) function" terminology instead of "method".
Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
Create rustdoc_internals feature gate
As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag.
This is pretty much what it would look like (needs to update the tests too).
The tracking issue is https://github.com/rust-lang/rust/issues/90418.
What do you think ``@rust-lang/rustdoc`` ?
|
|
|
|
Split inline const to two feature gates and mark expression position inline const complete
This PR splits inline const in pattern position into its own `#![feature(inline_const_pat)]` feature gate, and make the usage in expression position complete.
I think I have resolved most outstanding issues related to `inline_const` with #89561 and other PRs. The only thing left that I am aware of is #90150 and the lack of lifetime checks when inline const is used in pattern position (FIXME in #89561). Implementation-wise when used in pattern position it has to be lowered during MIR building while in expression position it's evaluated only when monomorphizing (just like normal consts), so it makes some sense to separate it into two feature gates so one can progress without being blocked by another.
``@rustbot`` label: T-compiler F-inline_const
|
|
|
|
|
|
|
|
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
|
|
This should significantly reduce the frequency of merge conflicts.
|
|
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
|
|
Stabilize `const_raw_ptr_deref` for `*const T`
This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.
closes https://github.com/rust-lang/rust/issues/51911
|
|
|
|
|
|
This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is placed behind the
`const_raw_mut_ptr_deref` feature gate.
|
|
Split doc_cfg and doc_auto_cfg features
Part of #90497.
With this feature, `doc_cfg` won't pick up items automatically anymore.
cc `@Mark-Simulacrum`
r? `@jyn514`
|
|
Clarify what to do with accepted feature gates
The documentation only referenced `removed.rs`, but feature gates for
accepted features move to `accepted.rs`.
|
|
|
|
|
|
The documentation only referenced `removed.rs`, but feature gates for
accepted features move to `accepted.rs`.
|
|
|
|
|
|
Add rustc lint, warning when iterating over hashmaps
r? rust-lang/wg-incr-comp
|
|
Implement coherence checks for negative trait impls
The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3).
This feature is necessary to handle the following from impl on box.
```rust
impl From<&str> for Box<dyn Error> { ... }
```
Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile.
We would have this in `alloc`:
```rust
impl From<&str> for Box<dyn Error> {} // A
impl<E> From<E> for Box<dyn Error> where E: Error {} // B
```
and this in `core`:
```rust
trait Error {}
impl !Error for &str {}
```
r? `@nikomatsakis`
This PR was built on top of `@yaahc` PR #85764.
Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
|
|
add feature flag for `type_changing_struct_update`
This implements the PR0 part of the mentoring notes within #86618.
overrides the previous inactive #86646 pr.
r? ```@nikomatsakis```
|
|
|
|
|
|
|
|
This reverts commit 7a62f29f3171767090949778ce0f161e930706b9.
|
|
Add `const_eval_select` intrinsic
Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime.
See https://github.com/rust-lang/const-eval/issues/7 for previous discussion.
r? `@oli-obk.`
|
|
|
|
Feature gate the non_exhaustive_omitted_patterns lint
Fixes https://github.com/rust-lang/rust/issues/89374
Add the machinery to gate the new `non_exhaustive_omitted_patterns` lint.
relates to https://github.com/rust-lang/rust/pull/89105 and https://github.com/rust-lang/rust/pull/89423
|
|
Fix stabilization version for `bindings_after_at`
According to the release notes and its PR milestone, it was stabilized
in 1.56.0.
|
|
Actually add the feature to the lints ui test
Add tracking issue to the feature declaration
Rename feature gate to non_exhaustive_omitted_patterns_lint
Add more omitted_patterns lint feature gate
|
|
* Remove "bool_to_options" feature
* Update version for compiler feature
* rustfmt
|
|
According to the release notes and its PR milestone, it was stabilized
in 1.56.0.
|
|
|