Commit graph

3172 commits

Author SHA1 Message Date
Ashley Mannix e1d70bc697
Rollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink
Avoid logging the whole MIR body in SimplifyCfg
2021-01-18 21:53:31 +10:00
Ashley Mannix 064e47b99e
Rollup merge of #81116 - bugadani:body-span, r=wesleywiser
ConstProp: Copy body span instead of querying it
2021-01-18 21:53:30 +10:00
Ashley Mannix b4defec768
Rollup merge of #81105 - LingMan:init_directly, r=nagisa
Initialize a few variables directly

Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.
2021-01-18 21:53:28 +10:00
Ashley Mannix d3ff9ac8e8
Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk
prevent potential bug in `encode_with_shorthand`.

see https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Remove.20PredicateKind.20in.20favor.20of.20only.20Bin.E2.80.A6.20compiler-team.23397/near/223012169
2021-01-18 21:53:26 +10:00
Ashley Mannix c7ca540da2
Rollup merge of #81071 - osa1:fix_81006, r=estebank
rustc_parse_format: Fix character indices in find_skips

Fixes #81006
2021-01-18 21:53:24 +10:00
bors 86e0ff47a0 Auto merge of #80995 - tmandry:instrument-method-checker, r=lcnr
Add tracing instrumentation to method typeck

I was recently digging into how this code works, and this instrumentation was helpful.
2021-01-18 08:39:31 +00:00
bors 0677d97293 Auto merge of #80865 - oliviacrain:proj_based, r=RalfJung
Use PlaceRef projection abstractions more consistently in rustc_mir

PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate.

See associated issue: rust-lang/rust#80647.

r? `@RalfJung`
2021-01-18 05:44:40 +00:00
bors 4253153db2 Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`
2021-01-17 20:49:11 +00:00
bors 1f0fc02cc8 Auto merge of #80524 - jyn514:unknown-tool-lints, r=flip1995,matthewjasper
Don't make tools responsible for checking unknown and renamed lints

Previously, clippy (and any other tool emitting lints) had to have their
own separate UNKNOWN_LINTS pass, because the compiler assumed any tool
lint could be valid. Now, as long as any lint starting with the tool
prefix exists, the compiler will warn when an unknown lint is present.

This may interact with the unstable `tool_lint` feature, which I don't entirely understand, but it will take the burden off those external tools to add their own lint pass, which seems like a step in the right direction to me.

- Don't mark `ineffective_unstable_trait_impl` as an internal lint
- Use clippy's more advanced lint suggestions
- Deprecate the `UNKNOWN_CLIPPY_LINTS` pass (and make it a no-op)
- Say 'unknown lint `clippy::x`' instead of 'unknown lint x'

This is tested by existing clippy tests. When https://github.com/rust-lang/rust/pull/80527 merges, it will also be tested in rustdoc tests. AFAIK there is no way to test this with rustc directly.
2021-01-17 17:52:01 +00:00
Jack Huey c4376ba24a
Whitespace and typo 2021-01-17 12:50:04 -05:00
Jack Huey d797a85491 Add comment about Encodable/Decodable impl 2021-01-17 12:32:05 -05:00
Tomasz Miąsko c7bad7ba5d Avoid logging the whole MIR body in SimplifyCfg 2021-01-17 15:57:21 +01:00
Ömer Sinan Ağacan 9111e9dd01 rustc_parse_format: Fix character indices in find_skips
Fixes #81006
2021-01-17 17:40:58 +03:00
Dániel Buga 428f948096 Copy body span instead of querying it 2021-01-17 14:50:47 +01:00
Mara Bos 7e2425ab73
Rollup merge of #81095 - LingMan:unwrap, r=oli-obk
Use Option::unwrap_or instead of open-coding it

r? ```@oli-obk``` Noticed this while we were talking about the other PR just now 😆
```@rustbot``` modify labels +C-cleanup +T-compiler
2021-01-17 12:24:59 +00:00
Mara Bos 34e073f44b
Rollup merge of #81084 - LingMan:map, r=oli-obk
Use Option::map instead of open-coding it

r? ```@oli-obk```
```@rustbot``` modify labels +C-cleanup +T-compiler
2021-01-17 12:24:58 +00:00
Mara Bos 19370a4860
Rollup merge of #81080 - bugadani:vec-diag, r=oli-obk,m-ou-se
Force vec![] to expression position only

r? `@oli-obk`

I went with the lazy way of only changing what broke. I moved the test to ui/macros because the diagnostics no longer give suggestions.

Closes #61933
2021-01-17 12:24:54 +00:00
Mara Bos 8f2ee87965
Rollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa
Remove is_dllimport_foreign_item definition from cg_ssa

It overwrites the definition from rustc_metadata.

cc https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/query.20provided.20twice/near/218927806

Marked as draft to test if this breaks anything.
2021-01-17 12:24:51 +00:00
Mara Bos ffcbeefd64
Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper
resolve: Simplify collection of traits in scope

"Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace.

Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore.
I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351.

In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits.
It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway.

The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names.
I'm not sure whether it is desirable or not, but I think it's acceptable for now.
The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope.
If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well.

---

The PR also contains a couple of pure refactorings
- Scope walk is done by using `visit_scopes` instead of a hand-rolled version.
- Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all.

r? ```@matthewjasper```
2021-01-17 12:24:47 +00:00
Mara Bos 19f97802ca
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```
2021-01-17 12:24:44 +00:00
Mara Bos 3d5e7e0f47
Rollup merge of #80031 - petrochenkov:builtina, r=estebank
resolve: Reject ambiguity built-in attr vs different built-in attr

Fixes https://github.com/rust-lang/rust/issues/79798.

Resolution ensures that inert attributes cannot be used through imports like this, but built-in attributes don't go through initial resolution (only through resolution validation), so we have to keep some extra data (the built-in attribute name) to prevent it from happening.
2021-01-17 12:24:41 +00:00
Mara Bos f783871ab1
Rollup merge of #79298 - lcnr:new-elysium, r=matthewjasper
correctly deal with late-bound lifetimes in anon consts

adds support for using late bound lifetimes of the parent context in anon consts.
```rust
#![feature(const_generics)]
const fn inner<'a>() -> usize where &'a (): Sized { 3 }

fn test<'a>() {
    let _: [u8; inner::<'a>()];
}
```
The lifetime `'a` is late bound in `test` so it's not included in its generics but is instead dealt with separately in borrowck.
This didn't previously work for anon consts as they have to use the late bound lifetimes of their parent which has
to be explicitly handled.

r? ```@matthewjasper``` cc ```@varkor``` ```@eddyb```
2021-01-17 12:24:39 +00:00
Ryan Levick f07dd6d41a Remove dead code 2021-01-17 12:45:48 +01:00
Jack Huey c76f47832a Don't derive TyEncodable/TyDecodable for Binder 2021-01-17 04:13:51 -05:00
Jack Huey 674735b109 Impl EncodableWithShorthand for PredicateKind 2021-01-17 02:49:30 -05:00
LingMan 0a74e17211 Initialize a few variables directly
Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.
2021-01-17 02:07:37 +01:00
Jack Huey f2ed9a3a8c Can't use EncodableWithShorthand for Predicate 2021-01-16 19:17:59 -05:00
Jack Huey dcad9f1893 More review comments 2021-01-16 18:56:37 -05:00
Jack Huey 3dea68de1d Review changes 2021-01-16 18:56:37 -05:00
Jack Huey 66c179946b Use no_bound_vars 2021-01-16 18:50:34 -05:00
Jack Huey 476bd53058 Cleanup 2021-01-16 18:50:34 -05:00
Jack Huey e76476afe4 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey 876192e8cd fold_with not super_fold_with in TypeFoldable impl for Predicate 2021-01-16 18:40:47 -05:00
Jack Huey 4cd6f85a07 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey 4cb3d6f983 Intermediate formatting and such 2021-01-16 18:40:47 -05:00
Jack Huey 8278314a8b Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
Bastian Kauschke 84b056d597 prevent potential bug in encode_with_shorthand. 2021-01-17 00:34:54 +01:00
Vadim Petrochenkov 7f9a2cfa1b resolve: Reject ambiguity built-in attr vs different built-in attr 2021-01-17 01:48:17 +03:00
bors 8a6518427e Auto merge of #81089 - m-ou-se:rollup-z7iac6i, r=m-ou-se
Rollup of 17 pull requests

Successful merges:

 - #78455 (Introduce {Ref, RefMut}::try_map for optional projections in RefCell)
 - #80144 (Remove giant badge in README)
 - #80614 (Explain why borrows can't be held across yield point in async blocks)
 - #80670 (TrustedRandomAaccess specialization composes incorrectly for nested iter::Zips)
 - #80681 (Clarify what the effects of a 'logic error' are)
 - #80764 (Re-stabilize Weak::as_ptr and friends for unsized T)
 - #80901 (Make `x.py --color always` apply to logging too)
 - #80902 (Add a regression test for #76281)
 - #80941 (Do not suggest invalid code in pattern with loop)
 - #80968 (Stabilize the poll_map feature)
 - #80971 (Put all feature gate tests under `feature-gates/`)
 - #81021 (Remove doctree::Import)
 - #81040 (doctest: Reset errors before dropping the parse session)
 - #81060 (Add a regression test for #50041)
 - #81065 (codegen_cranelift: Fix redundant semicolon warn)
 - #81069 (Add sample code for Rc::new_cyclic)
 - #81081 (Add test for #34792)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-16 20:26:20 +00:00
LingMan 5a706cfc49 Use Option::unwrap_or instead of open-coding it 2021-01-16 20:13:06 +01:00
LingMan 76003f31f1 Use Option::map instead of open-coding it 2021-01-16 20:05:02 +01:00
flip1995 5e3df4266a
More advanced unknown lint suggestion
This copies the unknown_lints code clippy uses for its
unknown_clippy_lints lint to rustc. The unknown_clippy_lints code is
more advanced, because it doesn't suggest renamed or removed lints and
correctly suggest lower casing lints.
2021-01-16 19:44:46 +01:00
Bastian Kauschke 15f0921d0c correctly deal with late-bound lifetimes in anon consts 2021-01-16 19:27:42 +01:00
Mara Bos 61be4e8024
Rollup merge of #81065 - osa1:cranelift_semicolon_warning, r=jyn514
codegen_cranelift: Fix redundant semicolon warn
2021-01-16 17:30:13 +00:00
Mara Bos 79a8499f77
Rollup merge of #80941 - JohnTitor:ref-mut-pat-in-loops, r=varkor
Do not suggest invalid code in pattern with loop

Fixes #80913
2021-01-16 17:30:02 +00:00
Mara Bos af5b0d9883
Rollup merge of #80614 - 1000teslas:issue-78938-fix, r=tmandry
Explain why borrows can't be held across yield point in async blocks

For https://github.com/rust-lang/rust/issues/78938.
2021-01-16 17:29:49 +00:00
bors 492b83c697 Auto merge of #80290 - RalfJung:less-intrinsic-write, r=lcnr
implement ptr::write without dedicated intrinsic

This makes `ptr::write` more consistent with `ptr::write_unaligned`, `ptr::read`, `ptr::read_unaligned`, all of which are implemented in terms of `copy_nonoverlapping`.

This means we can also remove `move_val_init` implementations in codegen and Miri, and its special handling in the borrow checker.

Also see [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/ptr.3A.3Aread.20vs.20ptr.3A.3Awrite).
2021-01-16 17:28:32 +00:00
Olivia Crain 65b5e4386b Use PlaceRef more consistently in rustc_mir 2021-01-16 10:44:23 -06:00
bors 63a83c5f55 Auto merge of #81077 - bugadani:shrink, r=Mark-Simulacrum
Remove unnecessary manual shrink_to_fit calls
2021-01-16 14:04:43 +00:00
Dániel Buga dc932cdf88 Remove unnecessary manual shrink_to_fit calls 2021-01-16 14:02:36 +01:00