Rollup merge of #83519 - oli-obk:assign_shrink_your_normal_code, r=pnkfelix
Implement a lint that highlights all moves larger than a configured limit Tracking issue: #83518 [MCP 420](https://github.com/rust-lang/compiler-team/issues/420) still ~blazing~ in progress r? ```@pnkfelix``` The main open issue I see with this minimal impl of the feature is that the lint is immediately "stable" (so it can be named on stable), even if it is never executed on stable. I don't think we have the concept of unstable lint names or hiding lint names without an active feature gate, so that would be a bigger change.
This commit is contained in:
commit
e109aa3613
13 changed files with 218 additions and 21 deletions
|
@ -83,6 +83,12 @@ impl Limit {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<usize> for Limit {
|
||||
fn from(value: usize) -> Self {
|
||||
Self::new(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Limit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
|
@ -143,6 +149,10 @@ pub struct Session {
|
|||
/// operations such as auto-dereference and monomorphization.
|
||||
pub recursion_limit: OnceCell<Limit>,
|
||||
|
||||
/// The size at which the `large_assignments` lint starts
|
||||
/// being emitted.
|
||||
pub move_size_limit: OnceCell<usize>,
|
||||
|
||||
/// The maximum length of types during monomorphization.
|
||||
pub type_length_limit: OnceCell<Limit>,
|
||||
|
||||
|
@ -352,6 +362,11 @@ impl Session {
|
|||
self.recursion_limit.get().copied().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn move_size_limit(&self) -> usize {
|
||||
self.move_size_limit.get().copied().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_length_limit(&self) -> Limit {
|
||||
self.type_length_limit.get().copied().unwrap()
|
||||
|
@ -1414,6 +1429,7 @@ pub fn build_session(
|
|||
features: OnceCell::new(),
|
||||
lint_store: OnceCell::new(),
|
||||
recursion_limit: OnceCell::new(),
|
||||
move_size_limit: OnceCell::new(),
|
||||
type_length_limit: OnceCell::new(),
|
||||
const_eval_limit: OnceCell::new(),
|
||||
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue