Commit Graph

2083 Commits

Author SHA1 Message Date
Camille GILLOT
27c60bad8a Remove Pat pre-lowering. 2020-11-23 19:02:47 +01:00
Camille GILLOT
6e17ab57fc Lower if let before the arms. 2020-11-23 18:55:59 +01:00
bors
ae6aa22cf2 Auto merge of #78646 - tgnottingham:packed_fingerprints, r=nnethercote
Use PackedFingerprint in DepNode to reduce memory consumption
2020-11-20 11:11:19 +00:00
Tyson Nottingham
142932ab19 Set unaligned_references lint to deny in rustc_data_structures
To detect misuse of private packed field in `PackedFingerprint`.
2020-11-20 01:13:15 -08:00
bors
5c45969502 Auto merge of #79192 - tmiasko:naked-noinline, r=oli-obk
Never inline naked functions

The `#[naked]` attribute disabled prologue / epilogue emission for the
function and it is responsibility of a developer to provide them. The
compiler is no position to inline such functions correctly.

Disable inlining of naked functions at LLVM and MIR level.

Closes #60919.
2020-11-20 06:01:49 +00:00
bors
74285eb3a8 Auto merge of #78088 - fusion-engineering-forks:panic-fmt-lint, r=estebank
Add lint for panic!("{}")

This adds a lint that warns about `panic!("{}")`.

`panic!(msg)` invocations with a single argument use their argument as panic payload literally, without using it as a format string. The same holds for `assert!(expr, msg)`.

This lints checks if `msg` is a string literal (after expansion), and warns in case it contained braces. It suggests to insert `"{}", ` to use the message literally, or to add arguments to use it as a format string.

![image](https://user-images.githubusercontent.com/783247/96643867-79eb1080-1328-11eb-8d4e-a5586837c70a.png)

This lint is also a good starting point for adding warnings about `panic!(not_a_string)` later, once [`panic_any()`](https://github.com/rust-lang/rust/pull/74622) becomes a stable alternative.
2020-11-20 03:40:20 +00:00
Tomasz Miąsko
c2fb99984c Never inline naked functions
The `#[naked]` attribute disabled prologue / epilogue emission for the
function and it is responsibility of a developer to provide them. The
compiler is no position to inline such functions correctly.

Disable inlining of naked functions at LLVM and MIR level.
2020-11-20 00:00:00 +00:00
Dylan DPC
95da425593
Rollup merge of #79212 - LeSeulArtichaut:rustc-ty, r=jonas-schievink
Move `rustc_ty` -> `rustc_ty_utils`

Implements MCP rust-lang/compiler-team#387.
r? `@jonas-schievink`
2020-11-19 23:58:48 +01:00
Dylan DPC
084fc293eb
Rollup merge of #79193 - tmiasko:revert-78969-normalize, r=davidtwco
Revert #78969 "Normalize function type during validation"

Closes #79066.
Reopens #78442.
2020-11-19 23:58:43 +01:00
Dylan DPC
8216b359e5
Rollup merge of #79185 - petrochenkov:derattr2, r=Aaron1011
expand/resolve: Pre-requisites to "Turn `#[derive]` into a regular macro attribute"

Miscellaneous refactorings and error reporting changes extracted from https://github.com/rust-lang/rust/pull/79078.

Unlike https://github.com/rust-lang/rust/pull/79078 this PR doesn't make any observable changes to the language or library.
r? ```@Aaron1011```
2020-11-19 23:58:42 +01:00
LeSeulArtichaut
f59d03038c Move rustc_ty -> rustc_ty_utils 2020-11-19 21:57:29 +01:00
Vadim Petrochenkov
d575aa4d58 expand: Mark some dead code in derive expansion as unreachable 2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
cd2177f3de expand: Stop derive expansion un unexpected targets early
Collect derive placeholders using `collect` instead of `push`
2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
ec547202b4 expand: Cleanup attribute collection in invocation collector 2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
dfb690eaa9 resolve/expand: Misc cleanup 2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
68f94e94ed resolve: Centralize some error reporting for unexpected macro resolutions 2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
69894ce9ac resolve: Introduce a separate NonMacroAttrKind for legacy derive helpers 2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
e7ee4d66ce expand: Move fully_configure to config.rs 2020-11-19 19:25:20 +03:00
Vadim Petrochenkov
b49fbc9432 expand: Tell built-in macros whether we are currently in forced expansion mode 2020-11-19 19:25:20 +03:00
Dylan DPC
b5fffdc12b
Rollup merge of #79164 - varkor:unbraced-single-segment-const-arguments, r=petrochenkov
Permit standalone generic parameters as const generic arguments in macros

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

r? ```@petrochenkov```
2020-11-19 16:26:44 +01:00
Dylan DPC
5c7d530b5e
Rollup merge of #79149 - sexxi-goose:upvar_ref, r=nikomatsakis
Move capture lowering from THIR to MIR

This allows us to:
- Handle precise Places captured by a closure directly in MIR. Handling
  captures in MIR is easier since we can rely on/ tweak PlaceBuilder to
  generate `mir::Place`s that resemble how we store captures (`hir::Place`).

- Handle `let _ = x` case when feature `capture_disjoint_fields`
  is enabled directly in MIR. This is required to be done in MIR since
  patterns are desugared in MIR.

Closes: rust-lang/project-rfc-2229#25

r? ```@nikomatsakis```
2020-11-19 16:26:39 +01:00
Dylan DPC
2fdcd245df
Rollup merge of #79117 - cjkenn:mir-fuel, r=oli-obk
add optimization fuel checks to some mir passes

Fixes #77402

Inserts a bunch of calls to `consider_optimizing`. Note that `consider_optimizing` is the method that actually decrements the fuel count, so the point at which it's called is when the optimization takes place, from a fuel perspective. This means that where we call it has some thought behind it:

1. We probably don't want to decrement the fuel count before other simple checks, otherwise we count an optimization as being performed even if nothing was mutated (ie. it returned early).
2. In cases like `InstCombine`, where we gather optimizations in a pass and then mutate values, we probably would rather skip the gathering pass for performance reasons rather than skip the mutations afterwards.
2020-11-19 16:26:35 +01:00
Dylan DPC
470f768c97
Rollup merge of #79110 - estebank:issue-58964, r=oli-obk
Remove redundant notes in E0275

Fix #58964.
2020-11-19 16:26:31 +01:00
Dylan DPC
05ff58e645
Rollup merge of #79101 - tmiasko:lower-func-type, r=jonas-schievink
Don't special case constant operands when lowering intrinsics
2020-11-19 16:26:27 +01:00
Dylan DPC
3f0f224be4
Rollup merge of #79082 - ThePuzzlemaker:issue-78941-fix, r=estebank
Improve the diagnostic for when an `fn` contains qualifiers inside an `extern` block.

This mitigates #78941. As suggested by ```@estebank,``` `span_suggestion` was replaced with `span_suggestion_verbose` for this specific diagnostic.
2020-11-19 16:26:21 +01:00
Dylan DPC
5a58b50698
Rollup merge of #78961 - CraftSpider:22565, r=oli-obk
Make bad "rust-call" arguments no longer ICE

The simplest of bad rust-call definitions will no longer cause an ICE. There is a FIXME added for future work, as I wanted to get this easy fix in before trying to either add a hack or mess with the whole obligation system

fixes #22565
2020-11-19 16:26:19 +01:00
cjkenn
1d3305aa66 remove check from const promotion 2020-11-19 08:21:20 -05:00
Tomasz Miąsko
0ab44584aa Revert "Normalize function type during validation"
This reverts commit d486bfcbff.
2020-11-19 05:36:55 +01:00
Tomasz Miąsko
8247223f74 Revert "Always use param_env_reveal_all_normalized in validator"
This reverts commit 99be78d135.
2020-11-19 05:36:51 +01:00
cjkenn
b556690c53 move checks later into optimization passes 2020-11-18 19:16:23 -05:00
bors
675f114d95 Auto merge of #79106 - tmiasko:inline-hint, r=nagisa,eddyb
Fix setting inline hint based on `InstanceDef::requires_inline`

For instances where `InstanceDef::requires_inline` is true, an attempt
is made to set an inline hint though a call to the `inline` function.
The attempt is ineffective, since all attributes will be usually removed
by the second call.

Fix the issue by applying the attributes only once, with user provided
attributes having a priority when provided.

Closes #79108.
2020-11-18 23:44:54 +00:00
Tyson Nottingham
05dde137ca Make PackedFingerprint's Fingerprint private 2020-11-18 15:10:43 -08:00
bors
8256379832 Auto merge of #78995 - Nadrieril:clean-empty-match, r=varkor
Handle empty matches cleanly in exhaustiveness checking

This removes the special-casing of empty matches that was done in `check_match`. This fixes most of https://github.com/rust-lang/rust/issues/55123.
Somewhat unrelatedly, I also made `_match.rs` more self-contained, because I think it's cleaner.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking
2020-11-18 21:24:40 +00:00
Tyson Nottingham
f09d474836 Use PackedFingerprint in DepNode to reduce memory consumption 2020-11-18 12:49:09 -08:00
Esteban Küber
c12e77badd review comment 2020-11-18 09:06:18 -08:00
Esteban Küber
352796402f Account for indirect cyclic requirements 2020-11-18 09:06:18 -08:00
Esteban Küber
2098ade771 Remove redundant notes in E0275
Fix #58964.
2020-11-18 09:05:48 -08:00
Mara Bos
43d13e2d58
Rollup merge of #79158 - lcnr:lazy-norm-coerce, r=oli-obk
type is too big -> values of the type are too big

strictly speaking, `[u8; usize::MAX]` or even `[[[u128; usize::MAX]; usize::MAX]; usize::MAX]` are absolutely fine types as long as you don't try to deal with any values of it.

This error message seems to cause some confusion imo, for example in https://github.com/rust-lang/rust/pull/79135#issuecomment-729361380 so I would prefer us to be more precise here.

See the added test case which uses one of these types without causing an error.

r? ``@oli-obk``
2020-11-18 15:46:40 +01:00
Mara Bos
f85c3f72a4
Rollup merge of #79079 - camelid:mir-visit-docs, r=matthewjasper
Turn top-level comments into module docs in MIR visitor
2020-11-18 15:46:29 +01:00
Mara Bos
92dcf6d733
Rollup merge of #78999 - petrochenkov:deprid, r=eddyb
stability: More precise location for deprecation lint on macros

One missing piece of https://github.com/rust-lang/rust/pull/73178.
2020-11-18 15:46:25 +01:00
Mara Bos
c7e9029b80
Rollup merge of #78361 - DevJPM:master, r=workingjubilee
Updated the list of white-listed target features for x86

This PR both adds in-source documentation on what to look out for when adding a new (X86) feature set and [adds all that are detectable at run-time in Rust stable as of 1.27.0](https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/src/detect/arch/x86.rs).

This should only enable the use of the corresponding LLVM intrinsics.
Actual intrinsics need to be added separately in rust-lang/stdarch.

It also re-orders the run-time-detect test statements to be more consistent
with the actual list of intrinsics whitelisted and removes underscores not present
in the actual names (which might be mistaken as being part of the name)

The reference for LLVM's feature names used is [this file](https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/X86TargetParser.def).

This PR was motivated as the compiler end's part for allowing #67329 to be adressed over on rust-lang/stdarch
2020-11-18 15:46:19 +01:00
cjkenn
51c2218d1f move fuel checks to later points in instcombine and const_prop, add opt level flag to test 2020-11-18 08:49:46 -05:00
varkor
efcbf1b00b Permit standalone generic parameters as const generic arguments in macros 2020-11-18 13:16:35 +00:00
Bastian Kauschke
88584d5800 change error for LayoutErr::SizeOverflow 2020-11-18 11:38:30 +01:00
Aman Arora
9f70e782f7 Remove THIR::ExprKind::SelfRef
ExprKind::SelfRef was used to express accessing `self` in
the desugared Closure/Generator struct when lowering captures in THIR.

Since we handle captures in MIR now, we don't need `ExprKind::Self`.
2020-11-17 17:49:42 -05:00
Aman Arora
7faebe57b2 Move capture lowering from THIR to MIR
This allows us to:
- Handle precise Places captured by a closure directly in MIR. Handling
captures in MIR is easier since we can rely on/ tweak PlaceBuilder to
generate `mir::Place`s that resemble how we store captures (`hir::Place`).
- Allows us to handle `let _ = x` case when feature `capture_disjoint_fields`
is enabled directly in MIR. This is required to be done in MIR since
patterns are desugared in MIR.
2020-11-17 17:49:42 -05:00
Rune Tynan
e8426a617b
Remove unnecessary abi import 2020-11-17 15:49:40 -05:00
Joshua Nelson
c9a17b1d3f Fix broken handling of MacroDef in Map::attrs
This also uses an exhaustive match to avoid future similar bugs.
2020-11-17 15:13:25 -05:00
Rune Tynan
c825c74dc9
Move change to check_fn, fix up overloaded-calls-nontuple 2020-11-17 14:42:29 -05:00
Mara Bos
b6f52410bb
Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebank
Fix exhaustiveness in case a byte string literal is used at slice type

fixes #79048
2020-11-17 16:13:53 +01:00