const_eval: fix some outdated comments · rust-lang/rust@6d1db11 (original) (raw)

`@@ -227,12 +227,11 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval

`

227

227

``

228

228

`// Keep interning as long as there are things to intern.

`

229

229

`// We show errors if there are dangling pointers, or mutable pointers in immutable contexts

`

230

``

`` -

// (i.e., everything except for static mut). When these errors affect references, it is

``

231

``

`-

// unfortunate that we show these errors here and not during validation, since validation can

`

232

``

`-

// show much nicer errors. However, we do need these checks to be run on all pointers, including

`

233

``

`-

// raw pointers, so we cannot rely on validation to catch them -- and since interning runs

`

234

``

`-

// before validation, and interning doesn't know the type of anything, this means we can't show

`

235

``

`-

// better errors. Maybe we should consider doing validation before interning in the future.

`

``

230

`` +

// (i.e., everything except for static mut). We only return these errors as a Result

``

``

231

`+

// so that the caller can run validation, and subsequently only report interning errors

`

``

232

`+

// if validation fails. Validation has the better error messages so we prefer those, but

`

``

233

`+

// interning has better coverage since it "sees" all pointers, including raw pointers and

`

``

234

`+

// references stored in unions.

`

236

235

`while let Some(prov) = todo.pop() {

`

237

236

`trace!(?prov);

`

238

237

`let alloc_id = prov.alloc_id();

`

`@@ -279,12 +278,12 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval

`

279

278

`// when there is memory there that someone might expect to be mutable, but we make it immutable.

`

280

279

`let dangling = !is_already_global && !ecx.memory.alloc_map.contains_key(&alloc_id);

`

281

280

`if !dangling {

`

282

``

`-

// Found a mutable reference inside a const where inner allocations should be

`

``

281

`+

// Found a mutable pointer inside a const where inner allocations should be

`

283

282

`// immutable.

`

284

283

`if !ecx.tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you {

`

285

284

`span_bug!(

`

286

285

` ecx.tcx.span,

`

287

``

`-

"the static const safety checks accepted mutable references they should not have accepted"

`

``

286

`+

"the static const safety checks accepted a mutable pointer they should not have accepted"

`

288

287

`);

`

289

288

`}

`

290

289

`// Prefer dangling pointer errors over mutable pointer errors

`