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

give *even better* suggestion when matching a const range #76749

Merged
merged 2 commits into from
Sep 19, 2020

Conversation

guswynn
Copy link
Contributor

@guswynn guswynn commented Sep 15, 2020

notice that the err already has "constant defined here"
so this is now exceedingly clear

extension to #76222

r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 15, 2020
@guswynn
Copy link
Contributor Author

guswynn commented Sep 15, 2020

@rustbot modify labels +A-diagnostics +T-compiler

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 15, 2020
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Some small nitpicks inline.

compiler/rustc_typeck/src/check/pat.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/pat.rs Outdated Show resolved Hide resolved
if let Ok(snip) =
self.tcx.sess.source_map().span_to_snippet(span)
{
e.span_suggestion_verbose(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is extremely nested, looks kindof funny lol

also let me know if there is a better way to get the snippet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is fine. At most, I would move this to a new method named along the lines of maybe_suggest_range_literal, simply to make it easier to follow what's going on at a high level.

Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small changes left. Otherwise it looks good to me!

compiler/rustc_typeck/src/check/pat.rs Outdated Show resolved Hide resolved
src/test/ui/issues/issue-76191.stderr Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/pat.rs Outdated Show resolved Hide resolved
if let Ok(snip) =
self.tcx.sess.source_map().span_to_snippet(span)
{
e.span_suggestion_verbose(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is fine. At most, I would move this to a new method named along the lines of maybe_suggest_range_literal, simply to make it easier to follow what's going on at a high level.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 16, 2020

📌 Commit 230355f has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2020
@ecstatic-morse
Copy link
Contributor

@bors rollup

RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 19, 2020
give *even better* suggestion when matching a const range

notice that the err already has "constant defined here"
so this is now *exceedingly clear*

extension to rust-lang#76222

r? @estebank
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 19, 2020
Rollup of 14 pull requests

Successful merges:

 - rust-lang#73963 (deny(unsafe_op_in_unsafe_fn) in libstd/path.rs)
 - rust-lang#75099 (lint/ty: move fns to avoid abstraction violation)
 - rust-lang#75502 (Use implicit (not explicit) rules for promotability by default in `const fn`)
 - rust-lang#75580 (Add test for checking duplicated branch or-patterns)
 - rust-lang#76310 (Add `[T; N]: TryFrom<Vec<T>>` (insta-stable))
 - rust-lang#76400 (Clean up vec benches bench_in_place style)
 - rust-lang#76434 (do not inline black_box when building for Miri)
 - rust-lang#76492 (Add associated constant `BITS` to all integer types)
 - rust-lang#76525 (Add as_str() to string::Drain.)
 - rust-lang#76636 (assert ScalarMaybeUninit size)
 - rust-lang#76749 (give *even better* suggestion when matching a const range)
 - rust-lang#76757 (don't convert types to the same type with try_into (clippy::useless_conversion))
 - rust-lang#76796 (Give a better error message when x.py uses the wrong stage for CI)
 - rust-lang#76798 (Build fixes for RISC-V 32-bit Linux support)

Failed merges:

r? `@ghost`
@bors bors merged commit 5631b5d into rust-lang:master Sep 19, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 19, 2020
@guswynn guswynn deleted the hir_ranges branch February 19, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants