Skip to content

Commit

Permalink
Use assoc integer constants in librustc_*
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 6, 2020
1 parent cf8df01 commit f7778d3
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
}
}

pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
pub const CODEGEN_WORKER_ID: usize = usize::MAX;

/// `FatalError` is explicitly not `Send`.
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
}

pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
pub const CODEGEN_WORKER_ID: usize = usize::MAX;

pub fn codegen_crate<B: ExtraBackendMethods>(
backend: B,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ impl EmitterWriter {
let mut multilines = FxHashMap::default();

// Get the left-side margin to remove it
let mut whitespace_margin = std::usize::MAX;
let mut whitespace_margin = usize::MAX;
for line_idx in 0..annotated_file.lines.len() {
let file = annotated_file.file.clone();
let line = &annotated_file.lines[line_idx];
Expand All @@ -1373,19 +1373,19 @@ impl EmitterWriter {
}
}
}
if whitespace_margin == std::usize::MAX {
if whitespace_margin == usize::MAX {
whitespace_margin = 0;
}

// Left-most column any visible span points at.
let mut span_left_margin = std::usize::MAX;
let mut span_left_margin = usize::MAX;
for line in &annotated_file.lines {
for ann in &line.annotations {
span_left_margin = min(span_left_margin, ann.start_col);
span_left_margin = min(span_left_margin, ann.end_col);
}
}
if span_left_margin == std::usize::MAX {
if span_left_margin == usize::MAX {
span_left_margin = 0;
}

Expand Down Expand Up @@ -1421,7 +1421,7 @@ impl EmitterWriter {
} else {
termize::dimensions()
.map(|(w, _)| w.saturating_sub(code_offset))
.unwrap_or(std::usize::MAX)
.unwrap_or(usize::MAX)
};

let margin = Margin::new(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_index/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a, T: Idx> BitIter<'a, T> {
// additional state about whether we have started.
BitIter {
word: 0,
offset: std::usize::MAX - (WORD_BITS - 1),
offset: usize::MAX - (WORD_BITS - 1),
iter: words.iter(),
marker: PhantomData,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trait_selection/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ fn receiver_is_dispatchable<'tcx>(
// FIXME(mikeyhew) this is a total hack. Once object_safe_for_dispatch is stabilized, we can
// replace this with `dyn Trait`
let unsized_self_ty: Ty<'tcx> =
tcx.mk_ty_param(::std::u32::MAX, Symbol::intern("RustaceansAreAwesome"));
tcx.mk_ty_param(u32::MAX, Symbol::intern("RustaceansAreAwesome"));

// `Receiver[Self => U]`
let unsized_receiver_ty =
Expand Down
8 changes: 2 additions & 6 deletions src/librustc_trait_selection/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3625,11 +3625,7 @@ struct ProvisionalEvaluation {

impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
fn default() -> Self {
Self {
dfn: Cell::new(0),
reached_depth: Cell::new(std::usize::MAX),
map: Default::default(),
}
Self { dfn: Cell::new(0), reached_depth: Cell::new(usize::MAX), map: Default::default() }
}
}

Expand Down Expand Up @@ -3728,7 +3724,7 @@ impl<'tcx> ProvisionalEvaluationCache<'tcx> {
op(fresh_trait_ref, eval.result);
}

self.reached_depth.set(std::usize::MAX);
self.reached_depth.set(usize::MAX);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2620,13 +2620,13 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<usize> {
_ => None,
};
if let Some(Lit { kind: LitKind::Int(ordinal, LitIntType::Unsuffixed), .. }) = sole_meta_list {
if *ordinal <= std::usize::MAX as u128 {
if *ordinal <= usize::MAX as u128 {
Some(*ordinal as usize)
} else {
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
tcx.sess
.struct_span_err(attr.span, &msg)
.note("the value may not exceed `std::usize::MAX`")
.note("the value may not exceed `usize::MAX`")
.emit();
None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ error: ordinal value in `link_ordinal` is too large: `18446744073709551616`
LL | #[link_ordinal(18446744073709551616)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the value may not exceed `std::usize::MAX`
= note: the value may not exceed `usize::MAX`

error: aborting due to previous error

0 comments on commit f7778d3

Please sign in to comment.