Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #84512

Closed
wants to merge 135 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
1768efa
Fix FP in `single_component_path_imports` lint
ThibsG Mar 14, 2021
6985d13
Take into account sub modules
ThibsG Mar 28, 2021
c05760f
Fix `macro_use_import` ICE
Jarcho Apr 3, 2021
81dfb9e
Check path imports per module
ThibsG Apr 4, 2021
1573d10
tabs_in_doc_comments: Fix ICE due to char indexing
phansch Apr 6, 2021
6b5778e
Fix `explicit_into_iter_loop`
Jarcho Mar 27, 2021
7468542
Introduce is_lang_ctor
camsteffen Apr 2, 2021
f6d1f36
Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup
flip1995 Apr 8, 2021
c40fa00
Auto merge of #7022 - Jarcho:macro_use_import_ice, r=flip1995
bors Apr 8, 2021
4f7fc11
Add invalid null pointer usage lint.
boxdot Oct 18, 2020
75efc14
Auto merge of #7023 - boxdot:invalid-null-usage-v2, r=camsteffen
bors Apr 8, 2021
012f9d4
Use `register_renamed` instead of `register_removed` for uplifted lints
jyn514 Apr 9, 2021
f7c2c44
Auto merge of #7056 - jyn514:register-renamed, r=flip1995
bors Apr 9, 2021
297e84f
Handle imports which are nested directly
ThibsG Apr 10, 2021
dde46c9
Replace complex conditional with pattern matching
phansch Apr 10, 2021
8b9331b
Fix rustfmt error / Add comment for tab character
phansch Apr 10, 2021
47a4865
Fix dogfood
phansch Apr 10, 2021
43e6c65
Remove `debug_assert` from `panic_in_result_fn`
daxpedda Apr 10, 2021
8f4417f
Fix rustfmt
daxpedda Apr 10, 2021
271c163
Fix false-positive `debug_assert`
daxpedda Apr 10, 2021
fd5cf4e
Auto merge of #7060 - daxpedda:debug-assert-panic-in-result-fn, r=fli…
bors Apr 10, 2021
cb14e7e
Fix false-positive `debug_assert` in `panic`
daxpedda Apr 10, 2021
a45faf6
Deprecate filter_map
camsteffen Apr 9, 2021
75e20ba
Auto merge of #7063 - daxpedda:debug-assert-panic, r=Manishearth
bors Apr 10, 2021
3ce6f0d
Fix FP in `wrong_self_convention` lint
ThibsG Apr 11, 2021
67fad01
Auto merge of #6905 - ThibsG:fpSingleComponentPathImports5210, r=gira…
bors Apr 11, 2021
a6b514c
Auto merge of #7059 - camsteffen:filter-map, r=flip1995
bors Apr 11, 2021
fb54b70
Add a note on the issue #5953
rail-rain Apr 10, 2021
f0ceb28
Auto merge of #7065 - rail-rain:warn_copy_pass_by_ref, r=Manishearth
bors Apr 12, 2021
aecccbc
Auto merge of #7047 - camsteffen:lang-ctor, r=flip1995
bors Apr 12, 2021
c3ef585
Auto merge of #6982 - Jarcho:explicit_into_iter_loop_fp, r=flip1995
bors Apr 12, 2021
53260df
fix a false negative on `needless_return`
TaKO8Ki Apr 12, 2021
0218a3b
add tests for a false negative on `needless_return`
TaKO8Ki Apr 12, 2021
e6c67ad
fix limit_stderr_length error
TaKO8Ki Apr 12, 2021
411c0df
Auto merge of #7064 - ThibsG:WrongSelfFix, r=giraffate
bors Apr 12, 2021
d6beb18
Remove paths::STD_PTR_NULL
boxdot Apr 12, 2021
2a96bc4
Auto merge of #7067 - TaKO8Ki:fix-false-negative-on-needless-return, …
bors Apr 12, 2021
e9728b8
Auto merge of #7068 - boxdot:remove-std-ptr-null, r=camsteffen
bors Apr 12, 2021
76bd5d2
Refactor diagnostic item methods
camsteffen Apr 12, 2021
0d14429
Improve changelog check error handling
camsteffen Apr 12, 2021
8f3c245
Auto merge of #7074 - camsteffen:diag-methods, r=llogiq
bors Apr 13, 2021
26a1989
Fix a FP in `missing_const_for_fn`
rail-rain Apr 13, 2021
cbdebd9
Explain why we use `char_indices()` instead of `chars()`
phansch Apr 14, 2021
19740d9
Auto merge of #7076 - rail-rain:missing_const_for_fn, r=phansch
bors Apr 14, 2021
24921df
Auto merge of #7039 - phansch:melt-ice, r=flip1995
bors Apr 14, 2021
b1c675f
Auto merge of #7070 - camsteffen:changelog-stderr, r=flip1995
bors Apr 14, 2021
cbde4f2
parent_node_is_if_expr now also recognizes if let as parent if
xFrednet Apr 10, 2021
7e90bb6
Fixed website inline code background
xFrednet Apr 13, 2021
2992b19
Added inferred local type comparion to SpanlessEq
xFrednet Apr 13, 2021
0b4af72
PR suggestions and removing utils::parent_node_is_if_expr
xFrednet Apr 14, 2021
ce5e927
Improve `map_entry` lint
Jarcho Mar 25, 2021
b63a5b5
`map_entry` improvements
Jarcho Mar 25, 2021
3323ff7
`map_entry` improvements
Jarcho Mar 25, 2021
bcf3488
Minor cleanup of `map_entry` and a few additional tests.
Jarcho Mar 30, 2021
779d98f
Don't allow adjustments for `manual_map`
Jarcho Apr 15, 2021
014bf43
Add note for pre-expansion passes
camsteffen Apr 15, 2021
52c8c9c
Auto merge of #7090 - camsteffen:pre-expansion-note, r=Manishearth
bors Apr 15, 2021
f6c5d8d
Remove all usages of `match_path`, `match_qpath` and `match_path_ast`…
Jarcho Apr 7, 2021
586a993
Auto merge of #7049 - Jarcho:remove_match_path, r=camsteffen
bors Apr 15, 2021
b658163
Improve `redundant_pattern_matching`
Jarcho Jan 3, 2021
c02baba
`redundant_pattern_matching` fix inverted boolean when missing `Drop`…
Jarcho Apr 2, 2021
9a55c0c
Fix `single_match`
Jarcho Apr 16, 2021
faa9756
Auto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate
bors Apr 16, 2021
696562d
Remove #[main] attribute.
crlf0710 Apr 8, 2021
ddc2598
Auto merge of #7093 - Jarcho:single_match_fp, r=llogiq
bors Apr 16, 2021
1e0a3ff
Auto merge of #6937 - Jarcho:map_entry_suggestion, r=giraffate
bors Apr 16, 2021
61230f4
Fixed incosistent_struct_constructor triggers in macro-generated code
yawara Apr 16, 2021
0462666
Add cloned_instead_of_copied lint
camsteffen Apr 16, 2021
b049c88
Eat dogfood
camsteffen Apr 16, 2021
7f2068c
Auto merge of #6568 - Jarcho:redundant_pattern_matching, r=flip1995
bors Apr 16, 2021
28dbcd8
Auto merge of #7098 - camsteffen:cloned-copied, r=Manishearth
bors Apr 16, 2021
2d050f4
add type in help of from over Into
ABouttefeux Apr 16, 2021
ccd0f0b
added missing line in test ouput
ABouttefeux Apr 16, 2021
eaf0f3d
Auto merge of #7075 - xFrednet:7054-fp-branches-sharing-code, r=camst…
bors Apr 16, 2021
559dedd
Allow allman style braces in `suspicious_else_formatting`
Jarcho Apr 15, 2021
831c157
Auto merge of #7087 - Jarcho:allman_style_else, r=camsteffen
bors Apr 16, 2021
5af078a
Add flat_map_option lint
camsteffen Apr 16, 2021
e441b33
Auto merge of #7099 - ABouttefeux:master, r=llogiq
bors Apr 16, 2021
8b5faf4
Switch transmute_ptr_to_ptr to "pedantic" class.
taralx Apr 16, 2021
9137803
Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[…
Apr 10, 2021
8c37e19
Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkov
bors Apr 18, 2021
024a49a
Fix clippy test using `ErrorKind`
CDirkx Mar 29, 2021
fdad6ab
move 'trait bounds on const fn' to separate feature gate
RalfJung Apr 18, 2021
fbfaab2
separate feature flag for unsizing casts in const fn
RalfJung Apr 18, 2021
392d549
Auto merge of #78880 - CDirkx:not_supported, r=joshtriplett
bors Apr 18, 2021
bd95569
fix feature use in rustc libs
RalfJung Apr 18, 2021
243dc46
un-double `return` on try_err
llogiq Apr 18, 2021
c569d33
Auto merge of #7108 - rust-lang:fix-return-try-err, r=Manishearth
bors Apr 18, 2021
04db4ab
add gate tests and pacify tidy
RalfJung Apr 19, 2021
46d09f7
remove E0723 error code
RalfJung Apr 19, 2021
fe5cefc
Auto merge of #7101 - camsteffen:flat-map-option, r=giraffate
bors Apr 19, 2021
b20cbff
Fix links in doc
giraffate Apr 19, 2021
2d65b2d
Update pull request template
giraffate Apr 19, 2021
a3b1efd
Auto merge of #7112 - giraffate:update_pull_request_template, r=camst…
bors Apr 19, 2021
c6b381c
useless use of format! should return function directly
basavesh Apr 19, 2021
42d0702
Ignore aarch64 for this test as it's x86 assembly only. Fixes #7091
ctennis Apr 18, 2021
8f77e20
Auto merge of #7111 - giraffate:fix_link_in_doc, r=Manishearth
bors Apr 19, 2021
419bf6b
fix suggestion for unsized function parameters
lcnr Apr 18, 2021
e2e104b
Add lint to check for boolean comparison in assert macro calls
GuillaumeGomez Apr 15, 2021
b7c12f3
Auto merge of #7092 - basavesh:fix#7066, r=giraffate
bors Apr 19, 2021
6eae905
Add a test for FP in macro expansion
yawara Apr 20, 2021
ec38ea1
Auto merge of #7097 - yawara:fix/7069, r=llogiq
bors Apr 20, 2021
e9696c8
Implement a lint that highlights all moves larger than 1000 bytes
oli-obk Mar 26, 2021
a2f2179
Add an attribute to be able to configure the limit
oli-obk Mar 26, 2021
a46bc56
Tidy
oli-obk Mar 26, 2021
6e988c0
Typo
oli-obk Mar 26, 2021
85b1c67
Limit test to 64 bit systems to keep the sizes in the diagnostics stable
oli-obk Mar 29, 2021
926286a
Auto merge of #7109 - ctennis:ct/asm_syntax_aarch64, r=flip1995
bors Apr 21, 2021
259a368
fix name resolution for param defaults
lcnr Apr 18, 2021
7cb1dcd
loosen ordering restricts for `const_generics_defaults`
lcnr Apr 18, 2021
312b4fd
improve wf check for const param defaults
lcnr Apr 18, 2021
d3e0d2f
supply substs to anon consts in defaults
lcnr Apr 18, 2021
bbc22e2
Auto merge of #7083 - GuillaumeGomez:bool-assert-eq, r=camsteffen
bors Apr 21, 2021
224881b
add unnecessary_self_imports lint
ebobrow Apr 13, 2021
79b9eb5
Auto merge of #7072 - ebobrow:imports-ending-with-self, r=camsteffen
bors Apr 21, 2021
1f7aef3
Auto merge of #7102 - taralx:taralx-patch-1, r=flip1995
bors Apr 22, 2021
44c8057
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Apr 22, 2021
876897d
Bump nightly version -> 2021-04-22
flip1995 Apr 22, 2021
98e2b9f
Auto merge of #7119 - flip1995:rustup, r=flip1995
bors Apr 22, 2021
9482caf
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
flip1995 Apr 22, 2021
e29f46c
rustdoc: Remove unnecessary `is_crate` field from doctree::Module and…
jyn514 Apr 23, 2021
1481af9
Take ItemType instead of TypeKind in record_extern_fqn
jyn514 Apr 23, 2021
f3ef4b2
Use ItemType in cache
jyn514 Apr 23, 2021
0a9b2ca
Remove `TypeKind`
jyn514 Apr 23, 2021
8fd29bf
Remove unused `impl Clean<ItemType> for DefKind`
jyn514 Apr 23, 2021
18ee323
Don't repeat `hir::def::DefKind` so much
jyn514 Apr 23, 2021
ab54197
Fix macro bug in `impl From<DefKind> for ItemType`
jyn514 Apr 23, 2021
893ca66
Update cargo, rls
ehuss Apr 22, 2021
a474fbf
Rollup merge of #83519 - oli-obk:assign_shrink_your_normal_code, r=pn…
Dylan-DPC Apr 24, 2021
57ce077
Rollup merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkor
Dylan-DPC Apr 24, 2021
6c6a194
Rollup merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk
Dylan-DPC Apr 24, 2021
14bfb6b
Rollup merge of #84412 - ehuss:update-cargo, r=ehuss
Dylan-DPC Apr 24, 2021
4540c9f
Rollup merge of #84427 - flip1995:clippyup, r=Manishearth
Dylan-DPC Apr 24, 2021
c2ce254
Rollup merge of #84460 - jyn514:doctree-is-crate, r=camelid
Dylan-DPC Apr 24, 2021
e03cdb6
Rollup merge of #84464 - jyn514:type-kind, r=CraftSpider
Dylan-DPC Apr 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1245,12 +1245,9 @@ checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"

[[package]]
name = "fst"
version = "0.3.5"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "927fb434ff9f0115b215dc0efd2e4fbdd7448522a92a1aa37c77d6a2f8f1ebd6"
dependencies = [
"byteorder",
]
checksum = "d79238883cf0307100b90aba4a755d8051a3182305dfe7f649a1e9dc0517006f"

[[package]]
name = "fuchsia-zircon"
Expand Down Expand Up @@ -1759,9 +1756,9 @@ dependencies = [

[[package]]
name = "json"
version = "0.11.15"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5"
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"

[[package]]
name = "jsondocck"
Expand Down Expand Up @@ -3133,7 +3130,7 @@ dependencies = [
"futures 0.3.12",
"heck",
"home",
"itertools 0.8.2",
"itertools 0.9.0",
"jsonrpc-core",
"lazy_static",
"log",
Expand Down Expand Up @@ -3168,14 +3165,14 @@ dependencies = [

[[package]]
name = "rls-analysis"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534032993e1b60e5db934eab2dde54da7afd1e46c3465fddb2b29eb47cb1ed3a"
version = "0.18.2"
dependencies = [
"derive-new",
"env_logger 0.7.1",
"fst",
"itertools 0.8.2",
"itertools 0.9.0",
"json",
"lazy_static",
"log",
"rls-data",
"rls-span",
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(const_fn)] // For the `transmute` in `P::new`
#![cfg_attr(bootstrap, feature(const_fn))] // For the `transmute` in `P::new`
#![cfg_attr(not(bootstrap), feature(const_fn_unsize))] // For the `transmute` in `P::new`
#![feature(const_fn_transmute)]
#![feature(const_panic)]
#![feature(crate_visibility_modifier)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ fn validate_generic_param_order(
GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident),
GenericParamKind::Const { ref ty, kw_span: _, default: _ } => {
let ty = pprust::ty_to_string(ty);
let unordered = sess.features_untracked().const_generics;
let unordered = sess.features_untracked().unordered_const_ty_params();
(ParamKindOrd::Const { unordered }, Some(format!("const {}: {}", param.ident, ty)))
}
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ E0716: include_str!("./error_codes/E0716.md"),
E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"),
E0723: include_str!("./error_codes/E0723.md"),
E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"),
Expand Down Expand Up @@ -636,6 +635,7 @@ E0781: include_str!("./error_codes/E0781.md"),
E0717, // rustc_promotable without stability attribute
// E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute
// E0723, unstable feature in `const` context
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]`
Expand Down
20 changes: 0 additions & 20 deletions compiler/rustc_error_codes/src/error_codes/E0723.md

This file was deleted.

13 changes: 13 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ macro_rules! declare_features {
_ => panic!("`{}` was not listed in `declare_features`", feature),
}
}

pub fn unordered_const_ty_params(&self) -> bool {
self.const_generics || self.const_generics_defaults
}
}
};
}
Expand Down Expand Up @@ -633,6 +637,9 @@ declare_features! (
/// Allows associated types in inherent impls.
(active, inherent_associated_types, "1.52.0", Some(8995), None),

// Allows setting the threshold for the `large_assignments` lint.
(active, large_assignments, "1.52.0", Some(83518), None),

/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries.
(active, c_unwind, "1.52.0", Some(74990), None),

Expand All @@ -642,6 +649,12 @@ declare_features! (
/// Allows `extern "wasm" fn`
(active, wasm_abi, "1.53.0", Some(83788), None),

/// Allows trait bounds in `const fn`.
(active, const_fn_trait_bound, "1.53.0", Some(57563), None),

/// Allows unsizing coercions in `const fn`.
(active, const_fn_unsize, "1.53.0", Some(64992), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
const_eval_limit, CrateLevel, template!(NameValueStr: "N"), const_eval_limit,
experimental!(const_eval_limit)
),
gated!(
move_size_limit, CrateLevel, template!(NameValueStr: "N"), large_assignments,
experimental!(move_size_limit)
),

// Entry point:
ungated!(main, Normal, template!(Word)),
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ impl GenericArg<'_> {
match self {
GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
GenericArg::Type(_) => ast::ParamKindOrd::Type,
GenericArg::Const(_) => ast::ParamKindOrd::Const { unordered: feats.const_generics },
GenericArg::Const(_) => {
ast::ParamKindOrd::Const { unordered: feats.unordered_const_ty_params() }
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html

#![feature(crate_visibility_modifier)]
#![feature(const_fn)] // For the unsizing cast on `&[]`
#![feature(const_panic)]
#![feature(extended_key_value_attributes)]
#![feature(in_band_lifetimes)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_index/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(allow_internal_unstable)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(extend_one)]
#![feature(iter_zip)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(extend_one)]
#![feature(iter_zip)]
Expand Down
34 changes: 34 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,39 @@ declare_lint! {
};
}

declare_lint! {
/// The `large_assignments` lint detects when objects of large
/// types are being moved around.
///
/// ### Example
///
/// ```rust,ignore (can crash on some platforms)
/// let x = [0; 50000];
/// let y = x;
/// ```
///
/// produces:
///
/// ```text
/// warning: moving a large value
/// --> $DIR/move-large.rs:1:3
/// let y = x;
/// - Copied large value here
/// ```
///
/// ### Explanation
///
/// When using a large type in a plain assignment or in a function
/// argument, idiomatic code can be inefficient.
/// Ideally appropriate optimizations would resolve this, but such
/// optimizations are only done in a best-effort manner.
/// This lint will trigger on all sites of large moves and thus allow the
/// user to resolve them in code.
pub LARGE_ASSIGNMENTS,
Warn,
"detects large moves or copies",
}

declare_lint_pass! {
/// Does nothing as a lint pass, but registers some `Lint`s
/// that are used by other parts of the compiler.
Expand Down Expand Up @@ -2962,6 +2995,7 @@ declare_lint_pass! {
LEGACY_DERIVE_HELPERS,
PROC_MACRO_BACK_COMPAT,
OR_PATTERNS_BACK_COMPAT,
LARGE_ASSIGNMENTS,
]
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(core_intrinsics)]
#![feature(discriminant_kind)]
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_middle/src/middle/limits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
//! Registering limits, recursion_limit, type_length_limit and const_eval_limit
//! Registering limits:
//! * recursion_limit,
//! * move_size_limit,
//! * type_length_limit, and
//! * const_eval_limit
//!
//! There are various parts of the compiler that must impose arbitrary limits
//! on how deeply they recurse to prevent stack overflow. Users can override
Expand All @@ -8,21 +12,22 @@
use crate::bug;
use rustc_ast as ast;
use rustc_data_structures::sync::OnceCell;
use rustc_session::{Limit, Session};
use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol};

use std::num::IntErrorKind;

pub fn update_limits(sess: &Session, krate: &ast::Crate) {
update_limit(sess, krate, &sess.recursion_limit, sym::recursion_limit, 128);
update_limit(sess, krate, &sess.move_size_limit, sym::move_size_limit, 0);
update_limit(sess, krate, &sess.type_length_limit, sym::type_length_limit, 1048576);
update_limit(sess, krate, &sess.const_eval_limit, sym::const_eval_limit, 1_000_000);
}

fn update_limit(
sess: &Session,
krate: &ast::Crate,
limit: &OnceCell<Limit>,
limit: &OnceCell<impl From<usize> + std::fmt::Debug>,
name: Symbol,
default: usize,
) {
Expand All @@ -34,7 +39,7 @@ fn update_limit(
if let Some(s) = attr.value_str() {
match s.as_str().parse() {
Ok(n) => {
limit.set(Limit::new(n)).unwrap();
limit.set(From::from(n)).unwrap();
return;
}
Err(e) => {
Expand Down Expand Up @@ -63,5 +68,5 @@ fn update_limit(
}
}
}
limit.set(Limit::new(default)).unwrap();
limit.set(From::from(default)).unwrap();
}
25 changes: 24 additions & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use crate::ty::print::{FmtPrinter, Printer};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, List, Ty, TyCtxt};
use crate::ty::{AdtDef, InstanceDef, Region, ScalarInt, UserTypeAnnotationIndex};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_hir::{self, GeneratorKind};
use rustc_hir::{self as hir, HirId};
use rustc_target::abi::{Size, VariantIdx};

use polonius_engine::Atom;
Expand Down Expand Up @@ -1948,6 +1948,29 @@ rustc_index::newtype_index! {
}
}

impl SourceScope {
/// Finds the original HirId this MIR item came from.
/// This is necessary after MIR optimizations, as otherwise we get a HirId
/// from the function that was inlined instead of the function call site.
pub fn lint_root(
self,
source_scopes: &IndexVec<SourceScope, SourceScopeData<'tcx>>,
) -> Option<HirId> {
let mut data = &source_scopes[self];
// FIXME(oli-obk): we should be able to just walk the `inlined_parent_scope`, but it
// does not work as I thought it would. Needs more investigation and documentation.
while data.inlined.is_some() {
trace!(?data);
data = &source_scopes[data.parent_scope.unwrap()];
}
trace!(?data);
match &data.local_data {
ClearCrossCrate::Set(data) => Some(data.lint_root),
ClearCrossCrate::Clear => None,
}
}
}

#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
pub struct SourceScopeData<'tcx> {
pub span: Span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl GenericParamDefKind {
GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime,
GenericParamDefKind::Type { .. } => ast::ParamKindOrd::Type,
GenericParamDefKind::Const { .. } => {
ast::ParamKindOrd::Const { unordered: tcx.features().const_generics }
ast::ParamKindOrd::Const { unordered: tcx.features().unordered_const_ty_params() }
}
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Rust MIR: a lowered representation of Rust.
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
Expand Down
Loading