Commit graph

94 commits

Author SHA1 Message Date
Camille GILLOT
5fb4648757 Take a LocalDefId in expect_*item. 2021-11-28 21:09:45 +01:00
inquisitivecrystal
9a987b0466 Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00
Gary Guo
02c1774cd3 Give inline const separate DefKind 2021-11-07 03:59:06 +00:00
Mark Rousskov
3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
Matthias Krüger
87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
bors
aa5740c715 Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakis
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
2021-10-23 12:51:15 +00:00
Yuki Okushi
6f0acbcbd0
Rollup merge of #88644 - eopb:abstractconst_leaf_subst, r=lcnr
`AbstractConst` private fields

Calls `subst` in `AbstractConst::root` when `Node` is `Leaf`.

r? ``@lcnr``
2021-10-21 14:11:03 +09:00
Santiago Pastorino
6975afd141
Add polarity to TraitPredicate 2021-10-20 12:10:41 -03:00
lcnr
00e5abe9b6 allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
bors
b27661eb33 Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillot
Fix clippy lints

I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.
2021-10-02 10:52:09 +00:00
Guillaume Gomez
759eba0a08 Fix clippy lints 2021-10-01 23:17:19 +02:00
Camille GILLOT
db9fea508a Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
bors
ac2d9fc509 Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074.

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first.

Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately.

It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c87 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-21 19:25:49 +00:00
Mark Rousskov
c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
Camille GILLOT
d7795d302a Do not store visibility in *ItemRef. 2021-09-20 00:29:53 +02:00
Ellen
8c7954dc42 add a CastKind to Node::Cast 2021-09-09 01:32:03 +01:00
Ellen
406d2ab95d rename mir -> thir around abstract consts 2021-09-09 01:32:03 +01:00
Ellen
c170dcf04c tidy 2021-09-09 01:32:03 +01:00
Ellen
4483c2bdf6 dont support blocks 2021-09-09 01:32:03 +01:00
Ellen
9b2913814b as casts and block exprs 2021-09-09 01:32:03 +01:00
Ellen
2987f4ba42 WIP state 2021-09-09 01:32:03 +01:00
Ethan Brierley
fc5633fed6 Make fields on AbstractConst private 2021-09-04 16:28:55 +01:00
Ethan Brierley
85d6029c13 AbstractConst::root: Always run subst when Node is Leaf 2021-09-04 15:44:26 +01:00
Camille GILLOT
d119a13137 Rename walk_crate. 2021-09-02 19:23:11 +02:00
Camille GILLOT
7ec973d9ce Stop using walk_crate. 2021-09-02 19:08:58 +02:00
Ellen
fcc2badf9b rename const_evaluatable_checked to generic_const_exprs
2021-08-30 11:00:21 +02:00
inquisitivecrystal
8c62fa0575 Treat macros as HIR items 2021-08-28 00:16:34 -07:00
lcnr
caa975c89e use ty::Unevaluated instead of def substs pair 2021-08-26 11:00:30 +02:00
lcnr
bfaf13af4e make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
lcnr
f4b606fd17 require a tcx for TypeVisitor 2021-08-26 10:54:01 +02:00
bors
f66e825f73 Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`

Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.
2021-08-24 03:58:22 +00:00
Frank Steffahn
bf88b113ea Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
Aaron Hill
af46699f81
Remove Session.used_attrs and move logic to CheckAttrVisitor
Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.
2021-08-21 13:27:27 -05:00
Vadim Petrochenkov
1fdea560d2 rustc_privacy: Replace HirIds and DefIds with LocalDefIds where possible 2021-08-19 00:01:12 +03:00
Deadbeef
32390a0df6
move Constness into TraitPredicate 2021-08-13 09:26:33 +00:00
bors
bb744e1e9f Auto merge of #87568 - petrochenkov:localevel, r=cjgillot
rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables

and passes using those tables - primarily privacy checking, stability checking and dead code checking.

All these passes work with definitions rather than with arbitrary HIR nodes.
r? `@cjgillot`
cc `@lambinoo` (#87487)
2021-08-04 02:04:04 +00:00
Vadim Petrochenkov
b08576b2ad rustc: Replace HirIds with LocalDefIds in AccessLevels tables
and passes using them - primarily privacy checking, stability checking and dead code checking.

WIP
2021-07-31 19:31:29 +03:00
Jade
3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
kadmin
8759f00c73 Actually infer args in visitors 2021-07-26 21:15:18 +00:00
kadmin
3605675bb1 Add inferred args to typeck 2021-07-25 07:28:51 +00:00
kadmin
417b098cfc Add generic arg infer 2021-07-25 07:28:51 +00:00
Camille GILLOT
071a047dc7 Make resolutions a query. 2021-07-06 19:22:27 +02: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
Camille Gillot
0f0f3138cb
Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
Camille GILLOT
5d9f96ab27 Make resolutions a query. 2021-05-30 19:47:00 +02:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Camille GILLOT
9849327384 Use () for privacy. 2021-05-12 13:58:45 +02:00
klensy
f43ee8ebf6 fix few typos 2021-04-19 15:57:08 +03:00
kadmin
ea2af70466 Update with comments
A bunch of nits fixed, and a new test for pretty printing the AST.
2021-03-23 17:16:20 +00:00