func (lmb *labelMatcherDeduper) dedupeReNotMatchers() ([]*labels.Matcher, bool) {
	deduped := []*labels.Matcher{}
outerNotRe:
	for i, reNotMatcher := range lmb.reNotMatchers {
		for _, matcher := range lmb.exactMatchers {
			if reNotMatcher.Name == matcher.Name {
				if reNotMatcher.Matches(matcher.Value) {
					continue outerNotRe
				} else {
					return nil, false
				}
			}
		}
		for _, reNotMatcher2 := range lmb.reNotMatchers[i+1:] {
			if reNotMatcher.Name == reNotMatcher2.Name && reNotMatcher.Value == reNotMatcher2.Value {
				continue outerNotRe
			}
		}
		deduped = append(deduped, reNotMatcher)
	}
	return deduped, true
}
dedupeReNotMatchers removes all regex matchers that are ensures by static matchers
or invalidates the query if there are conflicting static ones
package labeler
import (
	"github.com/prometheus/prometheus/pkg/labels"
)
type labelMatcherDeduper struct {
	deduped          []*labels.Matcher
	exactMatchers    []*labels.Matcher
	exactNotMatchers []*labels.Matcher
	reMatchers       []*labels.Matcher
	reNotMatchers    []*labels.Matcher
}
func DedupeMatchers(matchers []*labels.Matcher) []*labels.Matcher {
	lmb := &labelMatcherDeduper{}
	for _, matcher := range matchers {
		switch matcher.Type {
		case labels.MatchEqual:
			lmb.exactMatchers = append(lmb.exactMatchers, matcher)
		case labels.MatchNotEqual:
			lmb.exactNotMatchers = append(lmb.exactNotMatchers, matcher)
		case labels.MatchRegexp:
			lmb.reMatchers = append(lmb.reMatchers, matcher)
		case labels.MatchNotRegexp:
			lmb.reNotMatchers = append(lmb.reNotMatchers, matcher)
		}
	}
	all, ok := lmb.dedupeExactNotMatchers()
	if !ok {
		return NoneLabelMatcher
	}
	deduped, ok := lmb.dedupeExactMatchers()
	if !ok {
		return NoneLabelMatcher
	}
	all = append(all, deduped...)
	deduped, ok = lmb.dedupeReNotMatchers()
	if !ok {
		return NoneLabelMatcher
	}
	all = append(all, deduped...)
	deduped, ok = lmb.dedupeReMatchers()
	if !ok {
		return NoneLabelMatcher
	}
	all = append(all, deduped...)
	return all
}
func (lmb *labelMatcherDeduper) dedupeExactNotMatchers() ([]*labels.Matcher, bool) {
	deduped := []*labels.Matcher{}
outerNotExact:
	for i, notMatcher := range lmb.exactNotMatchers {
		for _, matcher := range lmb.exactMatchers {
			if notMatcher.Name == matcher.Name && notMatcher.Value != matcher.Value {
				continue outerNotExact
			}
		}
		for _, notMatcher2 := range lmb.exactNotMatchers[i+1:] {
			if notMatcher.Name == notMatcher2.Name && notMatcher.Value == notMatcher2.Value {
				continue outerNotExact
			}
		}
		deduped = append(deduped, notMatcher)
	}
	return deduped, true
}
func (lmb *labelMatcherDeduper) dedupeExactMatchers() ([]*labels.Matcher, bool) {
	deduped := []*labels.Matcher{}
outerExact:
	for i, matcher := range lmb.exactMatchers {
		for _, matcher2 := range lmb.exactMatchers[i+1:] {
			if matcher.Name == matcher2.Name {
				if matcher.Value == matcher2.Value {
					continue outerExact
				} else {
					return nil, false
				}
			}
		}
		deduped = append(deduped, matcher)
	}
	return deduped, true
}