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 #84509

Closed
wants to merge 131 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 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
392d549
Auto merge of #78880 - CDirkx:not_supported, r=joshtriplett
bors 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
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
5d9eeff
Ensure TLS destructors run before thread joins in SGX
mzohreva 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
51676f2
Rollup merge of #83519 - oli-obk:assign_shrink_your_normal_code, r=pn…
Dylan-DPC Apr 24, 2021
61247c3
Rollup merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkor
Dylan-DPC Apr 24, 2021
365ba09
Rollup merge of #84409 - mzohreva:mz/tls-dtors-before-join, r=dtolnay
Dylan-DPC Apr 24, 2021
81a0355
Rollup merge of #84412 - ehuss:update-cargo, r=ehuss
Dylan-DPC Apr 24, 2021
438e20a
Rollup merge of #84427 - flip1995:clippyup, r=Manishearth
Dylan-DPC Apr 24, 2021
edb7154
Rollup merge of #84460 - jyn514:doctree-is-crate, r=camelid
Dylan-DPC Apr 24, 2021
0dd60e1
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
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
7 changes: 7 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 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
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
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
42 changes: 42 additions & 0 deletions compiler/rustc_mir/src/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts};
use rustc_middle::ty::{self, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable};
use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, mir::visit::TyContext};
use rustc_session::config::EntryFnType;
use rustc_session::lint::builtin::LARGE_ASSIGNMENTS;
use rustc_span::source_map::{dummy_spanned, respan, Span, Spanned, DUMMY_SP};
use rustc_target::abi::Size;
use smallvec::SmallVec;
use std::iter;
use std::ops::Range;
Expand Down Expand Up @@ -753,6 +755,46 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
self.super_terminator(terminator, location);
}

fn visit_operand(&mut self, operand: &mir::Operand<'tcx>, location: Location) {
self.super_operand(operand, location);
let limit = self.tcx.sess.move_size_limit();
if limit == 0 {
return;
}
let limit = Size::from_bytes(limit);
let ty = operand.ty(self.body, self.tcx);
let ty = self.monomorphize(ty);
let layout = self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty));
if let Ok(layout) = layout {
if layout.size > limit {
debug!(?layout);
let source_info = self.body.source_info(location);
debug!(?source_info);
let lint_root = source_info.scope.lint_root(&self.body.source_scopes);
debug!(?lint_root);
let lint_root = match lint_root {
Some(lint_root) => lint_root,
// This happens when the issue is in a function from a foreign crate that
// we monomorphized in the current crate. We can't get a `HirId` for things
// in other crates.
// FIXME: Find out where to report the lint on. Maybe simply crate-level lint root
// but correct span? This would make the lint at least accept crate-level lint attributes.
None => return,
};
self.tcx.struct_span_lint_hir(
LARGE_ASSIGNMENTS,
lint_root,
source_info.span,
|lint| {
let mut err = lint.build(&format!("moving {} bytes", layout.size.bytes()));
err.span_label(source_info.span, "value moved from here");
err.emit()
},
);
}
}
}

fn visit_local(
&mut self,
_place_local: &Local,
Expand Down
19 changes: 4 additions & 15 deletions compiler/rustc_mir/src/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use rustc_middle::mir::visit::{
MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor,
};
use rustc_middle::mir::{
AssertKind, BasicBlock, BinOp, Body, ClearCrossCrate, Constant, ConstantKind, Local, LocalDecl,
LocalKind, Location, Operand, Place, Rvalue, SourceInfo, SourceScope, SourceScopeData,
Statement, StatementKind, Terminator, TerminatorKind, UnOp, RETURN_PLACE,
AssertKind, BasicBlock, BinOp, Body, Constant, ConstantKind, Local, LocalDecl, LocalKind,
Location, Operand, Place, Rvalue, SourceInfo, SourceScope, SourceScopeData, Statement,
StatementKind, Terminator, TerminatorKind, UnOp, RETURN_PLACE,
};
use rustc_middle::ty::layout::{HasTyCtxt, LayoutError, TyAndLayout};
use rustc_middle::ty::subst::{InternalSubsts, Subst};
Expand Down Expand Up @@ -440,18 +440,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
}

fn lint_root(&self, source_info: SourceInfo) -> Option<HirId> {
let mut data = &self.source_scopes[source_info.scope];
// 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 = &self.source_scopes[data.parent_scope.unwrap()];
}
trace!(?data);
match &data.local_data {
ClearCrossCrate::Set(data) => Some(data.lint_root),
ClearCrossCrate::Clear => None,
}
source_info.scope.lint_root(&self.source_scopes)
}

fn use_ecx<F, T>(&mut self, f: F) -> Option<T>
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,6 @@ impl<'a> Resolver<'a> {
);
err
}
ResolutionError::ParamInAnonConstInTyDefault(name) => {
let mut err = self.session.struct_span_err(
span,
"constant values inside of type parameter defaults must not depend on generic parameters",
);
err.span_label(
span,
format!("the anonymous constant must not depend on the parameter `{}`", name),
);
err
}
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
let mut err = self.session.struct_span_err(
span,
Expand Down
Loading